+ 2
Need help with while loops!
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. Sample Input 18 24 2 5 42 Sample Output 400 To solve this do I start with: X = int(input ()) ?
11 odpowiedzi
+ 5
count , sum= 0,0
while count<5:
age = input()
if age>3:
sum+=100
count+=1
print ('Total price is ', sum)
+ 2
You know exactly how many inputs so you'd take your input in a for loop.
+ 2
Your x=int(input()) will work now look at "In range" for python.
Id probably start with
x=0
x += int(input())
in some type of loop... if the number of inputs is static.
+ 2
Sum=0
for i in range(5):
age=int(input())
if age>3:
Sum+=100
print(Sum)
+ 2
Sum=0
i=0
while i<5:
Age=int(input())
if Age>3:
Sum+=100
i+=1
print(Sum)
+ 1
for < 5 times >:
age = the input
if age is less than 3:
free
else
charge em (add to total)
0
Slick could you show me an example please!
0
Manav Roy I asked for help, not whatever this is.