0
Python beginner
Hi, I'm really new to thus programming thing...not even sure what to dođ total = 0 while total > 3: print (total) total += 1 if total <= 3: break else: continue This is what I've got for finding ticket prices using while loop, break, continue thingy... Child under 3 years of age does not need to pay. Others cost 100 dollars per person. And i gotta find how much it will cost for five person (five input). I've got no idea where I got it wrong...đ Can anyone help me out...
3 Answers
+ 4
#try this
total = 0 #to initialize total variable
i = 0 # to run the loop
while i <5: # to take 5 inputs
age = int(input())
if age > 3:
total += 100
i += 1 # to increase variable i after each iteration.
print(total)
+ 1
I don't think you need to take 5 inputs you can simply take two inputs:
1st for total number of persons
2nd for number of persons who are <=3 years.
And then you have to subtract childrens from total numbers of persons to calculate the number of persons who are >3 years of age and then simply multiply it to $100.
edit]: if you will apply this logic, no for loop or while loop will be needed.
n=int(input("total persons: "))
s=int(input("persons<=3 years: "))
print("cost will be: ", (n-s)*100)
0
Thanks so much!!