Advertisement
kevinbocky

functions.py

Dec 17th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. def max_num (num1,num2,num3):
  2. if num1 >= num2 and num1 >= num3 :
  3. return num1
  4. elif num2 >= num1 and num2 >= num3:
  5. return num2
  6. else:
  7. return num3
  8.  
  9.  
  10. print(max_num(30,400,5))
  11.  
  12.  
  13.  
  14.  
  15. def calculation():
  16. print("Let's " + command + " some numbers")
  17.  
  18. if command == "add":
  19. input1 = input("Number 1 : ")
  20. input2 = input("Number 2 : ")
  21. result = int(input1) + int(input2)
  22. print(str(result))
  23.  
  24. elif command == "subtract":
  25. input1 = input("Number 1 : ")
  26. input2 = input("Number 2 : ")
  27. result = int(input1) - int(input2)
  28. print(str(result))
  29.  
  30. elif command == "total":
  31. result = 0
  32. how_many = input("how many numbers do you want to add? ")
  33. for loop in range(int(how_many)):
  34. number = input("Enter number " + str(loop) + ": ")
  35. result = result + int(number)
  36. print(str(result))
  37.  
  38. elif command == "average":
  39. result = 0
  40. how_many = input("How many numbers do you want to enter? ")
  41. for loop in range(int(how_many)):
  42. number = input("Enter number " + str(loop) + ": ")
  43. result = result + int(number)
  44. average = int(result) / int(how_many)
  45. print(str(average))
  46.  
  47. loop = True
  48. while loop == True:
  49.  
  50. print("Hi,i'm Oracle your personal bot")
  51. command = input("How can i help? ")
  52.  
  53. if command == "add" or command == "subtract" or command == "total" or command == "average":
  54. calculation()
  55.  
  56. elif command == "bye" or command == "exit" or command == "stop":
  57. loop = False
  58.  
  59. else:
  60. print("wrong entry / operator")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement