1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is the primary function of the print() command in Python?
The print() function is used to display text or variable values to the console or terminal.
What does the comma (,) do in a print() statement?
Using a comma inserts automatic spaces between items and allows for mixing different data types (e.g., strings, booleans, integers) in a single output.
What is the difference between the comma method and the plus (+) operator in Python for output?
The comma method automatically adds spaces between items and can handle multiple data types safely, while the + operator requires manual spacing and only works with strings.
What is the purpose of the sep parameter in the print() function?
The sep parameter specifies a custom character to use as a separator between items being printed, overriding the default space.
What error can occur when using the plus (+) operator for string concatenation?
A TypeError can occur if an attempt is made to concatenate a string with a non-string data type, such as an integer.
When is it necessary to use the int() function in Python?
The int() function is necessary to convert string input from the input() function into an integer form before performing arithmetic operations.
What does the print() function output if variable names are placed inside quotation marks?
If variable names are placed inside quotation marks, Python treats them as literal text rather than variables, resulting in the variable name being displayed instead of its content.
List the four variables defined in Assignment 1 and their data types.
The variables are full_name (string, 'David Carlson'), age (string, '25'), favorite_city (string, 'Paris'), and football (boolean, False).
Describe the relationship between user input and variable assignment in a Python script.
User input captured through input() is assigned to variables, allowing dynamic data to be processed and used within the program.
What are the differences between hard-coded variables and dynamic user inputs in Python?
Hard-coded variables are static values defined directly in the code, while dynamic user inputs are collected at runtime through the input() function, making scripts more flexible and interactive.