Recall & Review
beginner
What is the purpose of the
sep parameter in the print() function?The
sep parameter defines the string inserted between multiple values printed. By default, it is a space (' ').Click to reveal answer
beginner
How does the
end parameter affect the print() output?The
end parameter sets what is printed at the end of the output. By default, it is a newline (\n), so the next print starts on a new line.Click to reveal answer
intermediate
What does the
file parameter do in print()?The
file parameter specifies where the output goes. By default, it prints to the screen (standard output), but you can redirect it to a file or other stream.Click to reveal answer
beginner
How can you format a number to show two decimal places using
print()?Use an f-string with format specifier like
f"{number:.2f}". This rounds and shows the number with two decimals.Click to reveal answer
beginner
What is the difference between
print('Hello', end='!') and print('Hello')?The first prints
Hello! without moving to a new line after. The second prints Hello and moves to the next line.Click to reveal answer
What is the default separator between values in
print()?✗ Incorrect
By default,
print() inserts a space between multiple values.Which
print() parameter changes what is printed at the end?✗ Incorrect
The
end parameter sets the string printed after the output, defaulting to a newline.How do you print multiple values without spaces between them?
✗ Incorrect
Setting
sep='' removes spaces between printed values.What does
print(f"{value:.2f}") do?✗ Incorrect
The format specifier
.2f rounds and prints the number with two decimals.How can you print output to a file instead of the screen?
✗ Incorrect
You must open the file and pass the file object to the
file parameter.Explain how the
sep and end parameters change the behavior of the print() function.Think about what appears between and after printed items.
You got /4 concepts.
Describe how to format a floating-point number to two decimal places when printing in Python.
Use Python's modern string formatting.
You got /4 concepts.