Lab 5: Introduction to Python

$24.99 $18.99

Aim: Introduce you to programming in Python quickly! Let’s get started! Create a directory structure to hold your work for this course and all the subsequent labs: Suggestion: CS202/Lab5 Python Basics For this part, refer to Python Basics.pdf Note: This part has been adapted from : https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/Python1_Basics.html Considering that you all have decent amount of…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

Aim: Introduce you to programming in Python quickly!

Let’s get started!

    1. Create a directory structure to hold your work for this course and all the subsequent labs:

      • Suggestion: CS202/Lab5

Python Basics

    1. For this part, refer to Python Basics.pdf

  1. Note: This part has been adapted from : https://www3.ntu.edu.sg/home/ehchua/programming/webprogramming/Python1_Basics.html

  1. Considering that you all have decent amount of experience with programming in C, C++ and now in Java and Perl, you are only expected to run through the above document quickly. Try to focus on differences from other languages!

    1. Once you are comfortable with the basics, attempt the following exercises.

Exercise 1:

    1. Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string: My name is Michele Then I would see the string: Michele is name My shown back to me.

    1. Create and save this program in a file named ReverseString.py

Exercise 2:

    1. Write a Python function that prints out the first ‘n’ rows of Pascal’s triangle. Sample Pascal’s triangle is shown below:

  1. Create and save this program in a file named PascalTriangle.py

Exercises 3:

  1. Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates.

    • Write two different functions to do this – one using a loop and constructing a list, and another using sets (call these functions RemDupLoop and RemDupSet)

    1. Create and save this program in a file named RemoveDuplicates.py

Submitting your work:

    1. All source files as one tar-gzipped archive.

      • When unzipped, it should create a directory with your ID. Example: 2008CSB1001 (NO OTHER FORMAT IS ACCEPTABLE!!! Case sensitive!!!)

      • Negative marks if the TA has to manually change this to run his/her scripts!!

  1. Source files should include the following: (Case-Sensitive file names!!)

ReverseString.py [5 Points]

  • RemoveDuplicates.py [5 Points]

  • PascalTriangle.py [5 Points]

  1. Negative marks for any problems/errors in running your programs

  1. Submit/Upload it to Google Classroom

Lab 5: Introduction to Python
$24.99 $18.99