Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import time
- def jonglior(a, b):
- empty_result_list = []
- while True:
- user_command2 = input('Please Enter your calculation action: multiply(m) | divide(d) | add(a) | subtract(s): ')
- if user_command2 == 'a' or user_command2 == 'm' or user_command2 == 'd' or user_command2 == 's':
- while True:
- try:
- a = int(input('Please put your first digit: '))
- break
- except ValueError:
- print("Please enter a number")
- while True:
- try:
- b = int(input('Could you please put your second digit: '))
- break
- except ValueError:
- print("Please enter a number")
- else:
- print('You should use options already mentioned: multiply | divide | add | subtract!: ')
- continue
- # user_command2 = input('Please Enter your calculation action: multiply | divide | add | subtract: ')
- result = 0
- if user_command2 == 'm' or user_command2 == 'multiply':
- result = multiply(a, b)
- empty_result_list.append(result)
- elif user_command2 == 'd' or user_command2 == 'divide':
- result = divide(a, b)
- empty_result_list.append(result)
- elif user_command2 == 'a' or user_command2 == 'add':
- result = addition(a, b)
- empty_result_list.append(result)
- elif user_command2 == 's' or user_command2 == 'subtract':
- result = subtraction(a, b)
- empty_result_list.append(result)
- print(f'Result is : {result}!')
- n = 2
- while n > 0:
- time.sleep(1)
- n -= 2
- print('Thank you for your input!\n'
- '')
- n = 2
- while n > 0:
- time.sleep(2)
- n -= 2
- user_command6 = input('Would you like to continue: Yes | No ?')
- n = 1
- while n > 0:
- time.sleep(1)
- n -= 1
- if user_command6 == 'yes' or user_command6 == 'Yes' or user_command6 == 'y':
- a = int
- b = int
- continue
- elif user_command6 == 'no' or user_command6 == 'No' or user_command6 == 'n':
- n = 1
- while n > 0:
- time.sleep(1)
- n -= 1
- print('Calculator is entering sleeping mode after 5 seconds...')
- for i in range(5, 0, -1):
- time.sleep(1)
- print(i)
- zx = 1
- while zx > 0:
- time.sleep(1)
- zx -= 1
- print('End!')
- zxn = 2
- while zxn > 0:
- time.sleep(1)
- zxn -= 1
- print(f'The results as numbers are as follows: {empty_result_list}')
- sys.exit(1)
- def multiply(a, b):
- return a * b
- def divide(a, b):
- if b > 0:
- return a / b
- if b <= 0:
- print('Error: Division by Zero or negative number, Please redo operation!')
- nl = 1
- while nl > 0:
- time.sleep(1)
- nl -= 1
- return jonglior(a, b)
- def addition(a, b):
- return a + b
- def subtraction(a, b):
- return a - b
- def main():
- print('Hello, This is simple calculator!')
- n = 1
- while n > 0:
- time.sleep(1)
- n -= 1
- a = int
- b = int
- return jonglior(a, b)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement