Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- finished = False
- while finished == False:
- print("Hi, I am Jenny, your personal bot.")
- command = input("How can I help? ")
- # code for adding numbers
- if command == "add":
- print("Let's add some numbers!")
- users_name = input("What is your name? ")
- print("Welcome to Math world, " + users_name)
- print("Let's add some numbers.")
- input1 = input("Number1- ")
- input2 = input("Number2- ")
- input3 = input("Number3- ")
- number1 = int(input1)
- number2 = int(input2)
- number3 = int(input3)
- result = number1 + number2 + number3
- output = str(result)
- print(input1 + "+" + input2 + "+" + input3 + "=" + output)
- # elif is like having possibilities other than the first one
- # code for subtracting numbers
- elif command == "subtract":
- print("Let's subtract some numbers.")
- input1 = input("Number1- ")
- input2 = input("Number2- ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 - number2
- output = str(result)
- print(input1 + "-" + input2 + "=" + output)
- # code for multiplying numbers
- elif command == "multiply":
- print("Let's multiply some numbers.")
- input1 = input("Number1- ")
- input2 = input("Number2- ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1*number2
- output = str(result)
- print(input1 + "X" + input2 + "=" + output)
- # code for dividing numbers
- elif command == "division":
- print("Let's divide some numbers.")
- input1 = input("Number1- ")
- input2 = input("Number2- ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1/number2
- output = str(result)
- print(input1 + "/" + input2 + "=" + output)
- # code for calculating area of a triangle
- elif command == "area of a triangle":
- print("Let's calculate the area of a triangle.")
- print("The formula for the area of a triangle is: 1/2 X Base X Height.")
- input1 = input("Base- ")
- input2 = input("Height- ")
- number1 = int(input1)
- number2 = int(input2)
- result = (1/2)*number1*number2
- output = str(result)
- print("1/2 X " + input1 + "X" + input2 + "=" + output)
- # code for finding average
- elif command == "average":
- print("Let's learn about average.")
- how_many = input("How many numbers?> ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + ">")
- total = total + int(number)
- result = total / how_many
- print("the average=" + str(result))
- # to create a shopping list
- elif command == "create shopping list":
- print("Let's create a shopping list.")
- shopping = []
- count = 0
- how_many = input("How many items of shopping do you have? ")
- how_many = int(how_many)
- for item_number in range(how_many):
- item = input("What is the item number " + str(item_number) + "?")
- shopping.append(item)
- count = count + 1
- output = str(count)
- print(shopping)
- print("You have " + output + " items in your shopping list.")
- elif command == "bye":
- finished = True
- else:
- print("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement