Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_calculation():
- print('Lets',command,'some numbers')
- input1=input('Number 1 :> ')
- print('')
- input2=input('Number 2 :> ')
- numba1=int(input1)
- numba2=int(input2)
- if command == 'Add' or command == 'add':
- result=numba1+numba2
- operator='+'
- elif command == 'Subtract' or command == 'subtract':
- result=numba1-numba2
- operator='-'
- elif command == 'Multiply' or command == 'multiply':
- result=numba1*numba2
- operator='*'
- elif command == 'Divide' or command == 'divide':
- result=numba1/numba2
- operator='/'
- elif command == 'Power' or command == 'power':
- result=numba1**numba2
- operator='**'
- ansa=str(result)
- print(' ')
- print(numba1,operator,numba2,'=',ansa)
- def do_average_or_total():
- print('Lets find the',command,'of some numbers')
- print(' ')
- how_many = input('How many numbers? ')
- how_many = int(how_many)
- total = 0
- for counter in range(how_many):
- number = input('Enter number ' + str(counter+1) + '> ')
- total = total + int(number)
- result = total / how_many
- print(' ')
- if command == 'Total' or command == 'total':
- print('The total is',total)
- elif command == 'Average' or command == 'average':
- print('The average is',result)
- else:
- print('Error!')
- print('****************************************')
- print('******** ********')
- print('******** WELCOME TO THE BOT ********')
- print('******** ********')
- print('****** MASTER PROGRAMMER: FAHIM ******')
- print('******** ********')
- print('****************************************')
- print('Hi, I am the Bot')
- print('')
- # Asks the user to enter their name
- user_name=input("What's you name? :>")
- print('Welcome '+user_name+'!')
- print('')
- finished = False
- while finished == False:
- command=input("What is your command?:> ")
- if command == 'Add' or command == 'add':
- do_calculation()
- elif command == 'Subtract' or command == 'subtract':
- do_calculation()
- elif command == 'Multiply' or command == 'multiply':
- do_calculation()
- elif command == 'Divide' or command == 'divide':
- do_calculation()
- elif command == 'Total' or command == 'total':
- do_average_or_total()
- elif command == 'Average' or command == 'average':
- do_average_or_total()
- if command == 'Power' or command == 'power':
- do_calculation()
- elif command == 'bye' or command == 'Bye':
- finished = True
- print('Goodbye')
- else:
- print("Sorry! I don't get it!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement