Skip to content

Commit fd016fe

Browse files
committed
more examples
1 parent 3e698c2 commit fd016fe

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

questions/float_add.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
""" Print the result of `0.1 + 0.2 - 0.3`. """
2+
print(0.1 + 0.2 - 0.3)

questions/float_add_1.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

questions/int_program_1.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Compute how many potatoes I can buy."""
2+
3+
potatoes_in_store: int = 1000 # total number of potatoes
4+
cost_for_all_potatoes: int = 50 # cost if we would buy all potatoes
5+
my_money: int = 10 # the money I have
6+
7+
# Compute the cost of one single potato.
8+
cost_per_potato = cost_for_all_potatoes // potatoes_in_store
9+
print(f"One potato costs {cost_per_potato} RMB.")
10+
11+
# Compute the number of potatoes that I can buy with my money.
12+
i_can_buy: int = my_money / cost_per_potato
13+
print(f"I can buy {i_can_buy} potatoes.")

0 commit comments

Comments
 (0)