0
Help,I don't know what else I can write. I'm a little confused.🙀 Plz teach me master python. The problem↓ thanks a lot😭
You are making a ticketing system. The price of a single ticket is $100. For children under 3 years of age, the ticket is free. Your program needs to take the ages of 5 passengers as input and output the total price for their tickets. Code↓ total = 0 #your code goes here age=int(input()) for i in range(5) if age <=3: i+=1 continue
4 Respuestas
+ 7
I think you have a few errors, mostly in the logic, not the actual coding.
You don't output a total, you don't even calculate the total. Also, I'd check the idea behind your loop.
+ 4
the task is quite simple: (it is an exercise from the old `python for beginners` tutorial)
> create a variable that can hold a running counter, e.g. `count`
> use a loop to take 5 individual values (age) as input.
> fof each input do: check if age is greater or equal to 3
> if yes: increment `count` by 1
> if no: do nothing
> when all inputs are done and evaluated, output the variable `count` multiplied by 100, this the total cost of tickets.
+ 2
I think I read this question somewhere, but can remember where it is.
There is something missing in your description.
Your program needs to take the ages of 5 passengers as input…
How are the input separated? Is it a list, or a string each age are separated by comma?
Also as Ausgrindtube said, the errors are mostly logical.
"for i in range(5)" will produce 0, 1, 2, 3, 4.
If you want to loop through each item in a list, such as a shopping_list, it should be "for item in shopping_list".
Also you are required to output the total price for their tickets, you set the variable "total" in place, but your code didn’t utilize it.
+ 1
There are several errors in the code you provided:
1. Syntax Error: There's a missing colon after "for i in range(5)".
2. Logical Error: You're trying to input the age of passengers only once, outside of the loop. You need to input the age inside the loop for each passenger.
3. Incorrect Use of the " i" Variable: The use of "i" inside the loop is incorrect. You should be using "age" instead.
4. Incorrect Conditional Check: The "if age <= 3" check is outside of the loop, and you are not updating the "age" variable for each passenger.