NEW
Font size
WorksheetsPython Basics
Total questions: 10
Worksheet time: 6mins
Which of the following is a valid variable name in Python?
A. 1variable
B. my-variable
C. _variablename
D. variable name
How do you print "Hello, World!" to the console in Python 3?
A. print("Hello, World!")
B. print "Hello, World!"
C. echo "Hello, World!"
D. System.out.println("Hello, World!")
What is the result of the expression 5 + 3 * 2?
A. 10
B. 16
C. 11
D. 26
Which symbol is used for single-line comments in Python?
//
--
#
/*
How do you declare a variable in Python?
A. var my_variable
B. my_variable =
C. variable my_variable
D. my_variable = 10
What is the output of print(5 + 2) in Python?
A. 52
B. 7
C. "5 + 2"
D. Error
Which of the following is a valid string in Python?
A. 'Hello, World!"
B. "Hello, World!"
C. Hello, World!
D. "Hello, World!'
Which operator is used for exponentiation in Python?
A. ^
B. **
C. ^
D. %
How do you check if two variables have the same value in Python?
A. x is y
B. x == y
C. x = y
D. x != y
What is the purpose of the if statement in Python?
A. To declare a variable
B. To define a function
C. To conditionally execute code
D. To loop through a sequence
