print('Welcome to Python quiz program by Marta Lupica Spagnolo!') print('Please answer the following questions...') print() print('############# 1. QUESTION #############') answer1= input('What are the data structures that are enclosed in round brackets in Python? ') if answer1== 'tuples': print('Right!') else: print('Wrong answer. Please try again!') print() answer1= input('Data structures enclosed in round brackets in Python are also immutable (possible answers are lists, dictionaries, tuples or sets) ') if answer1== 'tuples': print('Right!') else: print('Incorrect answer. Please check on page 132 of Head First Python!') print() print('############# 2. QUESTION #############') print('What elements can be used to comment on functions?') print('1) docstrings') print('2) modules') print('3) dictionaries') answer2= input('Please enter 1, 2 or 3: ') if answer2== '1': print ('Very good!') else: print ('Are you sure? Please take another look at Head First Python!') print() print('############# 3. QUESTION #############') print('What is the result of the following boolean operation? \nbool(-1)') answer3 = input ('Please enter True or False: ') spelling = ['t', 'TRUE', 'true', 'T'] if answer3=='True': print('Great!') elif answer3 in spelling: print('Your answer is correct, but please check your spelling') else: print('Your answer is wrong. The correct answer is True') print() print('############# 4. QUESTION #############') print('What code can you use to import the "add" function from the built-in module "calculation"?') print('a) from add import calculation \nb) from calculation import add \nc) import add') answer4= input('Please enter a, b or c: ') if answer4=='b': print('You are the best!') else: print('Your answer is wrong. The correct answer is "from calculation import add"') print() print('############# 5. QUESTION #############') print('In which order does the interpreter search these three locations when looking for a module?') print ('1) Your interpreter’s site-packages locations \n2) The standard library locations \n3) Your current working directory') answer5= input('Please enter the location numbers, es. 1,2,3, in the correct order: ') if answer5 == ('3,1,2'): print('I am very impressed with your programming skills') else: print('Oh noo!! The right answer is 3,1,2') print() print('############# 6. QUESTION #############') print ('The name Python for the programming language comes from the BBC TV sketch comedy Monty Python') answer6 = input ('Please enter True or False: ') spelling2 = ['t', 'TRUE', 'true', 'T', 'True'] if answer6 in spelling2: print('Yes, it is :)') else: print('Actually, yes, the name comes from Monty Python')