Advertisement
GCK

GCK/While_forever_if-not-bye

GCK
Sep 16th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.28 KB | None | 0 0
  1. def Calculate_something():
  2.     finished=False
  3.     print("Hello Im gigi your bot")
  4.     print("let's get started for more practice")
  5.     print("How can I help you?")
  6.     while finished==False:
  7.         print("Would you like to make an operation?")
  8.         operation=input("Answer: type  Y or YES for YES and type N or NO for NO? >")
  9.        
  10.         if operation=="NO" or operation=="N":
  11.             print("Bye Bye")
  12.         elif operation=="YES" or operation=="Y":
  13.             answer=input("Do you want to : > ( substract, add, multiply, sum or average) ?>")
  14.             if answer=="substract" or answer=="add" or answer=="multiply":
  15.                   input1=input("enter number 1>")
  16.                   input2=input("Enter number2>")
  17.                   number1=int(input1)
  18.                   number2=int(input2)
  19.                   print("lets "+ answer + " your numbers")
  20.                   if answer=="substract":
  21.                       substraction=number1-number2
  22.                       print("Results for "+input1+ "-"+input2 + "= "+ str(substraction))
  23.                   elif answer=="add":
  24.                       addition=number1+number2
  25.                       print("Result for "+input1+ "+"+input2 + "= "+str(addition))
  26.                   elif answer=="multiply":
  27.                       multiplication=(number1)*(number2)
  28.                       print("Results for "+input1+ "*"+input2 + "= "+str(multiplication))
  29.             elif answer=="sum" or answer=="average":
  30.                 how_many=int(input("How many numbers>"))
  31.                 total=0
  32.                 Average=0
  33.                 for number_count in range(how_many):
  34.                     number=input("Enter number "+ str(number_count)+ ":>)")
  35.                     total=total+ int(number)
  36.                     Average=total/how_many
  37.                 if answer=="sum":
  38.                     print("Total cost is = " + str(total))
  39.                 elif answer=="average":
  40.                     print("The average of "+ str(total)+ " by " + str(how_many) + "= "+str(Average))
  41.             else:
  42.                 print("Try again. I don't understand")
  43.         elif operation=="bye":
  44.             print("Goodbye!")
  45.             finished=True
  46.            
  47.         else:
  48.             print("I dont understand '"+ operation + " )'")
  49.  
  50. Calculate_something()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement