WorksheetsPython Programming Quiz
Total questions: 25
Worksheet time: 13mins
Which of the following is a valid Python variable name?
2variable
_variable
variable-name
for
What will be the output of the following code?
x = 5
X = 10
print(x, X)
5 10
10 5
Error
55
Which of the following is NOT a valid identifier in Python?
my_var
class
myVar123
var_2x
What is the correct way to define a variable in Python?
int x = 10;
x := 10
x = 10
10 = x
Which of the following is a Python keyword?
input
break
none
What is the correct syntax to print "Hello, Python!" in Python 3?
print "Hello, Python!"
print(Hello, Python!)
print("Hello, Python!")
echo "Hello, Python!"
What will be the output of the following code?
print("Python", "is", "fun", sep="-")
Python-is-fun
Python is fun
Python-is-fun-
Pythonisfun
What does the end parameter in the print() function do?
Specifies the ending character of the output
Stops the execution
Adds a new line after the output
Terminates the program
What is the default separator in Python's print() function?
, (comma)
" " (space)
\n (new line)
. (dot)
What is the output of this code?
x = "10"
y = "20"
print(x + y)
30
1020
Error
10 20
What error will the following code produce?
x = 5
y = "Hello"
print(x + y)
SyntaxError
TypeError
ValueError
No error
What error will occur in this program?
for i in range(5)
print(i)
SyntaxError
IndentationError
NameError
TypeError
What error will occur here?
def myFunction()
print("Hello")
SyntaxError
IndentationError
RuntimeError
TypeError
What will the following code print?
print("5" * 3)
555
15
Error
5 5 5
What is the error in this program?
print "Hello, World!"
SyntaxError
IndentationError
Logical Error
No Error
Which function is used to take user input in Python?
scan()
input()
read()
cin>>
What is the output of this code?
x = input("Enter a number: ")
print(type(x))
<class 'int'>
<class 'str'>
<class 'float'>
<class 'input'>
What is the output of this code?
print(3 * "Hello ")
Hello Hello Hello
HelloHelloHello
3Hello
Error
What does int("10") + int("20") return?
20
10
None
What does len("Python") return?
5
4
3
Which operator is used for exponentiation in Python?
^
**
&
*
How many keywords are there in Python 3.10?
33
35
36
38
Which of the following is NOT a Python keyword?
yield
global
define
nonlocal
Which keyword is used to define a function in Python?
function
define
def
fun
Which of the following is a looping keyword in Python?
loop
repeat
for
do
