Common Jobs

Common Jobs Logo

Python Quiz

1 / 38

1. What is the output of below python code?

def say(message, times=1):

  print(message*times)

say('Hello')

say('World',5)

2 / 38

2. Amongst which of the following is / are the conditional statement in Python code?

3 / 38

3. Which of the following function is used to convert list items into string?

4 / 38

4. How does Python's garbage collection work?

5 / 38

5. Python Dictionary is used to store the data in

6 / 38

6. Which operator is used for floor division?

7 / 38

7. Which is NOT true about recursion?

8 / 38

8. Which of the following is the correct way to define a tuple in Python?

9 / 38

9. Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?

10 / 38

10. Which of the following is used to define a block of code in Python language?

11 / 38

11. Which of the following is a valid variable name in Python?

12 / 38

12. Which of these definitions correctly describes a module?

13 / 38

13. What is the output of print(math.pow(3, 2))?

14 / 38

14. What will be the output of this statement?

i = 0  

while i < 5:  

    print(i)  

    i += 1  

    if i == 3:  

        break  

else:  

    print(0)

15 / 38

15. Which keyword is used to exit from a loop in Python?

16 / 38

16. What will be the output of the following Python code?

x=13

if x>12 or x<15 and x==16:

         print("Given condition matched")

else:

         print("Given condition did not match")

17 / 38

17. What is output of following code

x = 2

y = 10

x * = y * x + 1

18 / 38

18. The variable which is defined outside the function is called

19 / 38

19. What is the output of the following Python code?

import array

a = array.array('i', [1, 2, 3])

del a[1]

print(a)

20 / 38

20. Which function opens a file for reading in Python?

21 / 38

21. What is the correct way to convert a string to lowercase in Python?

22 / 38

22. What is the output of the following code? my_list = [1, 2, 3, 4, 5] print(len(my_list)) 

23 / 38

23. What will be output for the following code?

import numpy as np

a=np.array([1,2,1,5,8])

b=np.array([0,1,5,4,2])

c=a+b

c=c*a

print(c[2])

24 / 38

24. Amongst which of the following is / are needed to open an existing file?

25 / 38

25. What will be the output of the following Python code?

def show(id,name):

    print("Your id is :",id,"and your name is :",name)

show(12,"deepak")

26 / 38

26. Which keyword is used for conditional statements in Python?

27 / 38

27. Which of the following is a valid Python comment?

28 / 38

28. The keyword we used to define a function is

29 / 38

29. What does the with statement in Python do?

30 / 38

30. Amongst which of the following is / are the conditional statement in Python code?

31 / 38

31. Which Python module is used to parse dates in almost any string format?

32 / 38

32. What is the output of below code?

print(2**3 + (2+ 6)**(1 + 1))

33 / 38

33. What is the correct way to access the last element of a list in Python?

34 / 38

34. Which of the following is not the built-in function?

35 / 38

35. Which one of the following is the correct way of calling a function

36 / 38

36. What is the output of 5 // 2?

37 / 38

37. Amongst which of the following is / are true about the while loop?

38 / 38

38. Which exception is raised when dividing by zero in Python?

Your score is

The average score is 47%

0%