Font size
WorksheetsPython Quiz - print + input
Total questions: 25
Worksheet time: 13mins
What is Python used for in programming?
Graphic design
Web development
Scientific research
All of the above
Which of the following is an example of a variable in Python?
"Hello"
10
x
print()
How do you assign a value to a variable in Python?
variable = value
value = variable
assign(variable, value)
None of the above
What does the print() function do in Python?
Perform mathematical operations
Define variables
Capture user input
Display output
Which of the following is a correct way to print the phrase "Hello, World!" in Python?
print("Hello, World!")
print(Hello, World!)
display("Hello, World!")
show "Hello, World!"
How do you capture user input in Python?
scan()
get_input()
input()
user()
What data type is the result of the input() function in Python?
Integer
String
Float
Boolean
How can you convert user input to an integer in Python?
int(input())
input(int)
convert(input())
integer(input())
What is the purpose of the + operator when used with strings in Python?
Concatenation
Subtraction
Division
Multiplication
How do you print the output of a variable named age in Python?
print("age")
output(age)
print(age)
display(age)
What does the # symbol indicate in Python?
Addition
Comment
Trend
Division
What does the input() function return in Python?
Boolean
Integer
Float
String
How do you prompt the user for their name and print a greeting in Python?
print("Hello, " + input())
name = input()
print("Hello, " + name)
name = get_name()
print("Hello, " + name)
greet(input("Hello, "))
Which data type is used for decimal numbers in Python?
float
string
boolean
Integer
What is the purpose of the str() function in Python?
Convert to string
convert to integer
convert to float
convert to boolean
How do you use variables with the print() function to display dynamic messages?
print("Variable")
print(variable)
print("Hello, " + variable)
print("Hello, " variable)
What is the purpose of comments in Python?
Hide code
Explain code
Execute code
Output message
What is the result of the expression 5 + 3 * 2 in Python?
16
11
26
10
What is the correct syntax to declare a variable name and assign the value "John" to it in Python?
variable name = "John"
name := "John"
name = "John"
John = name
What is the result of the following code?
(a)
What is the correct way to declare a variable count and assign the value 5 to it in Python?
count:=5
int count = 5
5 = count
count = 5
What is the expected output of the Python code?
Hello, input!
Hello, name!
Depends on the users input
Enter your name: Hello, !
What will happen if the code is executed?
It will print the user's age.
It will cause an error.
It will prompt the user to enter their age.
It will print "Next year, you will be 1."
What does the above code snippet do?
Prints "Python is technology!"
Prints "Python is awesome!"
Prints "Python is awesome!technology"
Causes an error
What is the output of the code?
The sum of the entered numbers
An error will occur
The product of the entered numbers
The difference between the entered numbers
