Python for Fun

A vibrant illustration of a computer programmer joyfully coding in Python, with colorful Python logos and snippets of code in the background.

Python for Fun Quiz

Test your knowledge of Python programming in a fun and interactive way! This quiz covers various topics, including data types, control structures, and function usage.

  • Multiple-choice questions
  • Engaging and educational
  • Suitable for learners of all levels
15 Questions4 MinutesCreated by CodingCat42
Can we use "else" block for "for" loop?
 
For Example,
 
 
for I in range(1, 5):
    print(i)
else:
    print("this is else block statement" )
Yes
No
What is the output of the following code?
 
var= "James Bond"
print(var[2::-1])
Jam
Dno
Maj
DnoBsemaJ
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
What is the output of the following?
 
 
x = 36 / 4 * (3 +  2) * 4 + 2
print(x)
182.0
37
117
The Program executed with errors
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’]
The in operator is used to check if a value exists within an iterable object container such as a list. Evaluate to True if it finds a variable in the specified sequence and False otherwise.
True
False
What is the output of the following code?
 
 
 
def calculate (num1, num2=4):
  res = num1 * num2
  print(res)

calculate(5, 6)
20
The program executed with errors
30
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
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
What is the output of the following code?
 
 
var = "James" * 2  * 3
print(var)
JamesJamesJamesJamesJamesJames
JamesJamesJamesJamesJames
Error: invalid syntax
Which operator has higher precedence in the following list?
 
 
% (Modulus)
& (BitWise AND)
** (Exponent)
> (Comparison)
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
A string is immutable in Python?
True
False
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
What is the output of the following code?
 
 
str = "pynative"
print (str[1:3])
Py
Yn
Pyn
Yna
{"name":"Python for Fun", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your knowledge of Python programming in a fun and interactive way! This quiz covers various topics, including data types, control structures, and function usage.Multiple-choice questionsEngaging and educationalSuitable for learners of all levels","img":"https://cdn.poll-maker.com/104-5101057/img-p3rrpvhsjmuvq5ykjitkdayf.jpg"}
Powered by: Quiz Maker