CSIS2101_assgn7

.docx

School

Nova Southeastern University *

*We aren’t endorsed by this school

Course

2101

Subject

Physics

Date

Jan 9, 2024

Type

docx

Pages

4

Uploaded by the831unit

Report
Assignment 7 Question 1 ( 100 points) Menu Program Write a Python program named weights_firstname that finds the Weights of objects in Newton on different planets and satellites like Earth, Mars, Moon and Saturn. Your mass in Kilograms is a constant in all planets and satellites. But your weight is different and is calculated as W = m * g Where m is your mass in Kg and g is the gravity on the planet in m/s 2 In this file there should be four methods defined. Write a method named weight_earth_firstname, which accepts the mass of an object in Kilograms as an argument into the function. The method should calculate the weight of the object and return the weight on Earth in Newtons. The formula for calculating the weight of an object on Earth is given below. Write a method named weight_mars_firstname, which accepts the mass of an object in Kilograms as an argument into the function. The method should calculate the weight of the object and return the weight on Mars in Newtons. The formula for calculating the weight of an object on Mars is given below. Write a method named weight_moon_firstname, which accepts the mass of an object in Kilograms as an argument into the function. The method should calculate the weight of the object and return the weight on Moon in Newtons. The formula for calculating the weight of an object on Moon is given below. Write a method named weight_saturn_firstname, which accepts the mass of an object in Kilograms as an argument into the function. The method should calculate the weight of the object and return the weight on Saturn in Newtons. The formula for calculating the weight of an object on Saturn is given below. You don’t have to define a main in this program. Now Write a Python program named menu_firstname that asks the user to find weights of 3D objects. The program will then present the following menu of selections: a) Weight of an object in Newtons on Moon. b) Weight of an object in Newtons on Earth. c) Weight of an object in Newtons on Mars. d) Weight of an object in Newtons on Saturn. e) Exit the program. This program should import weights_firstname.py using the command import weights_firstname
and should be able to use the functions from that file. Write a void method named menu_lastname that displays the menu of selections. This method should not accept any arguments. The main in the program should keep running and continue to display the menu until the user enters “e” to exit the program. If the user selects an invalid choice from the menu, the program should display an error message. “Invalid Menu Option. Please pick a valid option” Based on the option entered, corresponding weight function from the other file is invoked and the weight is displayed by the Menu program. The menu program should display the weight in the corresponding planet or satellite based on the menu option chosen. For any valid option on the menu entered, the menu program should ask for two inputs the mass and the units. o Make sure that the mass is a positive number greater than 0 and the units is “lbs”. o Write ONLY one valid_input_firstname program in the Menu file which returns True if both input are valid. o This function can be reused for all menu options. o Once the input is validated, convert the weight into kilograms and it calls the corresponding weight function in the other file passing in the mass in kilograms and which returns the weight in Newtons. o Please note that the input mass of the object is validated in pounds and the input for every function in the other file is kilograms to compute weight in Newtons. o The Weight in Newtons and the planet is displayed. Format the weight output to three decimals As usual submit the two files in the form of a zip file Add comments to show what each function does. Here is the formula used for weight calculation: Weight in Newtons = Mass in Kilogram * g ( where g is the gravitational acceleration on each planet in m/s 2 . ) g on Earth = 9.81 m/s 2 g on Moon = 1.62 m/s 2 g on Mars = 3.77 m/s 2 g on Saturn = 10.39 m/s 2 Conversion of Pounds into Kilogram uses the formula: 1 Kilogram = 2.2 Pounds
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help