NEW
Font size
WorksheetsPython Programming Quiz
Total questions: 20
Worksheet time: 11mins
Who created Python?
James Gosling
Dennis Ritchie
Bjarne Stroustrup
Guido van Rossum
What is the latest version of Python mentioned?
v3.11
v3.10
v3.12
v3.13
What is the purpose of a variable in Python?
To store data
To create functions
To print output
To manage memory
What is the main use of the 'if' statement?
To define functions
To make decisions
To create loops
To store data
What is the purpose of the 'input' function?
To define functions
To create variables
To capture user data
To display output
Which version of Python is not backward-compatible?
Python 0.9.0
Python 1.0
Python 3.0
Python 2.7
Which of the following is a Python library for AI/ML?
Flask
Pygame
TensorFlow
Tkinter
What is the purpose of the 'for' loop?
To iterate over a sequence
To make decisions
To create functions
To store data
What is the main benefit of Python's extensive standard library?
It makes Python slower
It complicates coding
It provides many built-in functions
It is only for advanced users
What is the first step to start coding in Python?
Download Python
Write your first code
Create a variable
Install a game
What is the output of the following Python program?
for i in range(5):
print(i+1, end ='')
01234
00000
12345
5
What is a string in Python?
A letter, number, word, or sentence in quotation marks
A mathematical operation
A conditional statement
A data type
What does the 'print' function do in Python?
It calculates mathematical expressions
It retrieves user input
It displays text or numbers on the screen
It stores data in a variable
What type of value does the variable "user" hold in the example provided?
A list
A string
A boolean
An integer
What are conditional statements in Python and give an example.
Conditional statements in Python are used to execute the same code block regardless of the condition
An example of a conditional statement in Python is 'for' loop
Conditional statements in Python are used to execute different code blocks based on certain conditions. One common conditional statement is the 'if' statement, which executes a block of code only if a specified condition is true. For example: if x > 5: print('x is greater than 5')
A conditional statement in Python is 'while', which executes a block of code only once
Which of these codes is the correct syntax?
Print ("Hello World")
print ("Hello World")
PRINT ("Hello World")
print "Hello World"
How do you declare a variable in Python, as shown in the video?
var x = 5
x = 5
int x = 5
x := 5
What does Python use instead of curly braces {} for code blocks?
Semicolons
Parentheses
Indentation
Brackets
What keyword defines a function in Python?
func
def
function
define
What does the if statement do?
Tests a condition and executes code based on the result
Defines a function
Creates a loop
Declares a variable
