Font size
WorksheetsPython Programming Quiz
Total questions: 20
Worksheet time: 3600secs
What is the correct way to print "Hello, World!" in Python?
echo("Hello, World!")
printf("Hello, World!")
print("Hello, World!")
console.log("Hello, World!")
Which symbol is used for comments in Python?
//
#
/** */
What data type is the value 42 in Python?
String
Integer
Float
Boolean
What will this code output? x = 5 y = 3 print(x + y)
Which of the following is a valid variable name in Python?
2ndNumber
first_name
my-name
class
What is the output of this code? print(type(3.14))
What keyword is used to define a function in Python?
Write a Python statement to assign the value 10 to a variable called score.
What is the correct way to create a list of numbers from 1 to 5?
What will be the output of this code? for i in range(3): print(i)
How do you start a while loop in Python? Write the syntax for a while loop that runs while count is less than 5.
What is the output of this code? print("Python"[1])
What does len() function do in Python?
How would you add the number 7 to the end of the list numbers = [1, 2, 3]?
What will the following code print? x = 10 if x > 5: print("Greater") else: print("Smaller or equal")
Which of these is a Python tuple?
[1, 2, 3]
(1, 2, 3)
{1, 2, 3}
What is the output of this code? x = "5" y = 2 print(x * y)
How do you import the math module in Python?
Write a function named greet that takes a name as a parameter and prints "Hello, name!"
What is the difference between == and = in Python?
