1/16
Flashcards created from Lecture 3 covering Python data types, type conversion, console input/output formatting, and function calls.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What determines how a computer interprets a sequence of binary 1s and 0s stored in memory?
The variable's type specifies how the data in memory should be interpreted.
What two main components define a floating-point number represented in scientific notation, such as 1234.567=1.234567×103?
A Mantissa (the value, assumed to have 1 digit before the decimal point) and an Exponent (the power of 10 that the Mantissa is multiplied by).
What is the preferred method in Python to include both single quotes and double quotes inside a single string literal?
Use the backslash (\) as an escape character before the quotation marks inside the string.

What output is produced when executing the Python print statements shown in the image?
Line 1: Backslash: \1; Line 2: Tab: 2 (with tab spacing); Line 3: Newline:; Line 4: 3; Line 5: Quotes: '4' or "5".
In Python, what data type is produced by standard division 2/2 versus floor division 2//2?
Standard division (2/2) yields a Floating-Point number (1.0), while floor division (2//2) yields an Integer (1).
What is the result of multiplying an integer and a string in the expression 3×"Howdy" in Python?
"HowdyHowdyHowdy"
How is the subtraction operator (-) defined between two string operands in Python?
Subtraction is not defined for strings; attempting to subtract two strings results in an error.
How does Python convert a floating-point number to an integer when using the int() function, such as int(4.9) or int(-1.3)?
The floating-point value is truncated by dropping its fractional portion, yielding 4 for int(4.9) and −1 for int(-1.3).
What is the result of attempting to convert a decimal string directly to an integer using int("2.5") in Python?
It results in an error because int() cannot directly convert a string containing a decimal point.
When evaluating values with bool(), which numeric and string inputs evaluate to False?
The numeric value 0 and the empty string "" evaluate to False; all other values, including "0", evaluate to True.
What are the default separator and line-ending behaviors of the print() function in Python?
By default, print() separates items with a single space and ends the output with a newline character.
How can the sep and end keyword arguments be used in print("Test", 3, 5) to separate items with commas and end with a colon?
By passing sep="," and end=":", resulting in print("Test", 3, 5, sep=",", end=":").
What specifier is used within an f-string to format a floating-point number to exactly 5 decimal places?
:.5f inside curly braces, such as {1/9:.5f}.
Which format specifiers align text to the left, right, and center inside an f-string field?
< for left alignment, > for right alignment, and ^ for center alignment.
What data type does the input() function return in Python?
A string (str).
How does passing a prompt argument into input("Enter your name: ") change where the user types their input?
It prints the prompt text without a trailing newline, allowing the user to type their input directly after the prompt on the same line.
What is the standard syntactic structure for a Python function call?
<function name>(<arguments>)