Skip to content

Instantly share code, notes, and snippets.

@solanoize
Last active October 11, 2023 08:59
Show Gist options
  • Select an option

  • Save solanoize/72cde82d29a23f0f764ec1c256e3161b to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/72cde82d29a23f0f764ec1c256e3161b to your computer and use it in GitHub Desktop.
daftarProdukBBM = {
"Premium": 6450,
"Pertalite": 7650,
"Pertamax": 9000,
"Pertamax Turbo": 9850,
"Biosolar": 5150,
"Dexlite": 9500,
"DEX": 10200,
}
key = input("Masukkan jenis BBM yang ingin dibeli: ")
liter = int(input("Masukkan jumlah liter: "))
hargaBBM = daftarProdukBBM.get(key)
if not hargaBBM:
print("Ups bbm tidak ada...")
else:
if key == 'Premium' and liter > 10:
liter = 10
print("Maaf, jumlah pembelian maksimal BBM Premium adalah 10 liter")
harga = hargaBBM * liter
print(f'Harga yang harus dibayar adalah Rp. {harga}')
is_running = True
keranjangBelanja = []
while is_running:
hargaBelanja = input("Masukkan harga belanjaan kamu: ")
keranjangBelanja.append(int(hargaBelanja))
berhenti = input("Apakah mau dihitung?: ")
if berhenti == "yes":
is_running = False
hargaTotal = 0
potongan = 10 / 100
for subtotal in keranjangBelanja:
persen_potongan = subtotal - (subtotal * potongan)
hargaTotal = persen_potongan + hargaTotal
print(hargaTotal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment