Quiz 5 - UMBC-CMSC104/General GitHub Wiki
Quiz 5 will continue the tradition of the last two quizzes, having two modules A and B. However, it will be done in Python.
Module A
Name this program module_a.py.
For this module, you are to read in music review data from the user into a dictionary and print it out.
The data must have an band name, a album title, a year published, and a score.
This is the print function you'll need to use:
def print_music_info(music_info):
print "%s - %s (%d): %f" % (music_info['band_name'], music_info['album_title'], music_info['year'], music_info['score'])
You should ask for 3 music reviews. You must print out the information after reading all 3 albums in.
**Extra credit: ** Read in an arbitrary nubmer of music reviews.
Module B
Name this program module_b.py.
You are to read in two numbers and then print off the squares of each number within the range:
Please enter a starting number: 2
Please enter an ending number: 9
2^2 = 4
3^2 = 9
4^2 = 16
5^2 = 25
6^2 = 36
7^2 = 49
8^2 = 64
Exponents are easy in Python by using the ** operator. By saying num1num2, you raise num1 to the num2 power. In other words: 23 = 2 * 2 * 2 = 8. 4**5 = 4 * 4 * 4 * 4 * 4 = 1024. Use this operator for your squares.
**Extra credit: ** Allow the user to enter in a third number for the exponent. Instead of printing off the squares of each number, print of all numbers in the range raised to the new user inputted number.
Submittal
To submit the modules, type:
submit cs104_wilson quiz5 module_a.py module_b.py