Topic: Multiplication & Subtraction Precedence
You are building a checkout system for an online store. A customer has a cart worth 200.
You want to apply a $10 discount and then apply a 5% tax (0.05) only to the remaining balance.
An entry-level developer writes the following code:
total = 200 - 10 * 1.05
Problem: This code does not give the correct result because of operator precedence.
What is the actual result Python will calculate, and why is it wrong for this business logic?
Your Answer
Select the best option below.
Review your choice before proceeding.
A logistics company needs to transport 1,025 smart tablets. Each shipping crate can hold exactly 12 tablets. The warehouse manager needs to know how many full crates they can pack.
If you use the variable total_tablets = 1025 and crate_capacity = 12, what is the result of the following Python operation?
full_crates = total_tablets // crate_capacity
Your Answer
Imagine you are programming a digital 24-hour clock. The current time is 22
(10 PM). You want to calculate what time it will be in 5 hours.In programming, we often use the Modulus operator to "wrap around" values. Look at this code:
current_hour = 22 wait_time = 5 new_hour = (current_hour + wait_time) % 24
What is the value of new_hour?
Your Answer
Select the best option below.
Review your choice before proceeding.
In a biology lab, a specific strain of bacteria doubles every hour. You start with a base population of 2 bacteria. To calculate the population after 10 hours, you need to raise the base to the power of the time elapsed.
Which mathematical expression correctly represents this in Python to find the total population?
Your Answer
Select the best option below.
Review your choice before proceeding.
A developer is frustrated because their "Whole Number" variable is suddenly showing a decimal point. They are dividing 100 by 10.
x = 100 y = 10 result = x / y
True or False: Even though 100 is perfectly divisible by 10, the variable result will be stored as a float (10.0) rather than an int (10) because the single slash / operator always returns a decimal in Python.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
You are designing a blog page and you want to give even-numbered posts a gray background and odd-numbered posts a white background.
Which of the following code snippets correctly identifies an even number? (Select all that apply)
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
You are working on a simulation for a space agency. You need to calculate the total number of atoms in a specific volume of gas, resulting in a number with 50 digits.
In many older languages (like C or Java), this would cause an "Overflow Error" or crash the program. What happens in Python when you perform this arithmetic?
Scenario:
atoms = 10**50
Your Answer
Select the best option below.
Review your choice before proceeding.
You are calculating the area of a square-based room. The length of one side is (5 + 3) meters. You write the following code to find the area (Side squared):
area = 5 + 3 ** 2
Python calculates this and gives you the answer 14. However, the correct answer for a side of 8 should be 64.
To fix this, you must add parentheses to ensure the addition happens before the exponentiation. What is the correctly rewritten line of code (only the right side)?
Your Answer
A farmer has 17 apples and wants to give an equal amount to 3 children. He uses Floor Division to find out how many each child gets, and Modulus to find out how many apples are left over for himself.
| Person | Calculation | Result |
|---|---|---|
| Each Child | 17 // 3 | 5 |
| The Farmer | 17 % 3 | ? |
How many apples does the farmer keep?
Your Answer
Select the best option below.
Review your choice before proceeding.
You are reviewing a complex mathematical formula in a financial script. To ensure you calculate it correctly, you need to rank the operators in the order Python will execute them.
Arrange from Highest Priority (Executed First) to Lowest Priority (Executed Last):
Your Answer
Reorder the list below.
You are writing a script to calculate the average speed of a vehicle. In one instance, the time_elapsed variable is 0 because the vehicle hasn't moved yet.
distance = 500 time_elapsed = 0 average_speed = distance / time_elapsed
What is the technical result of this operation in Python?
Your Answer
Select the best option below.
Review your choice before proceeding.
A developer is testing a financial app and notices a strange result. They run the following code:
check = (0.1 + 0.2) == 0.3 print(check)
True or False: The result of this calculation is False because computers represent decimals in binary, leading to tiny precision errors where 0.1 + 0.2 actually equals 0.30000000000000004.
- True or
- False
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
When operators have the same precedence (like / and *), Python uses a rule called associativity to determine the direction of execution.
Consider this expression:
value = 100 / 5 * 2
How does Python associate these operators technically?
Your Answer
Select the best option below.
Review your choice before proceeding.
Floor Division (//) is defined as "the greatest integer less than or equal to the quotient." While this is easy with positive numbers, it behaves differently with negatives.
Look at the following code:
# Standard result is -3.333... result = -10 // 3
What is the technical integer result of this operation?
Your Answer
Most arithmetic operators in Python are Left-to-Right associative. However, Exponentiation (**) is a unique technical exception.
Evaluate this expression:
result = 2 ** 3 ** 2
What is the result, and what does it tell us about how Python reads powers?
Your Answer
Select the best option below.
Review your choice before proceeding.
When you perform arithmetic between two different numeric types, such as an Integer and a Float, Python must technically "promote" one of them to match the other.
score = 10 # int bonus = 0.5 # float total = score + bonus
What is the technical term for this automatic conversion, and what is the resulting data type of total?
Your Answer
Select the best option below.
Review your choice before proceeding.
The Modulus operator (%) behavior with negative numbers can be technically complex. In Python, the sign of the result of a modulo operation always matches the sign of the divisor (the second number).
Look at this calculation:
result = -10 % 3
What is the result?
Your Answer
Select the best option below.
Review your choice before proceeding.
In Python, you can combine an arithmetic operator with the assignment operator (=) to update a variable in place. This is called Augmented Assignment.
If health = 100, write the shorthand version of the code that subtracts 20 from the health variable.
Your Answer
While we usually think of the Modulus operator (%) as an integer-only tool, Python allows it to be used with Floats.
result = 7.5 % 2.5
What is the technical result of this expression?
Your Answer
Select the best option below.
Review your choice before proceeding.
Every time you perform an arithmetic operation in Python, such as x = 10 + 5, Python technically creates a new integer object in memory for the result (15) and assigns the variable x to point to it, rather than changing the original number 10.
True or False: This is because integers in Python are "Immutable" (unchangeable)
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
You are cleaning a dataset. To "normalize" a value, you must follow these steps
- Subtract the Minimum value.
- Divide by the Range (Maximum - Minimum).
- Multiply by 100 to get a percentage.
If you are writing this as a single Python expression: result = (value - min_val) / (max_val - min_val) * 100.
Arrange the operations in the order Python will execute them for this specific expression
Your Answer
Reorder the list below.
A game engine needs to calculate the position of a falling object using the formula:
d=vi⋅t+0.5⋅a⋅t2
In Python: pos = vi * t + 0.5 * a * t ** 2
Arrange the operators in the order Python will execute them to solve this physics equation:
Your Answer
Reorder the list below.
You are calculating the future value of an investment:
Amount=P(1+r)t
In Python: total = principal * (1 + rate) ** time
Rank the execution order of these operations:
Your Answer
Reorder the list below.
To adjust the brightness of a pixel, a script uses this formula: new_pixel = (red + green + blue) // 3 + offset.
Arrange the steps Python takes to calculate the new pixel value:
Your Answer
Reorder the list below.
You are coding a combat system. Which of the following Arithmetic Operators can be used to decrease a player's health variable? (Select all that apply)
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
You have a total number of seconds (e.g., 3675) and you want to convert it into hours and minutes. Which operators are essential for this task? (Select all that apply)
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Security keys are often based on powers of 2. Which of the following Python expressions result in the value 256? (Select all that apply)
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
You are calculating the average of three exam scores: 80, 90, 95. Which of the following code snippets will produce the mathematically correct average of 88.33...? (Select all that apply)
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
You are training an AI model that requires calculating 10100(a Googol).
True or False: Python will automatically convert this number to a "Float" and lose precision because integers cannot be that large.
- True or
- False
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
A store has 53 items and wants to display them in rows of 10.
True or False: If the developer uses rows = 53 / 10, the result will be a float (5.3), which might cause an error if the layout function expects a whole number (integer).
- True or
- False
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Reorder the list below.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Your Answer
Select the best option below.
Review your choice before proceeding.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
Your Answer
Reorder the list below.
Your Answer
Reorder the list below.
Your Answer
Reorder the list below.
Your Answer
Reorder the list below.
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Your Answer
Select all options that apply.
Ensure you have selected all applicable options.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
Your Answer
Determine if the statement above is correct.
Pick the most accurate statement.
