-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkalkulator.py
More file actions
32 lines (29 loc) · 982 Bytes
/
Copy pathkalkulator.py
File metadata and controls
32 lines (29 loc) · 982 Bytes
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
perintah = ''
print('=' * 50)
print('Masukan perintah [+] [-] [*] [/]')
print('untuk memberhentikan program masukan perintah [exit]')
while perintah != 'exit' :
print('=' * 50)
perintah = input('masukkan perintah : ')
if perintah == 'exit':
break
if perintah != '+' and perintah != '-' and perintah != '*' and perintah != '/' :
print('=' * 50)
print('perintah tidak di ketahui')
continue
a = eval(input('masukkan bilangan pertama : '))
b = eval(input ('masukkan bilangan kedua : '))
if perintah == '+' :
hasil = a + b
print(f'hasil dari {a} + {b} =')
elif perintah == '-' :
hasil = a - b
print(f'hasil dari {a} - {b} =')
elif perintah == '*' :
hasil = a * b
print(f'hasil dari {a} * {b} =')
elif perintah == '/':
hasil = a / b
print(f'hasil dari {a} / {b} =')
print('=' * 50)
print('Terimakasih telah memakai program ini')