NEW
Font size
Worksheets2F-1 | Python Quiz | 14/10/2024
Total questions: 20
Worksheet time: 20mins
What will the following code print? print("Hello", "World", sep="-")
Hello-World
Hello World
Hello- World
Hello -World
Which of these functions is used to get input from the user in Python?
print()
input()
int()
float()
What is the result of 5 // 2 in Python?
2.5
2
3
2.0
What does the end parameter in the print() function do?
Changes the default separator
Ends the program
Specifies what is printed at the end
Adds a new line at the end
Which operator is used for exponentiation in Python?
/
*
**
%
What is the output of print(int(3.7))?
3
4
3.7
Error
What will print("A", "B", "C", sep="*") output?
A*B*C
ABC
A B C
A* B* C
What will int("5.2") result in?
5
5.2
Error
6
Which of the following can be used to convert a string s to a floating-point number?
int(s)
float(s)
str(s)
input(s)
What will be the result of print(10 // 3)?
3.33
3
10
0
What is the output of print("Hello", end="!") followed by print("World")?
Hello!World
Hello World!
Hello! World
HelloWorld!
Which statement will correctly check if a number n is positive in Python?
if n > 0:
if n >= 0:
if n 2: print("Yes") elif 3 > 1: print("Maybe") else: print("No")
What will the output be for print("Hello", end="*") followed by print("Python", sep="*")?
Hello*Python
HelloPython*
Hello*Python*
HelloPython
What will the result of input("Enter a number: ") be if the user enters 5?
5
"5"
int
float
What is the output of print(7 % 3)?
1
2
3
0
Which of these will convert the string "123" to an integer and add 5 to it?
str(123) + 5
int("123") + 5
float("123") + 5
input("123") + 5
Which of the following is the correct way to use elif in an if statement?
if condition: ... else if condition: ...
if condition: ... elif condition: ...
else if condition: ...
if condition: ... elseif condition: ...
What does float("5.67") return?
5
5.67
"5.67"
Error
What will if 4 > 2: print("Yes") elif 3 > 1: print("Maybe") else: print("No") output?
Yes Maybe
Yes
Maybe
No
Which of these expressions will result in False?
5 < 10
3 == 3
4 != 4
2 <= 5
