Updated on: February 24, 2024 | 153 Comments
This Quiz is for beginners who are new to Python Programming. This quiz provides Multiple Choice Questions to get familiar with Python. The quiz focuses on testing your basic skills in Python functions, string, operators, functions, set, and lists.
The quiz contains . Solve 10 correct to pass the test.
Read Python Basics to solve this quiz.
Also, Solve Python Basic Exercise for Beginners.
1. A string is immutable in Python? Every time when we modify the string, Python Always create a new String and assign a new string to that variable.
True |
False |
2. What is the output of the following code?
for i in range(10, 15, 1): print( i, end=', ')Hint: Python range function
10, 11, 12, 13, 14, |
10, 11, 12, 13, 14, 15, |
3. What is the Output of the following code?
for x in range(0.5, 5.5, 0.5): print(x)
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5] |
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5] |
The Program executed with errors |
4. What is the output of the following code?
p, q, r = 10, 20 ,30 print(p, q, r)
10 20 |
10 20 30 |
Error: invalid syntax |
5. The operator is used to check if a value exists within an iterable object container such as a list. Evaluate to if it finds a variable in the specified sequence and otherwise.
True |
False |
6. Can we use the “else” block for loop?
for i in range(1, 5): print(i) else: print("this is else block statement" )
No |
Yes |
7. What is the output of the following code?
var= "James Bond" print(var[2::-1])
Jam |
dnoB semaJ |
semaJ |
8. Which operator has higher precedence in the following list?
% (Modulus) |
& (BitWise AND) |
** (Exponent) |
> (Comparison) |
9. What is the output of the following code?
salary = 8000 def printSalary(): salary = 12000 print("Salary:", salary) printSalary() print("Salary:", salary)
Salary: 12000 Salary: 8000 |
Salary: 8000 Salary: 12000 |
The program failed with errors |
10. What is the output of the following code?
sampleSet = {"Jodi", "Eric", "Garry"} sampleSet.add(1, "Vicki") print(sampleSet)
{‘Vicki’, ‘Jodi’, ‘Garry’, ‘Eric’} |
{‘Jodi’, ‘Vicki’, ‘Garry’, ‘Eric’} |
The program executed with error |
11. What is the output of the following code?
def calculate (num1, num2=4): res = num1 * num2 print(res) calculate(5, 6)Hint: functions in Python
20 |
The program executed with errors |
30 |
12. What is the output of the following code?
var1 = 1 var2 = 2 var3 = "3" print(var1 + var2 + var3)
6 |
33 |
123 |
Error. Mixing operators between numbers and strings are not supported |
13. What is the output of the following code?
sampleList = ["Jon", "Kelly", "Jessa"] sampleList.append(2, "Scott") print(sampleList)
The program executed with errors |
[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’] |
[‘Jon’, ‘Kelly’, ‘Jessa’, ‘Scott’] |
[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’] |
14. What is the output of the following code?
str = "pynative" print (str[1:3])
py |
yn |
pyn |
yna |
15. What is the output of the following code?
listOne = [20, 40, 60, 80] listTwo = [20, 40, 60, 80] print(listOne == listTwo) print(listOne is listTwo)
True True |
True False |
False True |
False False |
16. What is the output of the following code?
valueOne = 5 ** 2 valueTwo = 5 ** 3 print(valueOne) print(valueTwo)
10 15 |
25 125 |
Error: invalid syntax |
17. What is the output of the following
x = 36 / 4 * (3 + 2) * 4 + 2 print(x)Hint: Python Operators Precedence
182.0 |
37 |
117 |
The Program executed with errors |
18. What is the output of the following code?
var = "James" * 2 * 3 print(var)
JamesJamesJamesJamesJamesJames |
JamesJamesJamesJamesJames |
Error: invalid syntax |
Filed Under: Python, Python Basics, Python Quizzes
Did you find this page helpful?
Let others know about it. Sharing helps me continue to create free Python resources.
I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners.
Follow me on Twitter.
Related Tutorial Topics:
Python
Python Basics
Python Quizzes
Python Exercises and Quizzes