question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
Student: Anna made some bracelets. She used six strands of beads that cost $4 each, and some clasps that cost $1 each. How many clasps did Anna use if she spent a total of $28?
def solve() -> int: beads_cost = 4 clasps_cost = 1 total_cost = 28 clasps_num = (total_cost - beads_cost * 6) / clasps_cost result = int(clasps_num) return result
Katherine has 45 pencils. She gives 8 pencils to her friend. She then buys 3 pencils from the store. How many pencils does Katherine have left?
def solve() -> int: initial_pencils = 45 given_away = 8 new_pencils = 3 result = initial_pencils - given_away + new_pencils return result
A clothes store sold 300 items of clothing in a week. The store sold 120 tops and the rest were pants. If pants cost $20 each and tops cost $30 each, how much money did the store make in that week?
def solve() -> int: total_items_sold = 300 tops_sold = 120 pants_sold = total_items_sold - tops_sold tops_price = 30 pants_price = 20 total_sales = tops_sold*tops_price + pants_sold*pants_price result = total_sales return result
The Carter family has a dairy farm with 100 cows. Each cow produces 10 liters of milk per day. If they have a contract with a milk company to sell milk for $3 per liter, how much money can they make from selling milk in one month?
def solve() -> int: cows = 100 milk_per_cow = 10 price_per_liter = 3 milk_per_day = cows * milk_per_cow milk_per_month = milk_per_day * 30 money_per_month = milk_per_month * price_per_liter result = money_per_month return result
She works for 4 different students and spends 3 hours with each of them every week. However, she has to pay 10% of her weekly income as tax to the government. How much will she earn after paying the tax in a month?
def solve() -> int: weekly_income = 30 * 4 * 3 tax = weekly_income * 0.1 net_weekly_income = weekly_income - tax monthly_income = net_weekly_income * 4 result = monthly_income return result
Student: A car drives at a speed of 50 mph. How far will it travel in 2 hours?
def solve() -> int: speed = 50 time = 2 distance = speed * time result = distance return result
(See below for a sample python program solving the original question) Possible new questions and python programs are: Alice loves to collect stickers, but she needs to organize them in a new album. She has 4 packs of animal stickers, 3 packs of flower stickers, and 2 packs of star stickers. If a pack contains 5 sheets ...
def solve() -> int: animal_packs = 4 flower_packs = 3 star_packs = 2 sheets_per_pack = 5 stickers_per_sheet = 12 total_stickers = (animal_packs + flower_packs + star_packs) * sheets_per_pack * stickers_per_sheet result = total_stickers return result
A rectangle has a length of 15 cm and a width of 8 cm. What is the perimeter of the rectangle?
def solve() -> int: rectangle_length = 15 rectangle_width = 8 perimeter = 2*(rectangle_length+rectangle_width) result = perimeter return result
Student: Lily planted sunflowers in two patches of her yard. The first patch had 12 sunflowers, each with 8 petals. The second patch had 6 more sunflowers than the first patch, each with 10 petals. How many petals did Lily's sunflowers have in total?
def solve() -> int: first_patch_sunflowers = 12 first_patch_petals_per_sunflower = 8 second_patch_sunflowers = first_patch_sunflowers + 6 second_patch_petals_per_sunflower = 10 total_petals = (first_patch_sunflowers * first_patch_petals_per_sunflower) + (second_patch_sunflowers * second_patch_petals...
A square has a perimeter of 36 cm. What is the area of the square?
def solve() -> int: perimeter = 36 side_length = perimeter / 4 area = side_length ** 2 result = area return result
``` A rectangular pool is 40 feet long and 20 feet wide. If the depth is 10 feet, what is the volume of water in the pool?
def solve() -> int: pool_length = 40 pool_width = 20 pool_depth = 10 pool_volume = pool_length * pool_width * pool_depth result = pool_volume return result
A car travels at a speed of 60 km/hr for the first half of a trip, and then at 40 km/hr for the second half of the trip. If the total distance traveled is 480 km, how long did the trip take in hours?
def solve() -> int: distance = 480 speed_first_half = 60 speed_second_half = 40 time_first_half = distance/(2*speed_first_half) time_second_half = distance/(2*speed_second_half) total_time = time_first_half + time_second_half result = total_time return result
A class of 24 students collected $1080 for a charity walk. They decided to split the money equally among 4 different charities. How much money did each charity receive?
def solve() -> int: money_per_charity = 1080 / 4 result = money_per_charity return result
Michael has 5 $20 and 7 $5 bills. Sophia has 3 $10, 2 $20 and 6 $5 bills. How much more money does Michael have than Sophia?
def solve() -> int: michael_money = (5*20) + (7*5) sophia_money = (3*10) + (2*20) + (6*5) difference = michael_money - sophia_money result = difference return result
Student: 10. Sarah sold 12 pens for 5 dollars each. How much money did she make in total?
def solve() -> int: pens = 12 price = 5 total = pens * price result = total return result
Lily and Chloe each had $9 to spend. They pooled their money together to buy a book for $15. They also purchased two snacks for $2 each and divided them evenly. How much did Lily spend on the snacks?
def solve() -> int: lily_money = 9 chloe_money = 9 book_cost = 15 snack_cost = 2 total_money = lily_money + chloe_money remaining_money = total_money - book_cost snack_quantity = 2 snack_cost_each = snack_cost / snack_quantity lily_spent = snack_cost_each result = ...
Bob is currently twice as old as Ann. Ann is currently 12. If Bob is currently 48, what will be their total age in 12 years?
def solve() -> int: ann_age = 12 bob_age = 48 total_age = ann_age + bob_age + 24 result = total_age return result
An artist made 300 sketches. He put them in folders of fifty and sold each folder for $12. He also made 250 paintings and put them in frames to sell each frame for $60. If the artist sold all his art, how much did he earn in total?
def solve() -> int: num_sketches = 300 num_folders = num_sketches // 50 folder_price = 12 total_folder_price = num_folders * folder_price num_paintings = 250 frame_price = 60 total_frame_price = num_paintings * frame_price total_earnings = total_folder_price + total_frame_price...
A car dealer has 48 cars on their lot. They sold 25% of the cars last month. How many cars are left on the lot?
def solve() -> int: original_cars_on_lot = 48 cars_sold_last_month = original_cars_on_lot * 0.25 cars_left_on_lot = original_cars_on_lot - cars_sold_last_month result = cars_left_on_lot return result
A triangular prism has a base of 9 meters and a height of 7 meters. If the volume of the prism is 189 cubic meters, what is the length of the third side of the triangle?
def solve() -> int: base = 9 height = 7 volume = 189 base_area = 0.5 * base * height prism_height = volume / base_area third_side = ((prism_height ** 2) + (base ** 2)) ** 0.5 result = third_side return result
If John drives at an average speed of 60 miles per hour for 5 hours, how far does he travel in total?
def solve() -> int: speed = 60 time = 5 distance = speed * time result = distance return result
For a biology project, Sarah collected 10 jars of soil samples that weigh 8 ounces each. How much does the whole collection of jars weighs?
def solve() -> int: number_of_jars = 10 weight_of_each_jar = 8 weight_of_jars = number_of_jars * weight_of_each_jar result = weight_of_jars return result
Student: Frank runs a barber shop. Every month he spends a seventh of his budget on hair products, a fifth of his budget on electricity and water, and the rest of his budget on rent and salaries. If his budget is $2800 and he uses it up every month, how much is he spending on rent and salaries?
def solve() -> int: budget = 2800 hair_products = budget / 7 electricity_and_water = budget / 5 rent_and_salaries = budget - hair_products - electricity_and_water result = rent_and_salaries return result
Olivia has a bag of 100 candy pieces. She eats 35 candies, her brother eats 10 candies, she finds 5, and she gets 20 more candies from her parents. How many candies does Olivia have in the bag now?
def solve() -> int: candies_in_bag = 100 olivia_eats = 35 brother_eats = 10 olivia_finds = 5 candies_from_parents = 20 candies_in_bag = candies_in_bag - olivia_eats candies_in_bag = candies_in_bag - brother_eats candies_in_bag = candies_in_bag + olivia_finds candies_in_bag = can...
Frank bought a total of 24 erasers. He bought 8 packages, with each package containing an equal amount of erasers. How many erasers were in each package?
def solve() -> int: total_erasers = 24 package_num = 8 erasers_in_each_package = total_erasers / package_num result = erasers_in_each_package return result
John runs 5 km every day for 30 days. How many kilometers has he run in total?
def solve() -> int: daily_distance = 5 total_days = 30 total_distance = daily_distance * total_days result = total_distance return result
A restaurant sells 800 meals on its opening day and ultimately sells 5 times as many meals during the year. If the restaurant owner keeps 40% of the profits and the restaurant costs $50,000 to start, how much profit does the owner make?
def solve() -> int: opening_day_meals = 800 yearly_meals = 5 * opening_day_meals start_cost = 50000 total_revenue = yearly_meals * 20 total_profit = total_revenue * 0.6 - start_cost result = total_profit return result
A pizza has 8 slices. Lisa, her brother, and her parents want to share a pizza equally. How many slices will each person get?
def solve() -> int: slices = 8 people = 4 slices_per_person = slices / people result = slices_per_person return result
Ava and Ethan order smoothies for $6, muffins for $4, and 4 cookies for $1 each. The tax is $2. Later, Ava decides to order 2 more muffins and 1 more smoothie as she is still hungry. How much change should they get from $25?
def solve() -> int: smoothie_price = 6 muffin_price = 4 cookie_price = 1 tax = 2 total_cost = (smoothie_price + muffin_price + (4 * cookie_price)) + tax additional_muffin_cost = 2 * muffin_price additional_smoothie_cost = 1 * smoothie_price total_cost += additional_muffin_cost ...
Cindy has to read a book of 150 pages. She read 30 pages every day. How many days will it take for her to finish the book?
def solve() -> int: days_required = 150/30 result = days_required return result
Student: There are 45 ducks at a pond. Some ducks left the pond and 20 new ducks joined it. How many ducks did the pond gain?
def solve() -> int: ducks = 45 ducks_left = 15 ducks_joined = 20 final_ducks = ducks - ducks_left + ducks_joined gain = final_ducks - ducks result = gain return result
Leila has 20 stickers. She trades three stickers with Nina for four stickers and then gives two stickers to Sam. How many stickers does Leila have now?
def solve() -> int: stickers = 20 stickers = stickers - 3 + 4 stickers = stickers - 2 result = stickers return result
A company has 250 employees. 75% of them work in the office and the rest work remotely. How many employees work remotely?
def solve() -> int: employees = 250 office_employees = employees * 0.75 remote_employees = employees - office_employees result = remote_employees return result
Tyler obtained 80% on a math test. He had 5 mistakes. How many questions were on the test?
def solve() -> int: total_items = 0 score = 80 errors = 5 total_items = (score * 100) / (100 - errors) result = total_items return result
Jack has $1000 in his bank account. He spends $400 in the first week. What is the remaining amount in his account and what percentage of the original amount is it?
def solve() -> int: original_amount = 1000 expense = 400 remaining_amount = original_amount - expense percentage_remaining = (remaining_amount / original_amount) * 100 result = remaining_amount, percentage_remaining return result
Julie and Robert planted banana trees in their garden. At the start, Julie’s tree yielded 17 bananas and Robert’s tree yielded 13. Over the course of the next 5 years, Julie’s tree grew three times as much as it did in the first year, and Robert’s tree grew 6 times as much as it did in the first year. How many bananas ...
def solve() -> int: JulieYears1 = 17 JulieYears2 = 3*JulieYears1 JulieYears3 = 3*JulieYears2 JulieYears4 = 3*JulieYears3 JulieYears5 = 3*JulieYears4 RobertYears1 = 13 RobertYears2 = 6*RobertYears1 RobertYears3 = 6*RobertYears2 RobertYears4 = 6*RobertYears3 RobertYears5 ...
A triangle has a base of 8 cm and a height of 6 cm. What is the area of the triangle?
def solve() -> int: base = 8 height = 6 area = (base * height) / 2 result = area return result
During a charity walkathon, the high school students raised $400 on Monday. They collected $15 less than three times that amount the next day, and the following day they collected an additional $135. What was their total earnings?
def solve() -> int: monday_earnings = 400 next_day_earnings = (3 * monday_earnings) - 15 following_day_earnings = next_day_earnings + 135 total_earnings = monday_earnings + next_day_earnings + following_day_earnings result = total_earnings return result
Henry filled a jar with candy and counted 245 pieces. He divided the candy equally into 7 smaller bags. How many pieces of candy were in each bag?
def solve() -> int: jar = 245 bags = 7 candy_per_bag = jar / bags result = candy_per_bag return result
A cake recipe requires 2 cups of flour, 3 eggs, and 1 tablespoon of sugar. If a baker wants to make 3 cakes, how many cups of flour and eggs and tablespoons of sugar will she need in total to make the cakes?
def solve() -> int: flour_per_cake = 2 egg_per_cake = 3 sugar_per_cake = 1 number_of_cakes = 3 total_flour_required = flour_per_cake * number_of_cakes total_eggs_required = egg_per_cake * number_of_cakes total_sugar_required = sugar_per_cake * number_of_cakes result = total_flour_require...
Megan has a small jewelry shop. She started the day with 20 gold necklaces and 15 silver bracelets. Later on, she counted only 16 necklaces and 12 bracelets. Her staff told her that they had to remove 4 necklaces and 1 bracelet due to scratches on the jewelry. How many pieces of jewelry were sold today?
def solve() -> int: necklaces_start = 20 bracelets_start = 15 necklaces_counted = 16 bracelets_counted = 12 necklaces_removed = 4 bracelets_removed = 1 necklaces_sold = necklaces_start - necklaces_counted + necklaces_removed bracelets_sold = bracelets_start - bracelets_cou...
Student: John spent $150 on groceries and that was 3/5 of his salary. How much did John earn in total?
def solve() -> int: spent = 150 fraction = 3/5 total_salary = spent / fraction result = total_salary return result
Jordan wants to buy a new shirt and pants for a job interview. The shirt costs $40 and pants cost $60. He plans on tipping 10% for the salesperson. How much will he spend in total?
def solve() -> int: shirt_cost = 40 pants_cost = 60 tip_percent = 10 total_cost = shirt_cost + pants_cost tip_amount = total_cost * (tip_percent/100) total_cost_with_tip = total_cost + tip_amount result = total_cost_with_tip return result
10. Susan needs 5 avocados to make 1 soup. On Monday she makes 4 soups. On Tuesday she makes the same amount of soups as Monday. How many avocados did she need to make all these soups?
def solve() -> int: a_needed = 0 soups = 4 a_each_soup = 5 for i in range(2): a_needed += soups * a_each_soup soups *= 2 result = a_needed return result
A factory produces 1000 bottles per day. If 10% of them are defective, how many are not defective?
def solve() -> int: defective_bottles = (10/100)*1000 non_defective_bottles = 1000 - defective_bottles result = non_defective_bottles return result
Julia collected 114 leaves in total, out of which 4/9 were red leaves. How many red leaves did Julia collect?
def solve() -> int: totalLeaves = 114 redLeaves = 0 redLeaves = totalLeaves * 4/9 result = redLeaves return result
Jack had 64 toy cars which he shared equally between his two cousins. He played with 1/6 of the remaining cars and lost a third of the rest. His aunt then presented him with eight times the number of toy cars he lost. How many toy cars does Jack have now?
def solve() -> int: toy_cars = 64 cousins = 2 remaining_cars = toy_cars / cousins played_cars = remaining_cars / 6 remaining_cars -= played_cars lost_cars = remaining_cars / 3 remaining_cars -= lost_cars presented_cars = lost_cars * 8 total_cars = remaining_cars + presented...
A classroom has many erasers twice as many as the number of pencils. If there are 24 pencils in the class, how many erasers are there in the class?
def solve() -> int: pencils = 24 erasers = pencils * 2 result = erasers return result
At the gas station, attendant Tom's team filled a large tank with 20,000 gallons of fuel. Over the next 8 hours, they pumped fuel into cars at a rate of 2,500 gallons per hour. For the next 3 hours, they added more fuel to the tank at a rate of 1,200 gallons per hour. How many gallons of fuel were left in the tank at t...
def solve() -> int: tank_capacity = 20000 fuel_pumped_per_hour = 2500 additional_fuel_per_hour = 1200 fuel_pumped = fuel_pumped_per_hour * 8 additional_fuel = additional_fuel_per_hour * 3 fuel_left = tank_capacity - fuel_pumped - additional_fuel result = fuel_left return r...
Jordan scours through his pockets and finds a $5 bill, two $1 bills, 12 quarters, 15 dimes, 10 nickels, and 50 pennies. How much money does Jordan have in total?
def solve() -> int: five_bill = 5 one_bill = 2 quarters = 12 dimes = 15 nickels = 10 pennies = 50 total_money = (five_bill * 5) + (one_bill * 1) + (quarters * 0.25) + (dimes * 0.10) + (nickels * 0.05) + (pennies * 0.01) result = total_money return result
A car drives at a speed of 55 miles per hour. How long will it take the car to travel 330 miles?
def solve() -> int: distance = 330 speed = 55 time = distance / speed result = time return result
John and Sam each have 800 supercomputers in their stores. Due to an upgrade, John was able to upgrade 25% of his computers in 2016 while Sam was only able to upgrade 15% of his computers that same year. How many computers did each of them have in 2016?
def solve() -> int: total_computers_john = 800 percentage_upgrade_john = 0.25 total_upgrade_john = total_computers_john * percentage_upgrade_john total_computers_sam = 800 percentage_upgrade_sam = 0.15 total_upgrade_sam = total_computers_sam * percentage_upgrade_sam total_computers_john_20...
Sarah has 4 bags of flour and each bag contains 2 kg of flour. She uses 500 grams of flour to bake a cake. How many cakes can she bake?
def solve() -> int: num_bags = 4 flour_per_bag = 2 flour_per_cake = 0.5 total_flour = num_bags * flour_per_bag num_cakes = total_flour // flour_per_cake result = num_cakes return result
Jessica has only completed 2 marathons in her life. Lauren has completed 9 times as many marathons as Jessica, and Tyler has completed 15 more marathons than Lauren. If Jessica wants to say that she has completed as many marathons as Tyler and plans to run 1 marathon every 6 months, how many years would it take Jessica...
def solve() -> int: jessica_marathons = 2 lauren_marathons = 9 * jessica_marathons tyler_marathons = lauren_marathons + 15 jessica_goal = tyler_marathons marathons_per_year = 2 years_to_achieve_goal = (jessica_goal - jessica_marathons) / marathons_per_year result = years_to_achiev...
A store is offering a buy two, get one free deal on shirts that cost $25 each. How much would six shirts cost with this discount?
def solve() -> int: shirt_cost = 25 total_cost = (2 * shirt_cost * 3) + shirt_cost result = total_cost return result
Alex has 50 marbles and wants to divide them equally between his 2 siblings. How many marbles will each sibling get?
def solve() -> int: marbles = 50 siblings = 2 marbles_per_sibling = marbles / siblings result = marbles_per_sibling return result
A factory produces five times as many blue pens as red pens. If the factory produces 1200 red pens per day, how many pens does it produce per day in total?
def solve() -> int: red_pens = 1200 blue_pens = 5 * red_pens total_pens = red_pens + blue_pens result = total_pens return result
Emily wants to swim a 5-mile race next summer. She knows that each month, she can increase her swimming distance by 0.5 miles from the previous month. If she can swim 1 mile during the first month of training, how many months before the race should she start training to ensure she can swim far enough?
def solve() -> int: race_distance = 5 monthly_increase = 0.5 starting_distance = 1 num_months = 0 while starting_distance < race_distance: starting_distance += monthly_increase num_months += 1 result = num_months return result
A student needs to study for 6 hours a day for 10 days. If she has already studied for 2 days, how many more hours does she need to study?
def solve() -> int: hours_per_day = 6 total_days = 10 days_already_studied = 2 hours_already_studied = hours_per_day * days_already_studied hours_left_to_study = hours_per_day * (total_days - days_already_studied) result = hours_left_to_study return result
The price of a pencil is $0.75. If you pay with a $5 bill, how many pencils can you buy?
def solve() -> int: price_per_pencil = 0.75 amount_paid = 5 num_pencils = amount_paid // price_per_pencil result = num_pencils return result
Student: Michael runs around a circular track with a length of 600m twice in 10 minutes. What is his average speed?
def solve() -> int: track_length = 600 laps = 2 time = 10 time_seconds = time * 60 total_distance = track_length * laps average_speed = total_distance / time_seconds result = average_speed return result
Student: A boat started its journey with 500 gallons of drinking water on board. After the first day, the sailors had drunk 1/5 of the water. They drank 1/4 of the remaining water over the next two days. Calculate the number of gallons of water left on the boat right after that.
def solve() -> int: water_on_board = 500 water_drank_day_1 = 1/5 water_drank_day_2_3 = 1/4 water_left = water_on_board * (1 - water_drank_day_1) * (1 - water_drank_day_2_3) result = water_left return result
Here are some possible questions and programs: Maria collects stickers and puts them in her album. She has 12 pages in her album and each page can fit 9 stickers. She already filled 7 pages and has 23 stickers left. How many more stickers does she need to complete her album?
def solve() -> int: total_stickers = 12 * 9 stickers_maria = 7 * 9 + 23 stickers_needed = total_stickers - stickers_maria result = stickers_needed return result
If a construction company needs five times as much steel as wood to build a house, and it needs a total of 100 units of building materials, how many units of steel does it need?
def solve() -> int: wood = 100 / (1 + 5) steel = 5 * wood result = steel return result
Q3: It takes 2.5 minutes to boil a pot of water on Sam's stove. How many minutes will it take to boil 4 pots of water?
def solve() -> int: time_to_boil_1 = 2.5 total_time = time_to_boil_1 * 4 result = total_time return result
There were 100 pieces of candy to be divided evenly between 10 children. How many pieces of candy did each child get?
def solve() -> int: num_candy = 100 num_children = 10 candy_each = num_candy / num_children result = candy_each return result
Student: In a grocery store, there are 24 apples in a basket. The store sells 5 baskets of apples each day. How many apples are sold in a week?
def solve() -> int: apples_in_basket = 24 baskets_sold = 5 days_in_week = 7 apples_sold_day = apples_in_basket * baskets_sold apples_sold_week = apples_sold_day * days_in_week result = apples_sold_week return result
Andrew is one-third of Kylie's age and Kylie is one-fourth of Olivia's age. If Olivia is 24 years old, how old is Andrew?
def solve() -> int: olivia_age = 24 kylie_age = olivia_age * 4 andrew_age = kylie_age / 3 result = andrew_age return result
Tom bought 4 shirts for $20 each and 3 shorts for $15 each. If he had a coupon for 10% off his total purchase, what was the final amount he paid?
def solve() -> int: shirt_cost = 20 num_shirts = 4 short_cost = 15 num_shorts = 3 discount_rate = 0.1 subtotal = shirt_cost*num_shirts + short_cost*num_shorts discount = discount_rate*subtotal total_cost = subtotal - discount result = total_cost return result
Jack is running a marathon that is 42 km long. If he runs at a pace of 10 km/h and takes a 5-minute break every 4 km, how long will it take him to complete the marathon?
def solve() -> int: marathon_distance = 42 pace = 10 break_distance = 4 break_time = 5 total_breaks = marathon_distance // break_distance total_break_time = total_breaks * break_time total_time = marathon_distance / pace total_time += total_break_time result ...
Walter runs a video game center and charges $20 per person plus additional $2 for every hour they play. If 12 people come to play for 5 hours, how much money, in dollars, does he earn?
def solve() -> int: total_cost = 20 num_person = 12 num_hours = 5 cost_person = 2 total_cost = total_cost + (num_person * cost_person * num_hours) result = total_cost return result
Possible new questions and programs: In a school field trip, each student can choose one of the three activities: hiking, canoeing, or museum. The hiking costs $10 per student, the canoeing costs $15 per student, and the museum costs $12 per student. The school also pays $5 per student for transportation. If there are ...
def solve() -> int: n = 60 hiking_cost = 10 canoeing_cost = 15 museum_cost = 12 transport_cost = 5 museum_students = n - 20 - 15 hiking_total = hiking_cost * 20 canoeing_total = canoeing_cost * 15 museum_total = museum_cost * museum_students transport_total = transport_cost * n ...
A store has 200 different types of candy for sale. A customer purchased 20 types on their first visit and 25 on their second visit. If they want to try every type of candy in the store, how many types should they purchase on average during their third and fourth visits combined?
def solve() -> int: total_types = 200 first_visit = 20 second_visit = 25 types_remaining = total_types - first_visit - second_visit average_per_visit = types_remaining / 2 result = average_per_visit return result
Student: Jake wants to buy a new phone that costs $800. He only has $200 saved up. If he saves $25 every week, how many weeks will it take him to save enough money to buy the phone?
def solve() -> int: phone_cost = 800 saved = 200 save_per_week = 25 difference = phone_cost - saved weeks = difference / save_per_week result = weeks return result
A store has 500 books in stock. Each book costs $15. It has allocated 30 books for staff use and 20 books for display. How much money will the store make if it sells all the remaining books at a 20% discount?
def solve() -> int: book_cost = 15 allocated_books = 30 + 20 remaining_books = 500 - allocated_books total_cost = remaining_books * book_cost discount = total_cost * 0.2 total_cost -= discount result = total_cost return result
-It is possible to use **random numbers or choice** to generate different questions. But make sure the questions are **reasonable and consistent**. Here is a good tutorial on how to use the random and choice module: https://www. w3schools.com/python/python_module_random. asp Possible questions and programs: Tim baked a...
def solve() -> int: muffins_given = 24 - 6 neighbors = muffins_given // 3 result = neighbors return result
At 35, John is 5/4 the age of his wife Maria. What would be their average age in 12 years?
def solve() -> int: john_age = 35 maria_age = (4/5) * john_age average_age = (john_age + maria_age) / 2 average_age_in_12_years = average_age + 12 result = average_age_in_12_years return result
Student: Gary, Michael, and Jacob buy apples. Gary bought 7 apples, Michael bought 9 apples, and Jacob bought 11 apples. How many apples did they buy in total?
def solve() -> int: gary_apples = 7 michael_apples = 9 jacob_apples = 11 total_apples = gary_apples + michael_apples + jacob_apples result = total_apples return result
While on a safari trip in Africa, it rained on 3 days out of 7 for Sarah and her family. The amount of rainfall was 4 cm, 6 cm, and 3 cm on each respective day. During the same week, it rained 20 cm at her home. How much less rain did Sarah experience while on safari?
def solve() -> int: safari_rainy_days = 3 day1_rainfall = 4 day2_rainfall = 6 day3_rainfall = 3 safari_total_rainfall = day1_rainfall + day2_rainfall + day3_rainfall home_rainfall = 20 rainfall_difference = home_rainfall - safari_total_rainfall result = rainfall_...
Student: A warehouse stores goods in boxes. Each box contains 12 items. If the warehouse needs to store 336 items, how many boxes does it need?
def solve() -> int: items_per_box = 12 total_items = 336 boxes = 0 boxes = total_items // items_per_box result = boxes return result
san and Emily together can complete a task in 12 days. Susan alone takes 20 days to complete the task. How long does it take Emily alone to complete the task?
def solve() -> int: susan_days = 20 together_days = 12 emily_fraction = together_days / susan_days - 1 emily_days = 1 / emily_fraction result = emily_days return result
Rachel is knitting a sweater that requires 10 balls of wool. If she can use one ball of wool every hour, how many hours will it take her to complete the sweater?
def solve() -> int: balls_of_wool = 10 hours_per_ball = 1 total_hours = balls_of_wool * hours_per_ball result = total_hours return result
At a restaurant, Mia can prepare a meal for four people in 30 minutes. Nathan can prepare the same meal in half the time it takes Mia. Olivia can prepare a meal in 20 minutes less than twice the time it takes Nathan. If Mia and Olivia prepare the meal together, how much faster can they make the meal compared to Nathan?
def solve() -> int: mia_time = 30 nathan_time = mia_time / 2 olivia_time = (2 * nathan_time) - 20 mia_and_olivia_time = 1 / ((1 / mia_time) + (1 / olivia_time)) nathan_time_difference = nathan_time - mia_and_olivia_time result = nathan_time_difference return result
If a package of 12 pens costs $6.60, how much would 24 pens cost?
def solve() -> int: pens_in_package = 12 package_cost = 6.60 pens_needed = 24 cost = (pens_needed / pens_in_package) * package_cost result = cost return result
In two years, Mia will be six times as old as Noah. If Noah is currently four years old, how old is Mia?
def solve() -> int: noah_age = 4 mia_age_in_two_years = 6 * (noah_age + 2) mia_age = mia_age_in_two_years - 2 result = mia_age return result
There is a pizza with a diameter of 12 inches. What is the area of the pizza?
def solve() -> int: radius = 12 / 2 area = 3.14 * radius**2 result = round(area, 2) return result
am and Leo go to a farm to pick apples and pears. Sam picks 18 apples and 15 pears. Leo decides to pick 4 pears for every 3 apples Sam picks. Due to health reasons, Leo decides to eat 8 pears and 6 apples after meeting his own goal. How many fruits do they have altogether now?
def solve() -> int: leo_pears = (4/3) * 18 leo_apples = (3/3) * 18 leo_pears_eaten = 8 leo_apples_eaten = 6 leo_pears_kept = leo_pears - leo_pears_eaten leo_apples_kept = leo_apples - leo_apples_eaten sam_apples = 18 sam_pears = 15 total_apples = sam_apples + ...
A pool is 20 meters long and 10 meters wide. If the pool is 3 meters deep, what is the volume of water needed to fill the pool?
def solve() -> int: length = 20 width = 10 depth = 3 volume = length * width * depth result = volume return result
raj decided to buy 4 bottles of snacks for a party. Each bottle contains 5 packs of snacks. Each pack of snacks costs two-thirds of the price per bottle. The total cost of the 4 bottles is $30. How much does one pack of snacks cost?
def solve() -> int: cost_per_bottle = 0 cost_per_pack = 0 cost_per_bottle = 30/4 cost_per_pack = cost_per_bottle * 2/3 result = cost_per_pack return result
A company has 5 teams of 8 employees each. If they need to layoff 6 employees, how many employees will be left in each team?
def solve() -> int: total_teams = 5 employees_per_team = 8 total_employees = total_teams * employees_per_team employees_laidoff = 6 employees_left_per_team = (total_employees - employees_laidoff) // total_teams result = employees_left_per_team return result
Tony wants to buy a gift from a box that contains 3 pencils, 4 mugs, and 6 erasers. What is the least number of items Tony must choose to get at least 1 of each item?
def solve() -> int: pencils = 3 mugs = 4 erasers = 6 items_needed = max(pencils, mugs, erasers) result = items_needed return result
Rachel rode her bike for 30 minutes, which is two-thirds as long as Karen rode her bike. If Emily rode her bike for 4 times as long as Karen, how many minutes did Emily ride her bike for?
def solve() -> int: rachel_time = 30 karen_time = rachel_time * 3 / 2 emily_time = karen_time * 4 result = emily_time return result
How many pencils does he have left?
def solve() -> int: total_pencils = 39 broken_pencils = 9 change = broken_pencils * 1 result = total_pencils - change return result
Possible questions and programs: Kelly earns $12 per hour as a babysitter. She babysits for two families, one for 8 hours on Monday and Wednesday, and the other for 6 hours on Tuesday and Thursday. How much money does she make in a week?
def solve() -> int: hourly_rate = 12 hours_family_1 = 8 * 2 hours_family_2 = 6 * 2 total_hours = hours_family_1 + hours_family_2 total_income = total_hours * hourly_rate result = total_income return result
Maria went shopping and bought a dress for $70, shoes for $45, and a purse for $25. What percent of $150 did she spend in total?
def solve() -> int: total_spent = 70 + 45 + 25 total_budget = 150 percent_spent = total_spent/total_budget*100 result = percent_spent return result
Mia and Max are saving money for a trip. Mia has $120 in her piggy bank and Max has $80 in his. Every week, they each add $10 to their savings. How many weeks will it take them to save enough money for the trip that costs $500?
def solve() -> int: mia_start = 120 mia_weekly = 10 max_start = 80 max_weekly = 10 target = 500 weeks = 0 savings = mia_start + max_start while savings < target: savings = savings + mia_weekly + max_weekly weeks = weeks + 1 result = f'It will...
Emily has 24 cupcakes. She gives away one-quarter of the cupcakes to her neighbor. Her neighbor then eats 6 cupcakes. If Emily has 15 cupcakes left, how many cupcakes did she have at first?
def solve() -> int: cupcakes_at_first = 24 cupcakes_given_away = cupcakes_at_first / 4 cupcakes_left = cupcakes_at_first - cupcakes_given_away cupcakes_eaten = 6 final_cupcakes_left = cupcakes_left - cupcakes_eaten result = final_cupcakes_left return result
Carl gathered 25 shells at the beach. He painted 5 shells orange and 8 shells blue. He then divided the remaining shells equally into 2 groups, and painted them yellow and green. How many shells did he paint yellow?
def solve() -> int: total_shells = 25 orange_shells = 5 blue_shells = 8 remaining_shells = total_shells - orange_shells - blue_shells yellow_green_shells = remaining_shells / 2 yellow_shells = yellow_green_shells result = yellow_shells return result
A store has 200 bottles of water that it needs to sell to get exactly $500. They want to sell each bottle for $2, but after few days, they realize they need to reduce the price to $1.75 to sell all of the bottles. How much money will they get in total?
def solve() -> int: total_bottles = 200 original_price = 2 new_price = 1.75 required_money = 500 original_money = total_bottles * original_price new_money = total_bottles * new_price difference = original_money - new_money final_money = required_money - difference ...
A fitness center charges $50 for a monthly membership and an additional $5 for each fitness class attended. If someone attends 3 classes in a month, how much will they pay?
def solve() -> int: membership_cost = 50 class_cost = 5 classes_attended = 3 total_cost = membership_cost + (class_cost * classes_attended) result = total_cost return result