Hey guys, so i have an assignment. Its like this;
Create a python program about purchasing discounted children’s festival tickets, with a minimum purchase of 3 people. As well as the terms of purchase:
- If the child is aged 3 years and under, they will be given a 10% discount. 2. If the child is between 3-7 years old, they will be given a 13% discount. 3. If the child is aged 7 years and over, they will be given a 17% discount
So like im confused on where to start doing this. Can you help me with this? I heard my friends are using arrays but i dont understand it.
Hi - I would start by asking my friends to explain what they are doing. Tell them that the best way they can make sure they fully understand arrays is by explaining those to someone else! (You could also ask them why they are using arrays in a problem that is not at all suitable for array use, but is an exercise of conditionals.)
I second the suggestion about asking your friends to explain their
approach. Good for them and good for you. You don’t really want them
writing your programme, but understanding what they’re doing or thinking
A piece of terminology: Python’s general purpose array-like thing is
It appears to me that you’ve got a few things to do here:
Write some kind of loop which prompts the user for the age of a person
wanting a ticket. Collect these ages in a
list (the array).
When the user has finished entering ages, you now have information for
working out the ticket prices:
- total number of tickets, needed for “minimum purchase of 3 people”
- ages, used to figure out each ticket’s price
Your age condition will typically be tested with an
else type if-statement - it’s almost written out
for you in the sentence above
Don’t forget to print various things out as you go, that will help you
check that values are what you expect (or not).
Come back with some code and questions.