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.
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....
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
MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
Using Python Question 1 Write an input function. Then use it to supply the input to...
Using Python Question 1 Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even. Question 2 Write function that asks for input from a user. If the user types 'end', the program exits, otherwise it just keeps going.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT