0
I need help , how to make ticketing system to calculate the cost of tickets for persons older than 3 years
Hello
6 ответов
+ 1
#there:
def main() -> str:
print('Enter the ages for 5 persons')
arr = [int(input(f'Age {_} : '))for _ in range(5)]
price = 0
for i in arr:
if i>=3:
price+=100
return 'Total price for 5 persons is %d'%price
if __name__=='__main__':
print(main())
+ 1
Which course, which task?
Please link your code attempt
+ 1
Ticketing System:
1-Number of available tickets
2-Separated Prices for adults and children (as if ◉‿◉)
3- Total number of reservations
4- Amm... This will be the number of available tickets to sold
5- ... I guess the total sum of cash earned
.... 6- Final monetary earning and other thing that can be out of topic ಡ ͜ ʖ ಡ.
Anyway, I guess this is a code practice here and you should analyse carefully what this challenge wants ...
If you post an attempt of your here, I will give you a big help: by explaining the steps (•‿•).
+ 1
#Decima
total = 0
x = 0
while x < 5:
age = int(input())
if age >= 3:
total += 100
x += 1
print(total)
+ 1
Good start !
Make it more managable like:
people = [int(input()) for _ in range(5)]
# list of prices
prices = [(i>4 and 100)or 50 for i in people]
print(prices)
adults = [i for i in prices if i == 100]
kids = [i for i in prices if i == 50]
print(adults,sum(adults))
print(kids,sum(kids))
0
Thanks everyone it's done