Advertisement
dan_haifa

Bot-4

Jan 20th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. def do_calculation():
  2. print("Lets "+command+" some numbers")
  3. input1=input("Number1>")
  4. input2=input("Number2>")
  5. number1=int(input1)
  6. number2=int(input2)
  7. if command=="add":
  8. result=number1+number2
  9. operator="+"
  10. elif command=="subtract":
  11. result=number1-number2
  12. operator="-"
  13. output=str(result)
  14. print(input1+operator+input2+"="+output)
  15. finished=False
  16. while finished==False:
  17. print("Hi, I am a Genie, your personal bot!")
  18. print("Let's do magics!")
  19. users_name=input("What is your name?")
  20. print("Hi, "+users_name+", Welcome!")
  21. command=input("How can I help ?")
  22. if command=="add":
  23. do_calculation()
  24. elif command=="subtract":
  25. do_calculation()
  26. elif command=="calc circle" or command=="crcl":
  27. print("Let's calc the area of circle!")
  28. input1=input("diameter in cm ")
  29. input2=3.14
  30. input3=4
  31. number1=int(input1)
  32. number2=float(input2)
  33. number3=int(input3)
  34. result=number1*number1*number2/number3
  35. output=str(result)
  36. print(input1+"*"+input1+"*"+"3.14"+"/"+"4"+"="+output)
  37. elif command=="calc squared" or command=="sqrd":
  38. print("Let's calc the area of squared!")
  39. input=input("side in cm ")
  40. number=int(input)
  41. result=number*number
  42. output=str(result)
  43. print(input+"*"+input+"="+output)
  44. elif command=="average":
  45. how_many=input("how many numbers>?")
  46. how_many=int(how_many)
  47. total=0
  48. for number_count in range(how_many):
  49. number=input("Enter number "+str(number_count) +"> ")
  50. total=total+int(number)
  51. result=total/how_many
  52. print("the average= "+str(result))
  53. elif command=="shopping":
  54. shopping=[]
  55.  
  56. how_many=input("how many items of shopping do you have?")
  57. how_many=int(how_many)
  58.  
  59. for item_number in range(how_many):
  60. item=input("What is item number "+str(item_number+1) +"? ")
  61. shopping.append(item)
  62.  
  63. print(shopping)
  64.  
  65. shopping=len(shopping)
  66. shopping=str(shopping)
  67. print("You have "+shopping+" items in your list")
  68. elif command=="bye":
  69. finished=True
  70. else:
  71. print("I don't understand it!")
  72. print("Bye! "+users_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement