Loop program

homework
python

#1

I need help with this loop program
I got the first half just need help with the last half

Develop a Python program that contains this menu:

A. Estimate the shipping rates
B. Find the maximum number of two integer numbers
Q. Quit

Please enter your selection:

 If user enters a wrong option, the error message will display
“You have a wrong selection, please try again.” (Hint: using while-loop )

 If users choose ‘A’, your application will allow users to enter total amount for online shopping and how many items will be shipped. After calculation, it will display the shipping fee.

The shipping rate formula is based on the following algorithm.

  • If the total amount of online shopping is less than or equal $50, the shipping rates will be $5 plus $1.5 for each items.

  • If the total amount of online shopping is less than or equal $100, the shipping rates will be $5 plus $1 for each items.

  • If the total amount of online shopping is over $100, it will be free shipping.

 If users choose ‘B’, your application will allow users to enter two integer numbers, and display the maximum numbers.

 When the “Q. Quit” is selected, the program will be terminated. Screen will display
“ Thank you for using the program.”

my code is the following

print(“A Estimate the shipping rates”)
print(“B find the maximun numbers of two intergers numbers”)
print(“Q Quit”)
print(“please enter your selection”)
Choice=input()
while Choice != "Q"
if choice==“A”:
totalAmount_str=input(“enter total for online shopping”)
totalAmount=float(totalAmount_str)
Items_str=input(“How many items will be shipped”)
Items=input(Items=str)
shippingRates=float
if totalAmount<=50:
shippingtRates=5+1.5Items
print(“Total shipping fee is:”, shippingRates)
elif totalAmount <=100
shippingRates=5+1
Items
print(“Total shipping fee is:”, shippingRates)
else
print(“Total shipping fee is:free”)
elif choice== “B”:
firstinteger_str=input(“enter your first string”)

<do not remove the three backticks above>

#2

Say we consider a program as containing something more than print statements. Where does that take us? To be a program that is re-usable means making it a function. A function is a re-usable bit of code that we can call by name.

    def foo():
        return "Foo! (Are you surpised?)"

    print (foo())    # <- Foo! (Are you surpised?)

So what will be the header line of your function?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.