Skip to content

Commit 6fb498f

Browse files
Add files via upload
1 parent 364a798 commit 6fb498f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pyhton_study_1/page17/script.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apple_price = 2
2+
# Assign 10 to the money variable
3+
money = 10
4+
5+
input_count = input('How many apples do you want?: ')
6+
count = int(input_count)
7+
total_price = apple_price * count
8+
9+
print('You will buy ' + str(count) + ' apples')
10+
print('The total price is ' + str(total_price) + ' dollars')
11+
12+
left_money = money - total_price
13+
# Add control flow based on the comparison of money and total_price
14+
if money > total_price:
15+
print("You have bought " + str(count) + " apples")
16+
print("You have " + str(left_money) + " dollars left")
17+
18+
elif money == total_price:
19+
print("You have bought " + str(count) + " apples")
20+
print("Your wallet is now empty")
21+
22+
else:
23+
print("You do not have enough money")
24+
print("You cannot buy that many apples")

0 commit comments

Comments
 (0)