| Let's use python to solve math problems. | |
| Question: Olivia has $23. She bought five bagels for $3 each. How much money does she have left? | |
| ```python | |
| def solution(): | |
| """Olivia has $23. She bought five bagels for $3 each. How much money does she have left?""" | |
| money_initial = 23 | |
| bagels = 5 | |
| bagel_cost = 3 | |
| money_spent = bagels * bagel_cost | |
| money_left = money_initial - money_spent | |
| result = money_left | |
| return result | |
| ``` | |
| ---------------- | |
| Question: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday? | |
| ```python | |
| def solution(): | |
| """Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?""" | |
| golf_balls_initial = 58 | |
| golf_balls_lost_tuesday = 23 | |
| golf_balls_lost_wednesday = 2 | |
| golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday | |
| result = golf_balls_left | |
| return result | |
| ``` | |
| ---------------- | |
| Question: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room? | |
| ```python | |
| def solution(): | |
| """There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?""" | |
| computers_initial = 9 | |
| computers_per_day = 5 | |
| num_days = 4 # 4 days between monday and thursday | |
| computers_added = computers_per_day * num_days | |
| computers_total = computers_initial + computers_added | |
| result = computers_total | |
| return result | |
| ``` | |
| ---------------- |