p.2
Concatenation vs. Comma Separation in Output
What is concatenation in the context of printing output?
Joining pieces of output using the + operator.
p.1
Variables and Data Storage
What is a variable?
A container that holds information.
p.4
Formatting Output with Format Specifiers
What does the format specifier %s represent?
It is a placeholder for a string.
p.1
Type Conversion for Mathematical Operations
What must you do to perform mathematical operations on user input?
Convert the input to a numerical type (like an integer or a float).
p.3
Formatting Output with Format Specifiers
What formatting issue arises with monetary amounts in output?
Monetary amounts should be expressed in two decimal places.
p.2
Type Conversion for Mathematical Operations
What is a more concise way to get user input as an integer?
number = int(input('How many cheeseburgers would you like?'))
p.4
Formatting Output with Format Specifiers
What does the percentage sign (%) signify in Python formatting?
It signals that what comes next is a format specifier.
p.4
Formatting Output with Format Specifiers
What happens if the number exceeds the length of the numeric expression?
Spaces will be added to the output.
p.4
Formatting Output with Format Specifiers
How do you specify decimal precision for a float in Python?
Using a decimal number like %0.2f for two decimal places.
p.3
Concatenation vs. Comma Separation in Output
What must be added deliberately when using concatenation?
Spaces to achieve the desired spacing.
p.2
Output Functions in Python
What is the output of the following code: print('Hello,' + name + '!')?
It prints a greeting followed by the user's name and an exclamation mark.
p.2
Type Conversion for Mathematical Operations
How does the teacher convert the input string to an integer?
By using the int() function on the input.
p.4
Formatting Output with Format Specifiers
What is a format specifier?
An alphabetic character (and sometimes a number) that serves as a placeholder for data.
p.4
Formatting Output with Format Specifiers
What does the initial 0 in %0.2f indicate?
It indicates no padding (blank spaces) preceding the number.
What happens if you input a number like 27 in Python?
It is treated as a string.
p.3
Error Handling with Data Types
What is a common error when concatenating different data types?
You cannot concatenate a string with an integer or float directly.
p.4
Formatting Output with Format Specifiers
What does a negative sign in a format specifier indicate?
The string will be left justified.
p.3
Concatenation vs. Comma Separation in Output
What happens when using commas in the print function?
A space is added automatically after each section.
p.2
Syntax and Structure of Print Statements
How do you include a variable in a print statement?
By separating the variable with commas from string literals.
What is an example of collecting user input in Python?
name = input('Hello! What is your name?')
p.1
Type Conversion for Mathematical Operations
Why is it important to convert user input to a numerical type?
To perform mathematical operations.
p.3
Type Conversion for Mathematical Operations
How can you successfully concatenate an integer or float with a string in Python?
By converting the integer or float to a string using str().