-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAUTOMATIC CALCULATOR.py
More file actions
141 lines (99 loc) · 7.33 KB
/
AUTOMATIC CALCULATOR.py
File metadata and controls
141 lines (99 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#created by Harfho 5-11-2 017bb
import time #import time
print('\n\n\t\t\t\t_____________AUTOMATIC CALCLULATOR________________')
prompt=str(input('\n\t\tselect : \n\n\t\t d for division \n\t\t m for multiplication \n\t\t a for addition \n\t\t s for subtraction'.upper() +
'\n\t\t E for exponential \n\t\t R for reminder \n\n\t\t C to quit \n \nselect : '.upper() )) #variable contain an input----whatever the user enter we be store int he variable
store=('\nYOU SELECT ')
#a variable
while prompt.upper() != 'C': #while loop we run until it become false
if prompt.upper() == 'D' : #an if statement to check if what the user enter is equal to D
#if it is D the code below runs if not it does not.
try:
print(store + 'division'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nb = ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the bumber in variable ask_b into this variable
result_of_a_and_b= a / b # divide variable b from a and store the result_of_a_and_b
print('\n' + str( a ) + ' divide by ' + str( b ) + ' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (enter \'c\' to exit): '.upper())
except ValueError:
print('\n invalid \'enter a number\'... '.upper())
elif prompt.upper() == 'M': #an elif statement to check if what the user enter is equal to M
#if it is M the code below runs if not it does not.
try:
print(store + 'multiplication'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nb = ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the bumber in variable ask_b into this variable
result_of_a_and_b= a * b # multiply variable a and b and store the result_of_a_and_b
print('\n' + str( a ) + ' multiply by ' + str( b ) + ' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (\'c\' to cancel): '.upper()) #'''ask the user again if to select another operation or cancel(exit):whatever the user enter we affect the prompt at the beginning of this program '''
except ValueError:
print('\ninvalid \'enter a number\'... '.upper())
elif prompt.upper() == 'A': #an elif statement to check if what the user enter is equal to A
#if it is A the code below runs if not it does not.
try:
print(store + 'addition'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nb = ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the bumber in variable ask_b into this variable
result_of_a_and_b= a + b # Add up variable a and b and store the result_of_a_and_b
print('\n' + str( a ) + ' + ' + str( b ) + ' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (enter \'c\' to exit): '.upper())#'''ask the user again if to select another operation or cancel(exit):whatever the user enter we affect the prompt at the beginning of this program '''
except ValueError:
print('\ninvalid \'enter a number\'... '.upper())
elif prompt.upper() == 'S': #an elif statement to check if what the user enter is equal to S
#if it is S the code below runs if not it does not.
try:
print(store + 'subtraction'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nb = ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the bumber in variable ask_b into this variable
result_of_a_and_b= a - b # subtract variable a from b and store the result_of_a_and_b
print('\n' + str( a ) + ' - ' + str( b ) + ' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (enter \'c\' to exit): '.upper()) #'''ask the user again if to select another operation or cancel(exit):whatever the user enter we affect the prompt at the beginning of this program '''
except ValueError:
print('\ninvalid \'enter a number\'... '.upper())
elif prompt.upper() == 'R': #an elif statement to check if what the user enter is equal to R
#if it is R the code below runs if not it does not.
try:
print(store + 'reminder'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nb = ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the bumber in variable ask_b into this variable
result_of_a_and_b= a // b # divide variable a from b and return the reminder,the reminder is then store in variable result_of_a_and_b
print('\n' + str( a ) + ' divide by ' + str( b ) + ' we remain '+' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (enter \'c\' to exit): '.upper()) #'''ask the user again if to select another operation or cancel(exit):whatever the user enter we affect the prompt at the beginning of this program '''
except ValueError:
print('\ninvalid \'enter a number\'... '.upper())
elif prompt.upper() == 'E': #an elif statement to check if what the user enter is equal to E
#if it is E the code below runs if not it does not.
try:
print(store + 'exponential'.upper())
ask_a=int(input('\na = ')) #ask the user to input a number and store the number in this variable
ask_b=int(input('\nround up to= ')) #ask the user to input a number and store the number in this variable
a=ask_a #store the number in variable ask_a into this variable
b=ask_b #store the number in variable ask_b into this variable
result_of_a_and_b= a ** b # round up a to b
print('\n' + str( a ) + ' raise to power ' + str( b ) + ' = ',result_of_a_and_b) #print variable result_of_a_and_b
prompt=input('\n\t\t\t(select again) or (enter \'c\' to exit): '.upper()) #'''ask the user again if to select another operation or cancel(exit):whatever the user enter we affect the prompt at the beginning of this program '''
except ValueError:
print('\ninvalid \'enter a number\'... '.upper())
else:
print('\nsorry no command for that!! '.upper())
prompt=input('\nselect again : '.upper())
time.sleep(0)
print('\n\n\nBYE..............THANKS.........FOR........USING..........MY..........PROGRAMME.........'.upper())
time.sleep(1)
print('\n\t\t\t\t\t\t__-------CREATE BY AFOLABI ROKEEB AKOLADE(----MHE-KAHN----)------__')
time.sleep(1)
print('\n\nhope you are satisfy with it'.upper())
input()
input()
input()
input('\n\n\t\t\t\tpress enter to exit .........'.upper())