1. Given the following snippets of code, evaluate the print statements:
(assume python 3.X)
Code:
x=[1,4,3,2]
y=('k',0,(1,5))
z={1,4,5}
s="Text"
w={'a':5, 'b': [1,2,3],'c':x}
for x_elem in x:
print(x_elem, end=",")
print()
for y_elem in y:
print(y_elem, end=",")
print()
for s_elem in s:
print(z_elem, end=",")
print()
for w_elem in w:
print(w_elem, end=",")
(a) How many variables are there in the above code block?
(b) What does the len() function of each variable return?
(c) What is the data types of each of the variables?
(d) What is stored in y[2][1]? y[0][0]?
(e) What are the keys of the dictionary? What are the values?
2. Specification - Write a program that allows the user to chose a movie based on a
specific genre. Fill a dictionary with some of your own examples such that the user will type
in a genre (Horror, Action, Drama, etc), and the program should display a list of movies
for them to choose from, if they type a genre not supported...keep looping until the user
provides a valid type. Have at least 3 genres and 3 examples.
Enter a genre: Suspense
Currently Not Available
Enter a genre: Documentry
Currently Not Available
Enter a genre: Horror
1) Hellraiser
2) The Thing
3) Shining