#KalKulator Sederhana Menggunakan Python
def operasi(x,y,operator):
total = 0
if (operator =="+"):
total=x+y
elif(operator=="-"):
total=x-y
elif(operator=="*"):
total=x*y
elif(operator=="/"):
total=x/y
elif(operator=="**"):
total=x**y
elif(operator=="%"):
total=x%y
else:
return "Operator Tidak Dikenali !!!"
return total
x = int(input("bilangan -1 = "))
y = int(input("bilangan -2 = "))
operator = input("operator(+,-,*,/,**,%) = ")
print ("Hasil = ", operaasi(x,y,operator))
def operasi(x,y,operator):
total = 0
if (operator =="+"):
total=x+y
elif(operator=="-"):
total=x-y
elif(operator=="*"):
total=x*y
elif(operator=="/"):
total=x/y
elif(operator=="**"):
total=x**y
elif(operator=="%"):
total=x%y
else:
return "Operator Tidak Dikenali !!!"
return total
x = int(input("bilangan -1 = "))
y = int(input("bilangan -2 = "))
operator = input("operator(+,-,*,/,**,%) = ")
print ("Hasil = ", operaasi(x,y,operator))
#Kalkulator Sederhana Multi Fungsi Menggunakan Python
def operasi(x,y,operator):
total = 0
if (operator =="+"):
total=x+y
elif(operator=="-"):
total=x-y
elif(operator=="*"):
total=x*y
elif(operator=="/"):
total=x/y
elif(operator=="**"):
total=x**y
elif(operator=="%"):
total=x%y
else:
return "Operator Tidak Dikenali !!!"
return total
bOperator = int(input("Banyak Operator = "))
total = 0
n = int(input("Bilangan -1 = "))
for i in range (1, bOperator +1):
m = int(input("Bilangan - " +str(i + 1)+"="))
operator = input("operator(+,-,*,/,**,%)=")
if(i==1):
total = operasi(n,m,operator)
else:
total = operasi(total,m,operator)
print("Hasil Sementara = ",total)
print("Hasil akhir =",total)
def operasi(x,y,operator):
total = 0
if (operator =="+"):
total=x+y
elif(operator=="-"):
total=x-y
elif(operator=="*"):
total=x*y
elif(operator=="/"):
total=x/y
elif(operator=="**"):
total=x**y
elif(operator=="%"):
total=x%y
else:
return "Operator Tidak Dikenali !!!"
return total
bOperator = int(input("Banyak Operator = "))
total = 0
n = int(input("Bilangan -1 = "))
for i in range (1, bOperator +1):
m = int(input("Bilangan - " +str(i + 1)+"="))
operator = input("operator(+,-,*,/,**,%)=")
if(i==1):
total = operasi(n,m,operator)
else:
total = operasi(total,m,operator)
print("Hasil Sementara = ",total)
print("Hasil akhir =",total)
Silahkan Berkomentar Sesuai Artikel EmoticonEmoticon