Python MCQ Quiz Hub

Python MCQs

Choose a topic to test your knowledge and improve your Python skills

What is the maximum possible length of an identifier?





✅ Correct Answer: 4

Who developed the Python language?





✅ Correct Answer: 2

In which year was the Python language developed?





✅ Correct Answer: 4

In which language is Python written?





✅ Correct Answer: 3

Which one of the following is the correct extension of the Python file?





✅ Correct Answer: 1

 In which year was the Python 3.0 version developed?





✅ Correct Answer: 1

What do we use to define a block of code in Python language?





✅ Correct Answer: 3

Which character is used in Python to make a single line comment?





✅ Correct Answer: 3

Which of the following statements is correct regarding the object-oriented programming concept in Python?





✅ Correct Answer: 2

Which of the following statements is correct in this python code? class Name: def __init__(javatpoint): javajavatpoint = java name1=Name("ABC") name2=name1





✅ Correct Answer: 2

What is the method inside the class in python language?





✅ Correct Answer: 2

Which of the following declarations is incorrect?





✅ Correct Answer: 4

Why does the name of local variables start with an underscore discouraged?





✅ Correct Answer: 3

Which of the following is not a keyword in Python language?





✅ Correct Answer: 1

Which of the following statements is correct for variable names in Python language?





✅ Correct Answer: 2

Which of the following declarations is incorrect in python language?





✅ Correct Answer: 2

Which of the following words cannot be a variable in python language?





✅ Correct Answer: 3

Which of the following operators is the correct option for power(ab)?





✅ Correct Answer: 2

Which of the following precedence order is correct in Python?





✅ Correct Answer: 1

Which one of the following has the same precedence level?





✅ Correct Answer: 2

 Which one of the following has the highest precedence in the expression?





✅ Correct Answer: 4

Which of the following functions is a built-in function in python language?





✅ Correct Answer: 2

Study the following function:round(4.576) What will be the output of this function?





✅ Correct Answer: 4

Which of the following is correctly evaluated for this function? pow(x,y,z)





✅ Correct Answer: 3

Study the following function: all([2,4,0,6]) What will be the output of this function?





✅ Correct Answer: 1

Study the following program: x = 1 while True: if x % 5 = = 0: break print(x) x + = 1 What will be the output of this code?





✅ Correct Answer: 1

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





✅ Correct Answer: 1

Study the following code: x = ['XX', 'YY'] for i in a: i.lower() print(a) What will be the output of this program?





✅ Correct Answer: 1

Study the following function: import math abs(math.sqrt(36)) What will be the output of this code?





✅ Correct Answer: 4

Study the following function:any([5>8, 6>3, 3>1]) What will be the output of this code?





✅ Correct Answer: 2

Study the following statement: >>>"a"+"bc" What will be the output of this statement?





✅ Correct Answer: 2

Study the following code: >>>"javatpoint"[5:] What will be the output of this code?





✅ Correct Answer: 3

The output to execute string.ascii_letters can also be obtained from:?





✅ Correct Answer: 4

Study the following statements: >>> str1 = "javat" >>> str2 = ":" >>> str3 = "point" >>> str1[-1:] What will be the output of this statement?





✅ Correct Answer: 1

Study the following statements: >>> print(0xA + 0xB + 0xC) What will be the output of this statement?





✅ Correct Answer: 1

Study the following statements: >>> print(ord('h') - ord('z')) What will be the output of this statement?





✅ Correct Answer: 2

Study the following program: x = ['xy', 'yz'] for i in a: i.upper() print(a) Which of the following is correct output of this program?





✅ Correct Answer: 1

Study the following program: i = 1: while True: if i%3 == 0: break print(i) Which of the following is the correct output of this program?





✅ Correct Answer: 4

Study the following program: a = 1 while True: if a % 7 = = 0: break print(a) a += 1 Which of the following is correct output of this program?





✅ Correct Answer: 2

Study the following program: i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) What will be the output of this statement?





✅ Correct Answer: 3

Which keyword is use for function?





✅ Correct Answer: 3

Which of the following items are present in the function header?





✅ Correct Answer: 4

What is called when a function is defined inside a class?





✅ Correct Answer: 3

If return statement is not used inside the function, the function will return:





✅ Correct Answer: 1

What is a recursive function?





✅ Correct Answer: 2

Which of the following is the use of id() function in python?





✅ Correct Answer: 2

Which of the following function headers is correct?





✅ Correct Answer: 3

In which part of memory does the system stores the parameter and local variables of funtion call?





✅ Correct Answer: 2

How is a function declared in Python?





✅ Correct Answer: 3

Which one of the following is the correct way of calling a function?





✅ Correct Answer: 3

Which operator is used in Python to import modules from packages?





✅ Correct Answer: 1

Where is function defined?





✅ Correct Answer: 4

Lambda is a function in python?





✅ Correct Answer: 1

What is a variable defined outside a function referred to as?





✅ Correct Answer: 2

What is the output of the following program?z = lambda x : x * x print(z(6))





✅ Correct Answer: 2

What is the output of the following program? print(chr(ord(chr(97))))





✅ Correct Answer: 1

Which one of the following is incorrect?





✅ Correct Answer: 2