Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- print ("let's" + command + " some numbers")
- input1 = input ("Number 1> ")
- input2 = input ("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- if command == "add":
- result = number1 + number2
- operator = "+"
- elif command == "subtract":
- result = number1 - number2
- operator = "-"
- output = str(result)
- print (input1 + operator + input2 + "=" + output)
- def average_or_total():
- total = 0
- print ("Let's calculate the " + command + " of some numbers.")
- how_many = input("How many numbers would you like " + command + " ? ")
- how_many = int(how_many)
- for n in range(how_many):
- n = n + 1
- number = input("Enter a number " + str(n) + ": ")
- total = total + int(number)
- if command == "average":
- result = total/how_many
- elif command == "total":
- result = total + int(number)
- print ("the " + command + " is " + str(result))
- finished = False
- while finished == False:
- print ("Hello, I am francydafne, your bot!")
- # code for adding numbers:
- command = input ("How can I help? ")
- if command == "add" or command == "plus":
- do_calculation()
- # code for subtracting numbers:
- elif command == "subtract":
- do_calculation()
- # code for dividing numbers:
- elif command == "divide":
- print ("let's divide some numbers")
- input1 = input ("Number 1> ")
- input2 = input ("Number 2> ")
- 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 ("Number 1> ")
- input2 = input ("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print (input1 + "*" + input2 + "=" + output)
- # code for calculating the area of a square:
- elif command == "square area":
- print ("let's calculate the area of a square multiplying its sides")
- input1 = input ("Number 1> ")
- input2 = input ("Number 2> ")
- number1 = int(input1)
- number2 = int(input2)
- result = number1 * number2
- output = str(result)
- print (input1 + "*" + input2 + "=" + output)
- # code for calculating averages or total
- elif command == "average":
- average_or_total()
- elif command == "total":
- average_or_total()
- # code for listing things I do during the day
- elif command == "todolist":
- todolist = []
- everyday = input ("How many things do you do? ")
- everyday = int(everyday)
- for acts in range(everyday):
- actions = input("What do you do? " + str(acts+1) + " ")
- todolist.append (actions)
- print (todolist)
- print ("The things I do every day are " + str(everyday))
- # to stop the program:
- elif command == "bye":
- finished = True
- # if everything goes wrong....
- else:
- print ("sorry, I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement