Difference between revisions of "CSC111 Final Exam 2010"
Line 279: | Line 279: | ||
; Be resourceful. | ; Be resourceful. | ||
:There won't be any extension due to failure of the computer, either beowulf or yours. Python can run on all the various platforms available to you. As long as the computer you are using can access the Web, you can write a program for the final. In case beowulf is down on the last day of exam period, email your program to your instructor (thiebaut@cs.smith.edu) before the 4:00 p.m. deadline. | :There won't be any extension due to failure of the computer, either beowulf or yours. Python can run on all the various platforms available to you. As long as the computer you are using can access the Web, you can write a program for the final. In case beowulf is down on the last day of exam period, email your program to your instructor (thiebaut@cs.smith.edu) before the 4:00 p.m. deadline. | ||
+ | |||
+ | ==Problem #2== | ||
+ | |||
+ | Write a program called final2.py that contains a '''recursive''' function called '''minmax()''' which returns the smallest and largest element of a list. | ||
+ | |||
+ | Example '''main()''' program: | ||
+ | |||
+ | <br /> | ||
+ | <source lang="python"> | ||
+ | |||
+ | def main(): | ||
+ | A = [ 1, 10, 20, 3, 2, -1, -10, 5, 5, 5, 5 ] | ||
+ | low, high = minmax( A ) | ||
+ | print "smallest item =", low, " largest item = ", high | ||
+ | # will print | ||
+ | # smallest item = -10 largest item = 20 | ||
+ | |||
+ | </source> | ||
+ | |||
+ | ===Requirements=== | ||
+ | |||
+ | The function '''minmax()''' must be recursive. | ||
+ | |||
+ | ===Submission=== | ||
+ | |||
+ | Submit your program as follows: | ||
+ | |||
+ | submit final final2.py | ||
+ | |||
+ | |||
; Good luck! | ; Good luck! |
Revision as of 07:11, 30 April 2010