# Untitled

unknown
python
2 years ago
2.3 kB
15
Indexable
Never
```
# bismillah

input('Program tiket masuk kebun binatang\nPRESS ENTER')

# User Interface
form = str('''
===================================
SELAMAT DATANG DI KEBUN BINATANG!
===================================
Daftar harga tiket:
1. <= 2 tahun                 \$FREE
2. 3 - 12 tahun               \$14
3. 13 - 65 tahun              \$23
4. >= 65 tahun                \$18
===================================

Masukkan umur anda:
>> ''')

formbayar = str('''
===================================
Harga tiket anda: \${0}
MASUKKAN UANG ANDA!

Nominal uang anda: \$ ''')

message = str('''
===================================
{0}
PRESS ENTER''')

# Function here
def space():
for i in range(100):
print()

def harga(x):
global price
global lanjut
global free
if x <= 2:
price = 0
free = 1
elif x >= 3 and x <= 12:
price = 14
elif x >= 13 and x <= 65:
price = 23
else:
price = 18

def count(x):
global uang
global pesan
global lanjut
global tiket
if x < price:
pesan = str('Uang anda tidak cukup!')
lanjut = 0
tiket = 0
elif x == price:
pesan = str("Uang anda pas! Terimakasih")
lanjut = 0
tiket = 1
else:
uang = uang - price
pesan = str(('Kembalian anda: \${0} Terimakasih!').format(uang))
lanjut = 0
tiket = 1

# Algo
main = True
while main == True:
error = 1
price = int()
free = 0
while error == 1:
try:
umur = int(input(form))
harga(umur)
error = 0
lanjut = 1
space()
except ValueError:
error = 1
space()

if free == 1:
pesan = ('Silahkan masuk secara GRATIS!')
input((message.format(pesan)))
space()
lanjut = 0

while lanjut == 1:
try:
uang = int(input(formbayar.format(price)))
count(uang)
lanjut = 0
space()
except ValueError:
lanjut = 1
input('\nMasukkan Angka!\nPRESS ENTER!')
space()

input(message.format(pesan))
space()

```