PYTHON SCRIPT
Your parents pay you $3 for each trash bag full of leaves you
take. If you can fill more than 10 bags in a month, they give you a
bonus of $20. Write a program that asks the user how many bags of
leaves they filled in the past month and prints out the total
amount of money they made.
For example, if someone fills 8 bags in a month, they would get
$24. But, if they fill 11 bags in a month, they would get 11 x $3 +
$20 = $53.
Sample Program Run
How many bags of leaves did you fill this month?
20
Great, you made $80.
Given below is the code in python:
bags = int(input("How many bags of leaves did you fill this month? : "))
if bags > 10:
money = bags * 3 + 20
else:
money = bags * 3
print("Great, you made $", money)
In the above code, we first took bags(int) as an input.
Then we checked if the number of bags is less than or equal to 10.
If it is greater than 10 then if statement is executed, where money = bags * 3 + 20
Else if it is less than 10 then money = bags * 3
Money is printed.
Get Answers For Free
Most questions answered within 1 hours.