# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment

responses = initialize_assignment("13_module_q", "week_1", "readings", assignment_points = 9.0, assignment_tag = 'week1-readings')

# Initialize Otter
import otter
grader = otter.Notebook("13_module_q.ipynb")

โ“ What is a Python Module?#

# Run this block of code by pressing Shift + Enter to display the question
from questions._13_module_q import Question1
Question1().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._13_module_q import Question2
Question2().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._13_module_q import Question3
Question3().show()

๐Ÿฆธโ€โ™‚๏ธ Avengers Mission: Python Modules!#

The Avengers need your coding skills to prepare for their next mission. Your task is to help them with three important calculations using Pythonโ€™s math module.

Mission Objectives#

  1. Thorโ€™s Task: Calculate the area of Mjolnirโ€™s circular base. The radius is 10 units. Use the formula for the area of a circle:

    \(\text{Area} = \pi \times r^2\)

    Use the constant math.pi and store the result in a variable named hammer_area.

  2. Iron Manโ€™s Task: Compute the cosine of 45 degrees to optimize his repulsor targeting system.

    • First, convert 45 degrees to radians using:

      \(\text{Radians} = \text{Degrees} \times \frac{\pi}{180}\)

      Use the function math.radians to handle this conversion.

    • Then, calculate the cosine using math.cos.
      Store the result in a variable named iron_cosine.

  3. Captain Americaโ€™s Task: Determine the least common multiple (LCM) of 12 and 18 to synchronize the teamโ€™s communication devices.

    • First, find the greatest common divisor (GCD) using math.gcd.

    • Then, calculate the LCM using the formula:

      \(\text{LCM}(a, b) = \frac{|a \times b|}{\text{GCD}(a, b)}\)

    Store the result in a variable named cap_lcm.

Requirements#

  • Write a Python program to perform these calculations.

  • Use the math module to simplify your work.

  • Assign the results to the variables hammer_area, iron_cosine, and cap_lcm.

  • Print the results at the end of your program so the Avengers can see them.

Now, go save the world with your coding skills! ๐ŸŒŸ

# Add your import statement here
...


def avengers_assemble():
    # Thor's hammer base area (circle area formula: ฯ€rยฒ)
    hammer_area = ...

    # Iron Man's cosine calculation (convert degrees to radians first)
    iron_cosine = ...

    # Captain America's LCM calculation
    # Find the LCM of 12 and 18
    a = 12
    b = 18
    cap_lcm = ...

    return hammer_area, iron_cosine, cap_lcm

# Do not modify the code below this line
# Print results
hammer_area, iron_cosine, cap_lcm = avengers_assemble()


print(f"Mjolnir's base area: {hammer_area}")
print(f"Iron Man's cosine of 45 degrees: {iron_cosine}")
print(f"Captain America's LCM: {cap_lcm}")
grader.check("avengers-mission-modules")

Submitting Assignment#

Please run the following block of code using shift + enter to submit your assignment, you should see your score.

from pykubegrader.submit.submit_assignment import submit_assignment

submit_assignment("week1-readings", "13_module_q")