Modular Arithmetic in Python
- 51Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
51 questions
- 1Modular arithmetic uses an operation that returns the_____left after division.
Hint
Think about what remains when you subtract the divisor's full groups from the dividend.
Answer
remainder
Explanation
The modulo operation returns the remainder after division.
- 2In the expression a modulo b, the number b is the_____.
Hint
This value determines the range of outputs for the operation.
Answer
modulus
Explanation
The content identifies b as the modulus, which sets the range of outputs.
- 3In the division setup described, the number being divided, represented by a, is the_____.
Hint
It is the number that gets divided by another number.
Answer
dividend
Explanation
The dividend is the number being divided.
- 4In the division setup described, the number that divides the dividend, represented by b, is the_____.
Hint
It is the number that goes into the dividend.
Answer
divisor
Explanation
The divisor is the number by which the dividend is divided.
- 5The quotient q represents the number of times the_____goes into the dividend.
Hint
It is the number used to divide the dividend.
Answer
divisor
Explanation
The quotient counts how many times the divisor can go into the dividend.
- 6The quotient and remainder together describe division through the relationship a=bq+r, where r is the_____.
Hint
It represents the leftover part after counting full groups.
Answer
remainder
Explanation
In this relationship, the dividend equals the divisor times the quotient plus the remainder.
- 7If the divisor goes evenly into the dividend, the_____is zero.
Hint
There is nothing left over after forming complete groups.
Answer
remainder
Explanation
Exact division leaves no leftover amount, so the remainder is zero.
- 8For a positive modulus, the modulus helps set the_____of possible modulo outputs.
Hint
It describes the set of values that the results can occupy.
Answer
range
Explanation
The modulus sets the range of outputs for the modulo operation.
- 9In Python, the built-in modulo expression is written using the_____symbol.
Hint
It is also called the percent symbol.
Answer
percentage sign
Explanation
Python uses the percentage sign, written as
%, for its built-in modulo expression. - 10Python's built-in modulo expression works with integers and_____numbers.
Hint
These numbers can include a fractional part.
Answer
floating
Explanation
The modulo expression works on both integers and floating numbers.
- 11The examples in the lesson focus on_____to keep the calculations simple.
Hint
These are whole numbers, including negative whole numbers.
Answer
integers
Explanation
Although Python's modulo expression also works with floating numbers, the lesson focuses on integers for simplicity.
- 12Besides the built-in_____
%expression, Python can use functions such asto conduct modulo operations.Hint
This function name begins with the letter f.
Answer
fmod
Explanation
The lesson mentions
fmodas another function that can conduct modulo operations. - 13When 6 is divided by 2, the modulo result is_____.
Hint
The divisor fits an exact number of times, with nothing left over.
Answer
0
Explanation
Since 2 goes into 6 three times exactly, the remainder is 0.
- 14In the calculation 6 modulo 2, the quotient is_____.
Hint
Count how many groups of two fit into six.
Answer
3
Explanation
The divisor 2 goes into the dividend 6 three times.
- 15When 5 is divided by 2, the modulo result is_____.
Hint
After removing two complete groups of two, consider what is left.
Answer
1
Explanation
Two groups of 2 make 4, leaving a remainder of 1 from 5.
- 16In the calculation 5 modulo 2, the quotient is_____.
Hint
Count the complete groups of two that fit into five.
Answer
2
Explanation
The divisor 2 fits into 5 twice, with 1 left over.
- 17Floor division returns the_____rather than the remainder.
Hint
It tells how many whole groups of the divisor fit into the dividend.
Answer
quotient
Explanation
Floor division returns the quotient, not the leftover amount.
- 18For positive integers, floor division gives the_____number of times the divisor goes into the dividend.
Hint
It excludes any fractional part of the division result.
Answer
whole
Explanation
The lesson describes floor division as returning the whole-number quotient.
- 19For 5 floor-divided by 2, the quotient used in the remainder calculation is_____.
Hint
It is the number of complete groups of two in five.
Answer
2
Explanation
Floor division gives a quotient of 2 for 5 divided by 2.
- 20For 5 modulo 2, multiplying the floor-division quotient by the modulus gives_____.
Hint
Use the quotient 2 and multiply it by the modulus 2.
Answer
4
Explanation
The quotient is 2, and 2 multiplied by the modulus 2 gives 4.
- 21To calculate the remainder from the dividend and the product of the quotient and modulus, subtract that product from the_____.
Hint
This is the original number being divided.
Answer
dividend
Explanation
For 5 modulo 2, subtract 4 from the dividend 5 to obtain the remainder 1.
- 22A from-scratch modulo function can calculate the remainder as a−(a//b)×b, using floor division to find the_____.
Hint
This value counts the complete groups that fit into the dividend.
Answer
quotient
Explanation
The expression first uses floor division to find the quotient, multiplies it by the modulus, and subtracts that product from the dividend.
- 23In the from-scratch function, the name_____
modis used for thein the modulo operation.Hint
It is the value that the dividend is divided by.
Answer
modulus
Explanation
The function's
modinput represents the modulus used to calculate the remainder. - 24The lesson tests the custom modulo function using integers from negative 10 up to, but not including,_____.
Hint
The upper endpoint of this range is excluded.
Answer
10
Explanation
The tested range starts at negative 10 and ends before 10, so its largest included integer is 9.
- 25The custom function is checked by comparing its results with Python's built-in_____operation.
Hint
This is the operation represented by the
%symbol.Answer
modulo
Explanation
The test checks whether the custom function agrees with Python's built-in modulo operation.
- 26In military time, the hour cycles from 0000 through_____before wrapping around.
Hint
This is the final hour shown before midnight.
Answer
2300
Explanation
The military-time clock runs from 0000 to 2300 and then wraps to 0000.
- 27The modulus used to wrap the clock's hour back to the start of a day is_____.
Hint
It is the number of hours in a full day.
Answer
24
Explanation
The clock uses modulo 24 so that hours wrap around after a full day.
- 28When an hour calculation reaches 24, the clock wraps to hour_____rather than showing 2400.
Hint
This is the first hour in the clock's cycle.
Answer
0
Explanation
Applying modulo 24 to 24 produces 0, so the clock starts again at hour zero.
- 29To project a clock time forward or backward, the function adds the hour offset to the current hour and applies modulo_____.
Hint
Use the clock's full-cycle length as the modulus.
Answer
24
Explanation
The updated hour is calculated by adding the offset to the current hour and taking the result modulo 24.
- 30A positive hour offset can project the clock to a_____time.
Hint
It moves forward from the current hour.
Answer
future
Explanation
Adding a positive number of hours projects the clock forward in time.
- 31A negative hour offset can be used to calculate a_____time.
Hint
It moves backward from the current hour.
Answer
previous
Explanation
Using a negative offset allows the function to calculate an earlier time.
- 32If the current time is 2320 and the clock advances one hour, the wrapped military time is_____.
Hint
The hour wraps to zero, while the minutes remain unchanged.
Answer
0020
Explanation
Adding one to hour 23 wraps the hour to 0 under modulo 24, and the minutes stay at 20.
- 33The clock function's default hour offset is_____.
Hint
With this setting, no hours are added or subtracted.
Answer
0
Explanation
A default offset of 0 makes the function display the current hour.
- 34The clock function changes the hour while leaving the current_____unchanged.
Hint
This is the smaller time unit that the function does not increment.
Answer
minutes
Explanation
The function adjusts the hour offset but does not change the minutes.
- 35The clock function described in the lesson displays its result using_____rather than returning a value for further use.
Hint
This action writes output to the screen.
Answer
print
Explanation
The lesson's clock function prints the formatted time and does not return a value.
- 36The clock obtains the current date and time using Python's_____functionality.
Hint
Its name combines the words for a date and a time.
Answer
datetime
Explanation
The function uses
datetimeto obtain the current date and time. - 37The clock uses the Python package_____to specify a time zone.
Hint
The package name begins with the letters p and y.
Answer
pytz
Explanation
The function uses
pytzto select the time zone for the requested clock time. - 38The clock function's default time zone in the lesson is_____.
Hint
It is the time zone used by default in the example.
Answer
eastern standard time
Explanation
The function sets eastern standard time as its default time zone.
- 39Without a specified time zone, the time retrieval described in the lesson returns_____time.
Hint
This is a globally standardized time reference.
Answer
universal
Explanation
The lesson says that without a specified time zone, the time would be returned as universal time.
- 40To get the current time for Addis Ababa, the function's time-zone setting should be_____.
Hint
Use the location named in the example as the selected time zone.
Answer
Addis Ababa
Explanation
Setting the time zone to Addis Ababa lets the function display the current time there.
- 41The time-zone listing function mentioned in the lesson returns a_____of available time zones.
Hint
It is an ordered collection of entries.
Answer
list
Explanation
The
all time zonesfunction is described as returning a list of time zones. - 42When the minute value has only one digit, a leading_____is added for military-time formatting.
Hint
This keeps the minute field two digits long.
Answer
0
Explanation
A leading zero is added to minutes below 10, such as formatting 9 as 09.
- 43When the updated hour has only one digit, a leading_____is added to the hour string.
Hint
The clock uses two digits for its hour field.
Answer
0
Explanation
A leading zero ensures that hours from 0 through 9 are displayed with two digits.
- 44The clock converts the hour and minute values to_____before formatting them for display.
Hint
These are text representations of the numeric values.
Answer
strings
Explanation
The function converts the numbers to strings so it can add leading zeros and display them together.
- 45In the Diffie-Hellman key exchange, modular arithmetic helps two parties securely exchange cryptographic_____over a public channel.
Hint
These are the items used by cryptographic systems to protect information.
Answer
keys
Explanation
Diffie-Hellman allows two parties to securely exchange cryptographic keys over a public channel.
- 46The Diffie-Hellman key exchange is an application of modular arithmetic in_____.
Hint
This field focuses on securing information and communications.
Answer
cryptography
Explanation
The lesson identifies Diffie-Hellman as a cryptographic application of modular arithmetic.
- 47A UPC or barcode helps grocery stores track_____in a store.
Hint
These are the products being sold, such as cereal boxes and soup cans.
Answer
items
Explanation
UPC codes and barcodes help stores track the items they carry.
- 48The UPC described in the lesson is made up of_____digits.
Hint
This is the number of digits stated for the code in the lesson.
Answer
10
Explanation
The lesson describes a UPC as comprising 10 digits used to track an item.
- 49A UPC uses a_____based on modular arithmetic to help verify that the code is valid.
Hint
It is a calculated value used to detect errors in a code.
Answer
checksum
Explanation
The UPC checksum uses modular arithmetic to help verify the validity of the code.
- 50The international standard book number, or ISBN, is used to verify_____.
Hint
It identifies the kind of publication the number is associated with.
Answer
books
Explanation
The lesson describes the ISBN as a system used to verify books.
- 51The ISBN example uses modular arithmetic to create_____values for books.
Hint
Each value distinguishes the book from others.
Answer
unique
Explanation
The lesson notes that unique ISBN values are made using modular arithmetic.

Ask anything
We've read this whole study set, so questions about it get the best answers.