Question

In: Computer Science

in python Using this baseline template, write a program to input a choice from a menu...

in python

Using this baseline template, write a program to input a choice from a menu

def calcArea(length, width):
   pass
  
def CalcVolumeSa(length, width, height):
   pass

def menu():
   pass
      

def getValuesArea():
pass
  

def getValuesVolSa():
pass
  
  
def main():
   menu()

if __name__ == "__main__":
   main()

[1] - Calculate Area of rectangle
[2] - calculate Volume and Surface area of Rectangle
[x} - Exit

Please select Option:

input the appropriate values and calculate and print out the results.    For example:

Please select Option: 2
Please enter length: 4
Please enter width: 5
Please enter height: 6
For Rectangle of lenght 4.0, width 5.0 and height 6.0, the Volume is 120.0, Surface Area is 148.0
Menu

[1] - Calculate Area of rectangle
[2] - calculate Volume and Surface area of Rectangle
[x} - Exit

Please select Option:

repeat the process until the user selects 'x'.

Solutions

Expert Solution

CODE:

def calcArea(length, width):
    return length * width


def CalcVolumeSa(length, width, height):
    return length * width * height, 2 * (length * width + width * height + height * length)


def menu():
    while True:
        print(
            "[1] - Calculate Area of rectangle\n[2] - calculate Volume and Surface area of Rectangle\n[x] - "
            "Exit\nPlease "
            "select Option:", end="")
        option = input()
        if option == "1":
            getValuesArea()
        elif option == "2":
            getValuesVolSa()
        elif option == "x":
            print("Exiting...")
            break


def getValuesArea():
    l = float(input("Please enter length:"))
    b = float(input("Please enter width:"))
    print("For Rectangle of length %.1f and width %.1f , the area is %.1f" % (
        calcArea(l, b)))


def getValuesVolSa():
    l = float(input("Please enter length:"))
    b = float(input("Please enter width:"))
    h = float(input("Please enter height:"))
    vol, sa = CalcVolumeSa(l, b, h)
    print("For Rectangle of length %.1f, width %.1f and height %.1f, the Volume is %.1f, Surface Area is %.1f" % (
        l, b, h, vol, sa))


def main():
    menu()


if __name__ == "__main__":
    main()

OUTPUT:

Please upvote if you like my answer and comment below if you have any queries or need any further explanation.


Related Solutions

PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x)...
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
Need this program in python. The data must be taken from user as input. Write a...
Need this program in python. The data must be taken from user as input. Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done...
Write a program in python that corrects misspelled words. The input for the program is either...
Write a program in python that corrects misspelled words. The input for the program is either a string or a list of strings. The output should be a string or a list depending on the input and should have the spellings corrected. The speller should be able to correct at least the words listed below. You are free to use any data structures we have covered so far including lists and dictionaries. Your program should be in autocorrect.py. Here is...
Write a Python program which takes a set of positive numbers from the input and returns...
Write a Python program which takes a set of positive numbers from the input and returns the sum of the prime numbers in the given set. The sequence will be ended with a negative number.
In python write a program that gets a list of integers from input, and outputs non-negative...
In python write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest). Ex: If the input is: 10 -7 4 39 -6 12 2 the output is: 2 4 10 12 39 For coding simplicity, follow every output value by a space. Do not end with newline
Write a python program that can solve system of linear equations in three variables using input...
Write a python program that can solve system of linear equations in three variables using input function. Paste your program in a word document or notepad. Note that I am using pycharm. please use a not really complex codes, thanks
IN PYTHON Write a program that takes in a positive integer as input, and outputs a...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string....
write a python program, please. Create a program that uses the Gettysburg Address as input and...
write a python program, please. Create a program that uses the Gettysburg Address as input and outputs a list of tuples for every two words. For example: [('Four', 'score'),('and', 'seven'), ...].
Using the Python program: a/ Write a program that adds all numbers from 1 to 100...
Using the Python program: a/ Write a program that adds all numbers from 1 to 100 to a list (in order). Then remove the multiples of 3 from the list. Print the remaining values. b/ Write a program that initializes a list with ten random integers from 1 to 100. Then remove the multiples of 3 and 5 from the list. Print the remaining values. Please show your work and explain. Thanks
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT