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...

12th Jan 2022, 3:52 AM
Kaylee
Kaylee - avatar
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)
12th Jan 2022, 5:46 AM
Simba
Simba - avatar
+ 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)
12th Jan 2022, 4:13 AM
NEZ
NEZ - avatar
0
Thanks so much!!
12th Jan 2022, 4:48 AM
Kaylee
Kaylee - avatar