Due: March 19, 2012 | Points: 100 |
As for all earlier assignments, please put refinements for all your programs into one file called “refinements.txt” or “refinements.pdf”, and error journal entries for all your programs into one file called “errors.txt” or “errors.pdf”.
In the example outputs, what your program outputs is in typewriter font, what the user types is in italicized typewriter font, and the user typing “enter” or “return” is represented by the character “↵”. You don’t need to change the font, use italics, or show the “↵” in your output.
In all programs, simply exit if the user types the end of file character (control-D on most systems).
For example:
Please enter a year: 2012↵and
2012 is a leap year.
Please enter a year: 2013↵
2013 is not a leap year.
Submit: Please turn in your program in the file “leap.py”.
For example:
Enter weight (lb): 199↵and
Enter height (in): 67↵
Your bmi of 31.92 is above the healthy range of 19-25
Enter weight (lb): 160↵and
Enter height (in): 68↵
Your bmi of 24.91 is within the healthy range of 19-25
Enter weight (lb): 120↵
Enter height (in): 72↵
Your bmi of 16.67 is below the healthy range of 19-25
Submit: Please turn in your program in the file “bmi.py”.
For example:
Please enter the first number: 12↵and
Please enter the second number: 15↵
The greatest common divisor of 12 and 15 is 3
Please enter the first number: 16↵
Please enter the second number: 40↵
The greatest common divisor of 16 and 40 is 8
Submit: Please turn in your program in the file “igcd.py”.
Hint: The classic algorithm for computing the GCD, known as Euclid’s Algorithm, goes as follows. Let m and n be variables containing the two numbers. Divide m by n. Save the divisor (that is, n) in m, and save the remainder in n. If n is 0, stop; m contains the GCD. Otherwise, repeat the process, starting with the division of m by n.
ECS 10, Basic Concepts of Computing Winter Quarter 2012 |