Common Jobs

Common Jobs Logo

Python Quiz

1 / 38

1. 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")

2 / 38

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

3 / 38

3. What will be the output of this statement?

i = 0  

while i < 5:  

    print(i)  

    i += 1  

    if i == 3:  

        break  

else:  

    print(0)

4 / 38

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

5 / 38

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

6 / 38

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

7 / 38

7. Python Dictionary is used to store the data in

8 / 38

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

import array

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

del a[1]

print(a)

9 / 38

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

10 / 38

10. Which of these definitions correctly describes a module?

11 / 38

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

12 / 38

12. What does the with statement in Python do?

13 / 38

13. How does Python's garbage collection work?

14 / 38

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

15 / 38

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

16 / 38

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

17 / 38

17. Which operator is used for floor division?

18 / 38

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

19 / 38

19. What is the output of below code?

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

20 / 38

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

21 / 38

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

22 / 38

22. The keyword we used to define a function is

23 / 38

23. Which is NOT true about recursion?

24 / 38

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

25 / 38

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

26 / 38

26. 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")

27 / 38

27. What is output of following code

x = 2

y = 10

x * = y * x + 1

28 / 38

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

29 / 38

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

30 / 38

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

31 / 38

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

32 / 38

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

33 / 38

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

34 / 38

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

35 / 38

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

36 / 38

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

37 / 38

37. What is the output of below python code?

def say(message, times=1):

  print(message*times)

say('Hello')

say('World',5)

38 / 38

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

Your score is

The average score is 46%

0%