Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- finished = False
- def do_calculation():
- print("Let us " + 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=" - "
- else:
- print(command+" is not a valid answer. I do not know if I should add, subtract or calculate an average. Please Try again.")
- output=str(result)
- print(input1+operator+input2+" = "+output)
- while finished == False:
- print("Hi, I am the bot that Sue created.")
- print("Let's get started.")
- users_name=input("What is your name? ")
- print("Welcome "+users_name)
- command=input("Please type add, subtract, or mean to calculate the average. Type bye if you would like to leave the program.>")
- if command=="bye":
- finished=True
- elif command=="mean":
- how_many=input("How Many Numbers Do You Want to Average?>")
- 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))
- else:
- do_calculation()
- if finished==False:
- shopping=[]
- count=0
- how_many=input(users_name+", how many items do you have on your shopping list? ")
- 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)
- for item in shopping:
- print(item)
- count=count+1
- print(count)
- print (len(shopping))
- strcount=str(count)
- print (users_name+", you have "+strcount+" items in your shopping list.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement