0% found this document useful (0 votes)
4 views3 pages

Beginner Python Guide MCQs

Uploaded by

selvi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Beginner Python Guide MCQs

Uploaded by

selvi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Beginner Python Guide Through MCQs

■ Python Basics
Q1. What is the correct file extension for Python files?
A) .pt
B) .py
C) .pyt
D) .python
■ Answer: B
Q2. Which of the following is the correct way to output "Hello World" in Python?
A) echo("Hello World")
B) print("Hello World")
C) printf("Hello World")
D) cout << "Hello World"
■ Answer: B
Q3. Which of these is a valid variable name in Python?
A) 2value
B) value_2
C) value-2
D) value 2
■ Answer: B

■ Data Types & Variables


Q1. What type of data is this: "123"?
A) Integer
B) Float
C) String
D) Boolean
■ Answer: C
Q2. What is the output of type(10.5)?
A)
B)
C)
D)
■ Answer: B
Q3. Which of the following is a boolean value in Python?
A) TRUE
B) true
C) True
D) "True"
■ Answer: C

■ Control Structures
Q1. Which keyword is used for decision making in Python?
A) for
B) if
C) switch
D) choose
■ Answer: B
Q2. What is the output of this code: if 5 > 2: print("Yes")?
A) No
B) Error
C) Yes
D) 5 > 2
■ Answer: C
Q3. Which keyword is used for loops in Python?
A) repeat
B) do
C) for
D) loop
■ Answer: C

■ Functions & Modules


Q1. How do you define a function in Python?
A) function myFunc():
B) def myFunc():
C) create myFunc():
D) fun myFunc():
■ Answer: B
Q2. What keyword is used to import a module in Python?
A) include
B) load
C) require
D) import
■ Answer: D

■ Lists and Dictionaries


Q1. What is the correct way to create a list in Python?
A) list = (1, 2, 3)
B) list = [1, 2, 3]
C) list = {1, 2, 3}
D) list = <1, 2, 3>
■ Answer: B
Q2. What is the output of len(["a", "b", "c"])?
A) 2
B) 3
C) 4
D) Error
■ Answer: B
Q3. What is a key-value pair used in?
A) List
B) Dictionary
C) Tuple
D) Set
■ Answer: B

■ Errors & Exceptions


Q1. What error will this line throw: print(x) (when x is not defined)?
A) ValueError
B) SyntaxError
C) NameError
D) TypeError
■ Answer: C
Q2. What keyword is used to handle exceptions in Python?
A) catch
B) try
C) check
D) handle
■ Answer: B

You might also like