Python Quiz 1. What is the output of the following code? list1 = [30, 60, 90] list2 = [30, 60, 90] print(list1 == list2) print(list1 is list2) True False False True True True Two boolean values 2. What is the output of the following code? import numpy import matplotlib.pyplot as plt v=numpy.array([1,2,7,9]) print(‘Vector: ‘ , v) s=numpy.sum(v) print(‘Sum : ‘, s) m=numpy.mean(v) print(‘Mean : ‘ , m) plt.plot(v) plt.show() Vector : [1 2 7 9] Sum : 19 Mean : 4.75 Vector : [1 2 7 9] Sum : 19 Mean : 4.75 And the line chart of values None, with Python it is not possible to draw graphs of points The vector, the sum and the average of the elements of the vector, the chart of the vector of values 3. What is the output of the following code? print(‘Recursive Function’) def recursiveF(n, m): if n==0: print(m) else: recursiveF(n-1, n+m) recursiveF(2, 0) Function runs infinitely and causes a StackOverflowError Recursive Function 3 Recursive Function Syntax Error 4. What variable name is invalid? There are no invalid names, Python accepts any variable name 68MyName My_Name My_Name_68 5. What’s Python? Python is a compiled programming language Python is an interpreted, interactive, high-level programming language but not object-oriented Python is an interpreted, high-level programming language Python is an interpreted, interactive, object-oriented, high-level programming language 6. What is the output of the following code? var= “Wonder Woman” print(var[3::-1]) dnoW Wond Won From fourth to first letter 7. What is Python used for? To develop web applications, software and scripts for data analysis but not for Machine Learning For product design and industrial design To develop web applications and software To develop web applications, software and scripts for data analysis and Machine Learning algorithms 8. What is the output of the following code? from math import sin x=1 s=sin(x) print(s) 0.8414709848078965 None. Python does not do trigonometric calculations sin(1) None, you must add: import math 9. What is Tkinter? A library that allows to create graphical interfaces A comic book character A library for GUI development immediately available in every Python installation A library that allows Web Scraping like Scrapy 10. Where can I use Python language? The code can be run on different platforms as long as it has the Python interpreter installed Smartphone iPhone only Unix, Linux, Windows, DOS, Macintosh, Real Time Systems, OS/2, Android and iOS cell phones The code can be run on different platforms even without the Python interpreter installed 11. What is the syntax for calling a method of a class? Methods are found indented within the class Just use the syntax instance.method() With the syntax instance.method(self) Not possible because the methods are inside the class 12. What is the output of the following code? def max_list(list): my_max = 0 for n in list: if n > my_max: my_max = n print(f”The number is {my_max}”) max_list([10, 5, 20, 8, 19]) The number is 20 The greater of the numbers in the list The number is Syntax Error 13. What is the output of the following code? v1 = 1 v2 = 2 v3 = “3” print(v1 + v2) sum of 1 and 2 Error. Mixed operators between numbers and strings are not supported 3 sequence 12 14. How do you define a class in Python? >>> class Test … pass … It is not possible because it does not support object-oriented programming With the keyword class >>> class Test: … pass … 15. What is the output of the following code? b = [1, 3, 5, 7, 9, 11] print(b[:2]) [1, 3] Slicing on a list [1] [1, 3, 5] Loading … Question 1 of 15