![]() ![]() |
![]() | Patrice Koehl |
Introduction to Computers: Fall 2013Lab7: Programming with Python (I)This is your first programming assignment!
Obviously, you will program using Python... Step 1: Getting readyPlease use IDLE as your interface to using Python. Create a file in which you will save your program. To do this using IDLE:
Now you are ready to write your program! Step 2: Generate proper headerIt is always worth documenting your program as much as you can!
In your file, add the following lines at the top: # # Author: Your name # Student ID: Your student ID # Date: Today's date # where obviously, "Your name", "Your student ID" and "Today's date" refer to you and the date you are working on this program! Step 3: ProgrammingYou will now solve three small programming exercises; put your solutions to all problems in the file you are working on, one below the other. Two important commands you will need:
Remember to test your program! To do this using IDLE: From the "Run" menu, choose "Run module". This should start the program, taking you back to the main IDLE window. Problem 1: dealing with numbers Write a Python program that reads from standard input the amount of a restaurant bill and outputs two options for tipping, one based on 15% of the bill, the other based on 20% of the bill. Problem 2: dealing with strings Write a Python program that:
Problem 3: Counting words and characters Write a Python program that:
For this problem, you will probably need the function len(): len(string) gives the length of string. Step 4: File submissionOnce you are sure your program is working, submit your file on Smartsite. Please submit your report as a single document (you can name this document as you want, but do keep the .py extension). It is very important to turn in your assignment. If you do not turn in,
you will not get your credit.
Grading:The maximum score you can get is 60. The breakdown is:
You will get credit for a question only if it is properly executed... Do not forget to logout from the lab computers! |
Page last modified 17 December 2015 | http://www.cs.ucdavis.edu/~koehl/ |