![]() ![]() |
![]() | Patrice Koehl |
Introduction to Computers: Fall 2013Lab8: Programming with Python (II)This is your second 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. Remember to test your program! Problem 1: Splicing strings Write a Python program that reads from standard input a long string S and outputs four new strings:
Problem 2: Encryption Write a Python program that reads in a string S and an integer number N and encripts S based on N The process of encryption is
Note that it is important that the two steps are performed in that order. We will assume that N is smaller than the length of the string S. Examples of encryption:
Problem 3: Computing change Write a Python program that reads in a change amount (assumed to be between 0 and 99 cents) and computes the minimal number of coins needed to tend this change. For example, if the change amounts is 82 cents, the output of your program should look like: Total change: 82 cents 3 quarter(s) 0 dime(s) 1 nickel(s) 2 cent(s) 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 50. 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/ |