✦Lucas AcademyCoding Class
📄 Description

Coding homework · Variables and expressions · about 30 minutes

The prime number vault

PracticePython

A vault uses two five-digit prime numbers, 10007 and 10009. Store them in variables named p and q. Use an expression to multiply them, save the result, and print it. Then change only q to another prime, 10037, and calculate again.

Plan about 15–20 minutes for the products and comparison, then 10–15 minutes for the remainder trail. Complete both parts before submitting.

Part 1 · products and comparison

  1. Before running, write a comment estimating how many digits the first product will have.
  2. Save 10007 in p and 10009 in q. Calculate p * q, save the product, and print it.
  3. Update q to 10037. Calculate and print the new product. Keep the first product in a separate variable.
  4. Use the two saved products to calculate and print how much the product changed.

Part 2 · remainder trail

In Python, a % b gives the remainder after dividing a by b. Use that arithmetic expression for three steps. Save each remainder in a new variable; no loop is needed.

  1. Reset q to 10009. Find and print the remainder of q ÷ p.
  2. Find and print the remainder of p ÷ first remainder.
  3. Find and print the remainder of first remainder ÷ second remainder. The last nonzero remainder is the greatest common divisor.
Expected console output · all six lines
100160063
100440259
280196
2
1
0

Run your code and check all six output lines. Then write your name and submit your code for teacher review.

This homework uses variables, arithmetic expressions, assignment, comments, and print. The remainder operator is explained here as one more arithmetic expression. The TODO comments show where to start; you can edit the whole program.

⌘ Code Python 3
Write Python on the blank lines. Keep the printed answers in the requested order.
▣ Console
Run your code to see its output.

Submit to your teacher

Write your name for this submission. Your code, name, result, and time will be saved for teacher review.