Space Mission Calculator

PythonBeginner
Practice Now

Introduction

Welcome to the LabEx Space Academy's Python Function and Module Challenge! As a new space cadet, you'll be completing a simple space mission calculator. This challenge will help you practice defining functions and using them from another file.

Complete the Space Mission Calculator

In this challenge, you will complete a partially created Python module and use it in a main program.

Tasks

  1. Open the file space_math.py in the /home/labex/project directory. (Recommend to use WebIDE)
  2. Complete the three functions in space_math.py:
    • calculate_fuel(distance)
    • time_to_destination(distance, speed)
    • gravity_force(mass1, mass2, distance)
  3. Open the file mission_planner.py in the same directory.
  4. Import the functions from space_math.py and use them to calculate mission details.

Requirements

  • Complete the functions in space_math.py using the formulas provided in the comments.
  • In mission_planner.py, import the functions from space_math.py using the from ... import ... syntax.
  • Use the imported functions to calculate and display the mission details.
  • Round all calculations to two decimal places in the output.

Example

After completing and running mission_planner.py, the output should look similar to this:

python ~/project/mission_planner.py
Space Mission Details:
----------------------
Fuel needed: 112500000000.00 liters
Time to destination: 11250.00 hours
Gravitational force at destination: 12.64 N
✨ Check Solution and Practice

Summary

In this challenge, you completed a Python module with space mission calculation functions and used it in a main program. You practiced defining functions, importing them from another file, and using them in calculations. These skills are important for organizing your code and creating reusable components in larger Python projects.