1/28
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the primary purpose of the % operator in Python?
It calculates the remainder after division, making it useful for tasks such as checking divisibility and identifying repeating patterns
What is the primary purpose of Python’s print() function
It displays information or output to the screen
Why is assigning the result of input() to a variable useful?
It allows the program to store and use the user’s response later in the program
An online banking system first checks whether a user has successfully logged in. Only if the login is successful should the program check whether the user has sufficient funds for a withdrawal. What’s the best approach to represent this logic?
Use a nested if: if the outer condition checks successful login, while the inner condition checks whether sufficient funds are available
A programmer wants the program to ask the user for their first name and the last name. Each response should be stored separately. Which design best satisfies the requirement?
Use two input() statements and assign each returned value to a different variable
Which statement best explains why choosing an appropriate data type for variable is important>
The data type determines how Python interprets and operates on the value, helping the program perform appropriate operations
What is the best statement that explains what the input() function does in Python?
It displays an optional prompt, waits for the user to enter data, and returns the entered value as a string
What best distinguishes executable code from a comment?
Executable code can instruct Python to perform an action, while a comment is ignored by Python during normal execution
Why is if-elif-else generally appropriate for classifying a value into several possible categories?
It allows Python to evaluate multiple conditions in sequence and execute the appropriate brach when a matching condition is found
When a value matches a case in a match-case statement, what normally happens?
The statements associated with that matching case are executed, and the remaining cases are not considered for that match statement
A programmer is deciding whether to add comments to a simple Python program. What principle represents the best programming practice?
Comments should be meaningful and explain code when additional clarification is useful
Why does a programmer often need to convert the result of input() before performing mathematical operations?
Because input() returns user-entered data as a string even when the user enter digits
Why is the order of condition important in an if-elif-else structure?
Python evaluates the condition from top to bottom and executes the first matching branch so ordered conditions can prevent more specific conditions from being reached
What statement best explain when a programmer should use a simple if-statement?
A simple if-statement is appropriate when an action should occur only when a specified condition evaluates to True
A programmer is creating a student registration system and needs to store a student’s full name, such as “RJ Lauraya”. Which data type should be selected?
str. because a person’s name is textual information rather than a numerical quantity
A student creates a program that asks for the user’s age and then adds 5 to it. The student writes age = input(“Enter your age":”) and later attempts to calculate age + 5. The program produces an error. What is the solution?
Convert the value returned by input () to an integer before performing arithmetic
A command line application accepts the commands “add”, “delete”, “view”, and “exit”. The programmer wants each command to trigger a different operation. What design is most appropriate?
Use match-case to compare the command against the expected string values
A student wants to temporarily prevent a debugging message form appearing without deleting the code because it may be needed later. What should the student do?
Place # before the print() statement
What explains the ** operator?
It performs exponentiation, raising the value on the left to the power specified by the valie on the right
A student is creating a program that asks a user for their name and then displays a personalized greeting. Which approach correctly allows the user to enter their name>
Use input() to receive the user’s name and stores the returned value in variable
A student is calculating the average score of four examination. The total score is 340, and the program needs to divide the total by 4 to obtain the average. What operator is the appropriate for this?
The / operator because ordinary produces the average value, including a possible decimal component
A web application receives a user’s role as “admin”, “teacher”, or “guest”. Each role has different permission. What approach best communicates the relationship between the role and the corresponding behavior>
Use match-case to associate each role with its appropriate action
What is the purpose of case _: in Python match-case statement?
It acts as a catch-all pattern for values that were not matched by earlier cases
What statement best describes a Python variable>
A variable is a name that refers to a value, allowing a program to store and work with data.
A school program asks students to enter their student number.. The student number may contain letters and numbers, such as 2026-ABC-15. What approach is appropriate?
Store the value returned by input() as a string because the student number is an identifier rather than a value used for arithmetic