Module 3 Quiz: Input, Output & String Formatting
12 questions • Select the best answer for each question
Question 1
What is the output of print("a", "b", "c", sep="-")?
Correct: c) The
sep parameter replaces the default space separator with "-".Question 2
What data type does input() always return?
Correct: b)
input() always returns a string, even if the user types a number. You must convert it with int() or float() if you need a number.Question 3
Which code correctly gets an integer from the user?
Correct: d)
input() gets the string from the user, then int() wrapping it converts that string to an integer.Question 4
What does the end parameter in print() control?
Correct: a) By default,
print() adds \n (newline) at the end. The end parameter lets you change this to a space, empty string, or anything else.Question 5
What does f"{3.14159:.2f}" produce?
Correct: c) The
:.2f format specifier rounds to 2 decimal places, producing 3.14.Question 6
What is the output of this code?
name = "Alice"
print(f"Hello, {name}!")
print(f"Hello, {name}!")
Correct: b) The
f prefix makes it an f-string, so {name} is replaced with the value of the variable name.Question 7
What does f"{0.75:.1%}" produce?
Correct: d) The
% format specifier multiplies by 100 and adds a percent sign. .1 gives 1 decimal place, producing 75.0%.Question 8
What is the output of print("Hi", end="") ; print("there")?
Correct: a)
end="" removes the newline after "Hi", so the next print continues on the same line with no space, producing Hithere.Question 9
What does f"{1000000:,}" produce?
Correct: c) The
:, format specifier adds comma separators for thousands.Question 10
What happens when you run: num = input("Number: ") and the user types 42?
Correct: b)
input() always returns a string, regardless of what the user types. The value is "42" (a string), not the number 42.Question 11
What is the difference between "Hello, " + name and print("Hello,", name)?
Correct: d) Concatenation with
+ joins strings exactly as-is (no automatic space). print() with commas automatically adds a space between values.Question 12
Which approach is generally recommended for formatting strings in modern Python?
Correct: c) f-strings (introduced in Python 3.6) are the modern, preferred approach. They are more readable and more concise than other methods.