Add tasks
This commit is contained in:
parent
b31b0fcc56
commit
0919e6e884
|
@ -0,0 +1,21 @@
|
|||
|
||||
def boolInput(question):
|
||||
while True:
|
||||
try:
|
||||
choice = input(question)
|
||||
assert choice in ['J', 'j', 'N', 'n']
|
||||
return choice in ['J','j']
|
||||
except AssertionError:
|
||||
print('Skriv in J eller N\n')
|
||||
|
||||
def discountBranch():
|
||||
choseDiscount = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
|
||||
print('Takk for pengene, god reise!' if choseDiscount else 'Da tilbyr vi fullpris: 440,-')
|
||||
|
||||
|
||||
daysToTrip = int(input('Dager til du skal reise? '))
|
||||
|
||||
if daysToTrip >= 14:
|
||||
discountBranch()
|
||||
else:
|
||||
print('For sent for minipris; fullpris 440,-')
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
def boolInput(question):
|
||||
while True:
|
||||
try:
|
||||
choice = input(question)
|
||||
assert choice in ['J', 'j', 'N', 'n']
|
||||
return choice in ['J','j']
|
||||
except AssertionError:
|
||||
print('Skriv in J eller N\n')
|
||||
|
||||
def evalDiscountPercent():
|
||||
age = int(input('Skriv inn din alder: '))
|
||||
if age < 16:
|
||||
return 50
|
||||
elif age >= 60:
|
||||
return 25
|
||||
|
||||
hasSpecialSocialStatus = boolInput('Er du student eller militær (J/N)?')
|
||||
return 25 if hasSpecialSocialStatus else 0
|
||||
|
||||
def discountBranch():
|
||||
choseDiscount = boolInput('Minipris 199,- kan ikke refunderes/endres\nØnskes dette (J/N)? ')
|
||||
if choseDiscount:
|
||||
discountPercent = evalDiscountPercent()
|
||||
print(f'Prisen på biletten blir: {440 - 440 * discountPercent/100}')
|
||||
else:
|
||||
print('Da tilbyr vi fullpris: 440,-')
|
||||
|
||||
|
||||
daysToTrip = int(input('Dager til du skal reise? '))
|
||||
|
||||
if daysToTrip >= 14:
|
||||
discountBranch()
|
||||
else:
|
||||
print('For sent for minipris; fullpris 440,-')
|
Loading…
Reference in New Issue