Python Print Function MCQS

Q. Which function displays output in Python 3?

A
echo()
B
print()
C
printf()
D
console.log()
Solution:

print() is the built-in output function in Python 3.

Q. What is the output of print("A", "B")?

A
AB
B
A B
C
A,B
D
A\nB
Solution:

The default separator (sep) is a single space.

Q. What is the default value of the end parameter in print()?

A
A space
B
An empty string
C
A newline "\n"
D
A tab
Solution:

print() ends each call with a newline unless you change end.

Q. What does print("x", "y", sep="-") output?

A
x y
B
x-y
C
x - y
D
xy-
Solution:

sep replaces the default space between values.

Q. What is the output of x = 5; print(f"{x * 2}")?

A
{x * 2}
B
x * 2
C
10
D
52
Solution:

Expressions inside an f-string’s braces are evaluated.

Q. Which line raises a TypeError?

A
print("Age", 5)
B
print("Age " + str(5))
C
Print("Age " + 5)
D
print(f"Age {5}")
Solution:

The + operator cannot join a str and an int.

Q. How do you print 1 2 3 on one line using a loop?

A
print(i, sep=" ")
B
print(i, end=" ")
C
print(i, line=False)
D
print(i, newline=0)
Solution:

end=” ” replaces the newline with a space.

Q. What does print(f"{3.14159:.2f}") output?

A
3.14159
B
3.14
C
3.1
D
3.15
Solution:

2f formats a float with exactly two decimals.

Q. What is the return value of print()?

A
The printed string
B
True
C
None
Solution:

print() writes to output and returns None.

Entri PDF Icon

Get Question Bank

Strengthen Your Practice with our comprehensive question bank.