Donata Petrelli

Data Scientist in High Heels

Donata Petrelli

Data Scientist in High Heels

Python Quiz

Python Quiz

1. What is the output of the following code?

from math import sin
x=1
s=sin(x)
print(s)

 
 
 
 

2. How do you define a class in Python?

 
 
 
 

3. What is Tkinter?

 
 
 
 

4. 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()

 
 
 
 

5. What is the output of the following code?

b = [1, 3, 5, 7, 9, 11]
print(b[:2])

 
 
 
 

6. What is the syntax for calling a method of a class?

 
 
 
 

7. 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])

 
 
 
 

8. What variable name is invalid?

 
 
 
 

9. What is the output of the following code?

var= “Wonder Woman”
print(var[3::-1])

 
 
 
 

10. What is the output of the following code?

list1 = [30, 60, 90]
list2 = [30, 60, 90]

print(list1 == list2)
print(list1 is list2)

 
 
 
 

11. What is the output of the following code?

v1 = 1
v2 = 2
v3 = “3”

print(v1 + v2)

 
 
 
 

12. What is Python used for?

 
 
 
 

13. What’s Python?

 
 
 
 

14. Where can I use Python language?

 
 
 
 

15. 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)

 
 
 
 

Question 1 of 15

Scroll to top