Program Kalkulator Sederhana Python
Listing
print " Kalakulator "
print "1. Penjumlahan"
print "2. Pengurangan"
print "3. Perkalian"
print "4. Pembagian"
print "5. Sisa Pembagian"
a = raw_input("Masukkan Pilihan[1-5] :")
if (a=="1"):
print "Penjumlahan"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a+b
print a," + ",b," = ",c
print (" ")
elif (a=="2"):
print "Pengurangan"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a-b
print a," - ",b," = ",c
print (" ")
elif (a=="3"):
print "Perkalian"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a*b
print a," . ",b," = ",c
print (" ")
elif (a=="4"):
print "Pembagian"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a/b
print a," : ",b," = ",c
print (" ")
elif (a=="5"):
print "Sisa Bagi"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a%b
print "Hasil sisa bagi ",a," dengan ",b," = ",c
print (" ")
else:
print " Maaf Tidak Terdapat dalam Pilihan "
Output
print " Kalakulator "
print "1. Penjumlahan"
print "2. Pengurangan"
print "3. Perkalian"
print "4. Pembagian"
print "5. Sisa Pembagian"
a = raw_input("Masukkan Pilihan[1-5] :")
if (a=="1"):
print "Penjumlahan"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a+b
print a," + ",b," = ",c
print (" ")
elif (a=="2"):
print "Pengurangan"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a-b
print a," - ",b," = ",c
print (" ")
elif (a=="3"):
print "Perkalian"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a*b
print a," . ",b," = ",c
print (" ")
elif (a=="4"):
print "Pembagian"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a/b
print a," : ",b," = ",c
print (" ")
elif (a=="5"):
print "Sisa Bagi"
a = float(raw_input("Masukkan nilai pertama = "))
b = float(raw_input("Masukkan nilai kedua = "))
c = a%b
print "Hasil sisa bagi ",a," dengan ",b," = ",c
print (" ")
else:
print " Maaf Tidak Terdapat dalam Pilihan "
Output
Komentar
Posting Komentar