question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
Jane invested $8000 at a 5% annual interest rate for a year. What is the total amount of money at the end of the year?
def solve() -> int: p = 8000 r = 0.05 t = 1 compound_interest = p * (1 + r) ** t result = compound_interest return result
In a dance competition, a group of 12 dancers performed on stage. 8 of them wore blue costumes while the rest wore red. If each green costume corresponds to 3 red costumes, how many green costumes are needed to match the blue ones?
def solve() -> int: blue_costumes = 8 red_costumes = 12 - blue_costumes green_costumes = blue_costumes / 3 result = green_costumes return result
A group of friends went to a movie that cost $9 per ticket. If they bought 4 tickets, how much did they spend in total?
def solve() -> int: ticket_price = 9 number_of_tickets = 4 total_cost = ticket_price * number_of_tickets result = total_cost return result
Student: Juan has 3 bottles of soda. Each bottle contains 500 ml of soda. He gives 40% of the soda to his friends. He drinks 300 ml of soda and gives 10% of the remaining soda to his parents. How many ml of soda are left?
def solve() -> int: bottle_1 = 500 bottle_2 = 500 bottle_3 = 500 friends_soda = (bottle_1 + bottle_2 + bottle_3) * 0.4 juan_soda = 300 parents_soda = (bottle_1 + bottle_2 + bottle_3 - juan_soda - friends_soda) * 0.1 result = (bottle_1 + bottle_2 + bottle_3 - juan_soda - friends_soda - parent...
A ladder is 19 meters long. If the ladder touches the top of a 15 meter building, what is the distance between the bottom of the building and the base of the ladder?
def solve() -> int: distance_between_building_and_ladder_base = (19**2 - 15**2)**0.5 result = distance_between_building_and_ladder_base return result
A rectangle has a length of 10 inches and a width of 6 inches. What is the area of the rectangle?
def solve() -> int: area = 10*6 result = area return result
Possible questions and programs are: A farmer has 96 chickens and 12 ducks. He sells one-fourth of his chickens and one-third of his ducks. How many birds does he have left?
def solve() -> int: chickens = 96 ducks = 12 chickens_sold = chickens / 4 ducks_sold = ducks / 3 chickens_left = chickens - chickens_sold ducks_left = ducks - ducks_sold birds_left = chickens_left + ducks_left result = birds_left return result
A pizza restaurant has a pie with 12 slices. If 2/3 of the pie is eaten, how many slices are left?
def solve() -> int: slices = 12 eaten = slices * (2/3) left = slices - eaten result = left return result
Emily is the tallest person in her class. She is one and a half feet taller than Grace, who is half a foot taller than Amy, who is two feet taller than Zoe. If Zoe is 4 feet 8 inches tall, how tall is Emily?
def solve() -> int: zoe_height = 4*12 + 8 amy_height = zoe_height + 2*12 grace_height = amy_height + 0.5*12 emily_height = grace_height + 1.5*12 result = emily_height/12 return result
Jackson is hosting a BBQ for his friends. He wants to make sure there's enough food for everyone, so he asks his mother to buy 2 pounds of meat for his friend Emily, 3 pounds for his friend Luke, and 4 pounds for his friend Max. In case there are more guests, Jackson's mother decides to buy one additional pound of meat...
def solve() -> int: emily = 2 luke = 3 max = 4 total_friends = emily + luke + max total_meat = emily + luke + max + total_friends jackson = total_meat / (total_friends + 1) total_meat += jackson total_meat = round(total_meat, 1) result = total_meat r...
The toy store has 5 different types of stuffed animals. Then they received a shipment of 3 boxes, each containing 8 teddy bears. How many teddy bears are there in total in the shipment?
def solve() -> int: num_animals = 5 num_boxes = 3 teddy_bears_per_box = 8 total_teddy_bears = num_boxes * teddy_bears_per_box result = num_animals * total_teddy_bears return result
Alex's living area has an area of 540 square feet. The area has a square bookshelf that takes up 100 square feet. What is the area of the living area excluding the square bookshelf?
def solve() -> int: living_area = 540 bookshelf_area = 100 area_excluding_bookshelf = living_area - bookshelf_area result = area_excluding_bookshelf return result
A school cafeteria served 800 meals on a weekday. One-fourth of the meals were breakfast, and three-eighths of the meals were lunch. The rest of the meals were dinner, but twenty-five of them were spoiled and thrown away. How many dinner meals were served by the cafeteria?
def solve() -> int: x = 800 b = x / 4 l = x * 3 / 8 d = x - b - l s = 25 result = d - s return result
arah's age is 3 years younger than Jaden's age. If Jaden is 15 years old, what's the sum of their ages?
def solve() -> int: jaden_age = 15 sarah_age = jaden_age - 3 total_age = jaden_age + sarah_age result = total_age return result
Maya is planning a party for her classmates. She has 120 plastic cups and 80 paper plates. She wants to serve lemonade and pizza to her guests. She needs one cup and one plate for each guest. She can make 8 cups of lemonade with one liter of water and one lemon. She can buy one pizza for 10 dollars and cut it into 8 sl...
def solve() -> int: guests = min(120, 80) water = guests / 8 lemons = guests / 8 pizzas = int(guests // 8) money = pizzas * 10 result = (guests, water, lemons, money) return result
If Jared can paint a house in six days and his friend Hannah can paint the same house in four times the amount of time as Jared, how many days will it take them to paint the house together on average?
def solve() -> int: jared_time = 6 hannah_time = 4 * jared_time total_time = jared_time + hannah_time average_time = total_time / 2 result = average_time return result
A train travels 60 km in the first hour, and then travels 10 km less in each of the following hours. If it travels for 5 hours in total, how far does it travel?
def solve() -> int: first_hour_distance = 60 distance_decrease_per_hour = 10 total_hours = 5 second_hour_distance = first_hour_distance - distance_decrease_per_hour third_hour_distance = second_hour_distance - distance_decrease_per_hour fourth_hour_distance = third_hour_distance - distance_decre...
Mike has 6 pens and he gives 1/3 of them to his sister. If his sister gives 2 pens to her friend, how many pens do they have in total?
def solve() -> int: sister_pens = 6 * (1/3) sister_pens -= 2 total_pens = sister_pens + 4 result = total_pens return result
Emma is purchasing a bookshelf at a furniture store where she gets a sale discount of 20% for furniture purchases. Additionally, she has a voucher for $25 off any furniture purchase. If the bookshelf Emma wants to buy costs $200 and the sale discount applies after the voucher, how much will she pay for the bookshelf?
def solve() -> int: price = 200 voucher = 25 discount = 0.2 price -= voucher price -= price * discount result = price return result
James is a writer. He has four fewer pens than he has fingers, and three more notebooks than he has hands. He also owns two more computers than he has heads, and one fewer printer than he has notebooks. What is the total number of writing materials that James owns?
def solve() -> int: fingers = 10 pens = fingers - 4 hands = 2 notebooks = hands + 3 heads = 1 computers = heads + 2 printer = notebooks - 1 total_writing_materials = pens + notebooks + printer result = total_writing_materials return result
A shop sells jeans for $50 each. If you buy 3 or more pairs, you get a 10% discount on the entire purchase. If Tom buys 5 pairs of jeans, how much does he pay?
def solve() -> int: if 5 >= 3: discount = 0.1 else: discount = 0 total_cost = 5*50*(1-discount) result = total_cost return result
A train travels at a speed of 60 km/h. How long will it take to travel a distance of 240 km?
def solve() -> int: distance = 240 speed = 60 time = distance / speed result = time return result
Two coworkers decide to order lunch. One orders a sandwich for $8 and the other orders a salad for $12. They split the total bill equally and add a 12% tip. How much does the person who ordered the sandwich pay in the end?
def solve() -> int: sandwich_price = 8 salad_price = 12 total_bill = sandwich_price + salad_price split_bill = total_bill / 2 tip = split_bill * 0.12 final_bill = split_bill + tip sandwich_share = (sandwich_price / total_bill) * final_bill result = round(sandwich_share, 2) return res...
Lily is making bracelets with beads. She has 280 red beads, 360 blue beads, and 240 green beads. She wants to make bracelets that have 12 beads each, and use the same number of each color. How many bracelets can she make?
def solve() -> int: min_beads = min(280, 360, 240) beads_per_color = min_beads // 3 beads_per_bracelet = beads_per_color * 3 bracelets = min_beads // beads_per_color result = bracelets return result
A family is trying to decide between two different cars. The first car costs $15,000 but gets 25 miles per gallon, while the second car costs $18,000 but gets 30 miles per gallon. If the family drives 600 miles per month, what is the difference in the cost of gas between the two cars per month?
def solve() -> int: car1_cost = 15000 car1_mpg = 25 car2_cost = 18000 car2_mpg = 30 monthly_miles = 600 car1_gas_cost = (monthly_miles / car1_mpg) * 2.5 car2_gas_cost = (monthly_miles / car2_mpg) * 2.5 gas_cost_difference = car2_gas_cost - car1_gas_cost result = gas_co...
Student: Sarah buys 3 pounds of coffee for $30. She pays with a $50 bill. What is her change?
def solve() -> int: coffee_price = 30 coffee_weight = 3 payment = 50 change = payment - coffee_price * coffee_weight result = change return result
Student: You buy a pizza that is sliced into 8 pieces. You eat 3 slices. What percentage of the pizza did you eat?
def solve() -> int: total_slices = 8 slices_eaten = 3 percentage_eaten = (slices_eaten / total_slices) * 100 result = percentage_eaten return result
If I cycle for 20 miles at an average speed of 10 miles per hour, how long did it take me?
def solve() -> int: distance = 20 average_speed = 10 time = distance / average_speed result = time return result
Karen's salsa recipe calls for 1/2 cup of chopped tomatoes but she likes to quadruple this amount to make it chunkier. Each tomato yields 3 tablespoons of chopped tomatoes. How many tomatoes does Karen need?
def solve() -> int: recipe_tomatoes = 1/2 factor = 4 total_tomatoes = recipe_tomatoes * factor tomatoes_per_tomato = 3/16 num_tomatoes = total_tomatoes / tomatoes_per_tomato num_tomatoes = round(num_tomatoes) result = num_tomatoes print return result
A coffee shop sells coffee for $3.50 and pastries for $2.20. If someone buys three coffees and four pastries, they get a discount of $3. If Rachel buys two coffees and three pastries and tips 20%, how much does she pay in total?
def solve() -> int: coffee_price = 3.5 pastry_price = 2.2 coffee_qty = 2 pastry_qty = 3 subtotal = coffee_price * coffee_qty + pastry_price * pastry_qty discount_amount = 3 if coffee_qty == 3 and pastry_qty == 4: subtotal -= discount_amount tip_percentage = 20 tip_amount = su...
Amanda can run a mile in 8 minutes. How long will it take her to run 3 miles?
def solve() -> int: time_to_run_one_mile = 8 total_time = 3 * time_to_run_one_mile result = total_time return result
Student: A car travels at a speed of 60 miles per hour. If the car travels for 3.5 hours, how far does it go?
def solve() -> int: speed = 60 time = 3.5 distance = speed * time result = distance return result
Mark builds model airplanes as a hobby. If he needs 2 pieces of plastic which are each 4 inches long and 3 pieces of plastic which are each 8 inches long to complete a certain model, how many total inches of plastic does he need?
def solve() -> int: piece1_length = 4 piece2_length = 4 piece3_length = 8 piece4_length = 8 piece5_length = 8 total_length = piece1_length + piece2_length + piece3_length + piece4_length + piece5_length result = total_length return result
Dan has 8 books on his shelf. He reads one book every day and buys two new books every week. How many books will he have on his shelf after three weeks?
def solve() -> int: books = 8 for day in range(21): books = books - 1 if day % 7 == 0: books = books + 2 result = books return result
Emily is checking to see if all passengers on a train have valid tickets. 40% of the passengers have valid tickets, and 1/6th that number have already purchased season tickets. If there are 500 passengers on the train, how many passengers did not have a valid ticket?
def solve() -> int: total_passengers = 500 valid_ticket_passengers = total_passengers * 0.4 season_ticket_passengers = valid_ticket_passengers / 6 invalid_ticket_passengers = total_passengers - valid_ticket_passengers - season_ticket_passengers result = invalid_ticket_passengers ...
Olivia reads 7 pages of a magazine on weekdays and 22 pages on weekends. If it takes her 4 weeks to finish the magazine, how many pages does it have?
def solve() -> int: weekday_pages = 7 weekend_pages = 22 weeks = 4 weekly_pages = (weekday_pages * 5) + (weekend_pages * 2) total_pages = weekly_pages * weeks result = total_pages return result
John just moved in and purchased new furniture for his living room at a 15% discount. The furniture cost him a total of $2700. How much money did he have to pay?
def solve() -> int: total_cost = 2700 discount_percentage = 15 discount = total_cost * (discount_percentage/100) final_cost = total_cost - discount result = final_cost return result
A home security system is marked down to $200, which is 40% less than the original price. What was the original price?
def solve() -> int: original_price = None discounted_price = 200 discount_percentage = 40 original_price = discounted_price / (1 - discount_percentage/100) result = original_price return result
A company sells 2000 units of a product at a price of $3 per unit. The company incurs costs of $1500 plus $0.50 per unit produced. What is the company's profit?
def solve() -> int: num_units_sold = 2000 price_per_unit = 3 fixed_costs = 1500 variable_costs_per_unit = 0.5 total_revenue = num_units_sold * price_per_unit total_costs = fixed_costs + (num_units_sold * variable_costs_per_unit) profit = total_revenue - total_costs result = profit r...
There are 91 students in the 4th grade. If 20% of them wear glasses and 10% wear contact lenses, how many more students wear glasses than contact lenses?
def solve() -> int: glasses = 91 * 0.2 contact_lenses = 91 * 0.1 difference = glasses - contact_lenses result = difference return result
Student: A factory produces 12 boxes of pens each day, with 24 pens per box. Each pen has a pack of 5 erasers attached to it. Calculate the total number of erasers produced in a day along with the pens.
def solve() -> int: boxes = 12 pens_per_box = 24 erasers_per_pen = 5 total_pens = boxes * pens_per_box total_erasers = total_pens * erasers_per_pen total_pens_and_erasers = total_pens + total_erasers result = total_pens_and_erasers return result
Jack spent $800 on a guitar and $1200 on an amplifier. He had previously purchased a microphone worth $300. If sound equipment costs $50 per decibel, how many decibels of sound equipment does he own now?
def solve() -> int: guitar_cost = 800 amplifier_cost = 1200 microphone_cost = 300 total_cost = guitar_cost + amplifier_cost + microphone_cost sound_equipment_cost_per_decibel = 50 total_decibels = total_cost / sound_equipment_cost_per_decibel result = total_decibels r...
A driver needs to travel a distance of 400 kilometers. He can drive at a speed of 50 kilometers per hour for the first 200 kilometers, and then 80 kilometers per hour thereafter. How long, in hours, will the entire trip take?
def solve() -> int: distance_1 = 200 speed_1 = 50 distance_2 = 400 - distance_1 speed_2 = 80 time_1 = distance_1 / speed_1 time_2 = distance_2 / speed_2 total_time = time_1 + time_2 result = total_time return result
Mrs. Johnson has 80 pens. She has 20 more pencils than pens. She wants to split them equally among 5 students. How many pens and pencils will each student receive?
def solve() -> int: pens = 80 pencils = pens + 20 total_items = pens + pencils each_student = total_items // 5 result = each_student return result
Student: Susan runs 5 miles per hour. How long (in minutes) does it take Susan to run 3 miles?
def solve() -> int: speed = 5 distance = 3 speed_per_minute = speed / 60 time = distance / speed_per_minute time_in_minutes = time * 60 result = time_in_minutes return result
A recipe calls for 2/3 cup of sugar. If a cup of sugar costs $2, how much does the sugar required for the recipe cost?
def solve() -> int: sugar_required = 2/3 cost_per_cup = 2 sugar_cost = sugar_required * cost_per_cup result = sugar_cost return result
Jessica needs to make a cake that requires 4.5 cups of sugar. She has 2 bags of sugar each containing 2.25 cups. How much more sugar does Jessica need?
def solve() -> int: total_cups_needed = 4.5 cups_per_bag = 2.25 bags = 2 total_cups = cups_per_bag * bags amount_needed = total_cups_needed - total_cups result = amount_needed return result
am has 8 apples. They eat 3 apples and then receive 6 more apples from their neighbor. How many apples do they have now?
def solve() -> int: apples = 8 apples -= 3 apples += 6 result = apples return result
Michael and his friends played two games of chess. The first game lasted 25 minutes and the second game lasted 15 minutes longer than the first. Before the games, they spent 5 minutes setting up the board and pieces and after the games, they spent 10 minutes discussing their moves. How long, in minutes, did it take Mic...
def solve() -> int: game_1 = 25 game_2 = game_1 + 15 setup = 5 discussion = 10 total_time = game_1 + game_2 + setup + discussion result = total_time return result
Tina has $30 and gives $11 to her mom and $6 to her dad for lunch. How much money does Tina have left after lunch?
def solve() -> int: tina_mom_lunch = 11 tina_dad_lunch = 6 tina_balance = 30 - (tina_mom_lunch + tina_dad_lunch) result = tina_balance return result
Carol bought 12 apples. Ernie bought 3 fewer apples than Carol. Joe bought 8 more apples than Ernie. How many apples did Carol, Ernie, and Joe buy in total?
def solve() -> int: carol = 12 ernie = carol - 3 joe = ernie + 8 result = carol + ernie + joe return result
A store purchases products for $20 each and sells them for $30 each. If they sell 100 such products, what is their total profit?
def solve() -> int: cost_price = 20 selling_price = 30 number_of_products = 100 total_profit = (selling_price - cost_price) * number_of_products result = total_profit return result
ve works in DHL courier service and he needs to deliver 10 packages to 10 different addresses. He starts at 9am and he knows that each package will take him 45 mins to deliver. If Steve must stop delivering the packages by 11am, how many packages will he be able to deliver?
def solve() -> int: delivery_time_per_package = 45 delivery_cut_off_time = 11 * 60 total_time_for_10_packages = 10 * delivery_time_per_package if total_time_for_10_packages < delivery_cut_off_time: num_of_packages_delivered = 10 else: nu...
Student: Sue baked 24 cupcakes for a charity sale. She sold two-thirds of them in the morning and the rest in the afternoon. She made $1.50 for each cupcake in the morning and $2.00 for each cupcake in the afternoon. How much money did Sue make in total?
def solve() -> int: cupcakes_morning = 24 * 2/3 cupcakes_afternoon = 24 * 1/3 price_morning = 1.50 price_afternoon = 2.00 money_morning = cupcakes_morning * price_morning money_afternoon = cupcakes_afternoon * price_afternoon result = money_morning + money_afternoon return result
The population of a town is 10,000 and it grows by 7% each year. How many people will live in the town in 5 years?
def solve() -> int: population = 10000 growth_rate = 0.07 num_years = 5 projected_population = population*(1+growth_rate)**num_years result = projected_population return result
Dan loves to read books and can read up to 6 books in a day. On a certain week, he read 4 books on Monday, 2 fewer books on Tuesday than on Monday, one more book on Wednesday than on Tuesday, the same number of books on Thursday as on Wednesday, and half the number of books he had read on Monday on Friday. How many boo...
def solve() -> int: Monday = 4 Tuesday = Monday - 2 Wednesday = Tuesday + 1 Thursday = Wednesday Friday = Monday // 2 total = Monday + Tuesday + Wednesday + Thursday + Friday result = total return result
Student: 4/7 of the seats in an auditorium that holds 700 people are currently taken. It was found that 1/10 of the seats are broken. How many seats are still available?
def solve() -> int: total_seats = 700 taken_seats = 4/7 * total_seats broken_seats = 1/10 * total_seats available_seats = total_seats - taken_seats - broken_seats result = available_seats return result
A farmer has 200 cows. 30% of them give at least 8 liters of milk per day. One-fifth of those cows give at least 10 liters of milk per day. If 15% of the remaining cows give less than 6 liters of milk per day, how many cows give less than 6 liters per day?
def solve() -> int: cows = 200 cows_with_8_liters = cows * 0.3 cows_with_10_liters = cows_with_8_liters * (1/5) remaining_cows = cows - cows_with_8_liters cows_less_than_6_liters = remaining_cows * 0.15 result = cows_less_than_6_liters return result
A sculpture is 2 meters tall and casts a shadow of 5 meters on the ground. How tall is a nearby building if it casts a shadow of 40 meters that same day?
def solve() -> int: sculpture_height = 2 sculpture_shadow = 5 building_shadow = 40 building_height = sculpture_height * (building_shadow / sculpture_shadow) result = building_height return result
Emily writes a 7-page essay for 2 different classes twice a month. How many pages does she write in a year?
def solve() -> int: pages_per_essay = 7 classes_per_month = 2 months_per_year = 12 essays_per_year = classes_per_month * months_per_year pages_per_year = pages_per_essay * essays_per_year result = pages_per_year return result
A farmer wants to divide his field into square sections of equal size. If the field is 1200 square meters in area, and each square section is 25 square meters, how many sections are there in the field?
def solve() -> int: field_area = 1200 section_area = 25 sections = field_area / section_area result = sections return result
A triangle with base 8 cm and height x cm has an area of 24 square cm. What is the value of x?
def solve() -> int: area = 24 base = 8 height = (2*area) / base result = height return result
Mary is 12 years old and her sister is 3 years older than her. What is the sum of their ages in 5 years from now?
def solve() -> int: age1 = 12 age2 = age1 + 3 age1_in5 = age1 + 5 age2_in5 = age2 + 5 sum_in5 = age1_in5 + age2_in5 result = sum_in5 return result
Student: Sophie is taking care of her friend's cat for a week. She needs to feed the cat twice a day, and it takes her 2 minutes to prepare the food and 5 minutes to clean the bowl. If she can only check on the cat during her lunch break, how much of her lunch break will she need to spend to feed the cat each day?
def solve() -> int: prep_time = 2 clean_time = 5 feed_times = 2 total_time = prep_time + clean_time time_per_day = total_time * feed_times result = time_per_day return result
Edward consumes 2 cans of energy drink every day. He likes to buy an entire year's supply when the drink is on sale for 10% off. If each can costs $2.00, how much will all the energy drinks cost after the discount?
def solve() -> int: cans_per_day = 2 days_per_year = 365 discount = 0.10 cost_per_can = 2.00 total_cans = cans_per_day * days_per_year total_cost = total_cans * cost_per_can discounted_cost = total_cost * (1 - discount) result = discounted_cost return result
If a store sells a shirt for $25 which costs $10 to make, what is the store's profit if they sell 50 shirts?
def solve() -> int: sale_price = 25 cost_price = 10 units = 50 profit = (sale_price - cost_price) * units result = profit return result
Jillian orders 20 pizzas. After two hours, she has 16 times as many pizzas as she started with. If each pizza has 8 slices, how many slices of pizza does Jillian have now?
def solve() -> int: pizzas_ordered = 20 slices_per_pizza = 8 pizzas_after_2_hours = pizzas_ordered * 16 slices_after_2_hours = pizzas_after_2_hours * slices_per_pizza result = slices_after_2_hours return result
Student: A soccer team has 11 players on the field. They score 3 goals in a match. How many points do they get for each goal?
def solve() -> int: players = 11 goals = 3 points_per_goal = players / goals result = points_per_goal return result
At a flower market, Sarah bought 7 bouquets of flowers. The next day she bought three times the number of bouquets as she bought the day before. On the third day, she gave away half of the number of bouquets she had bought the previous day. How many bouquets of flowers did Sarah have left on the third day?
def solve() -> int: bouquets_first_day = 7 bouquets_second_day = 3 * bouquets_first_day bouquets_given_away = bouquets_second_day / 2 bouquets_left = bouquets_second_day - bouquets_given_away result = bouquets_left return result
Ben likes to collect coins and has a jar full of pennies, nickels, dimes, and quarters. He knows that there are 100 pennies, 40 nickels, 50 dimes, and 20 quarters in the jar. He also knows that a penny is worth 1 cent, a nickel is worth 5 cents, a dime is worth 10 cents, and a quarter is worth 25 cents. How much money ...
def solve() -> int: pennies = 100 nickels = 40 dimes = 50 quarters = 20 penny_value = 1 nickel_value = 5 dime_value = 10 quarter_value = 25 pennies_value = pennies * penny_value nickels_value = nickels * nickel_value dimes_value = dimes * dime_value quarters_value = quart...
Mary has $840 and needs to buy some oranges. oranges cost $2.25 each. How many oranges can Mary buy with her $840?
def solve() -> int: amount = 840 price_per_orange = 2.25 num_oranges = amount // price_per_orange result = num_oranges return result
Before Joe went to the store, he had 10 coins worth $2 each. After he bought 3 items which each cost $10, how much money did he have left?
def solve() -> int: before = 10 * 2 cost = 10 * 3 after = before - cost result = after return result
am needs to paint a room that is 3 meters wide, 4 meters long, and 2.5 meters high. If one can of paint covers 10 square meters, how many cans of paint does Sam need?
def solve() -> int: width = 3 length = 4 height = 2.5 area = 2 * ((width*height) + (length*height)) cans_of_paint = area / 10 result = cans_of_paint return result
Leo wants to paint his room. He needs 1 gallon of paint for every 100 square feet of wall. He has 4 walls that are each 10 feet wide and 8 feet high. He also has a ceiling that is 10 feet wide and 10 feet long. He can buy paint for $20 per gallon. How much will he spend on paint if he paints the walls and the ceiling?
def solve() -> int: wall_area = 10 * 8 ceiling_area = 10 * 10 total_area = (4 * wall_area) + ceiling_area gallons = total_area / 100 total_cost = gallons * 20 result = round(total_cost, 2) return result
ally wants to save up enough money to buy some new clothes. She has saved $50 and earns an additional $30 every week. In how many weeks will Sally have saved $300?
def solve() -> int: savings = 50 weekly_earn = 30 target = 300 def count_weeks(savings, weekly_earn, target): counter = 0 while savings < target: savings += weekly_earn counter += 1 return counter result = count_weeks(savings, weekly_earn, target) return res...
Rachel buys 3 chicken sandwiches at $5 each, 2 burgers at $6 each, and 4 fries at $2 each. If she has $35, how many milkshakes can she buy with the change if one costs $3 each?
def solve() -> int: chicken_sandwiches = 3 sandwich_price = 5 burgers = 2 burger_price = 6 fries = 4 fries_price = 2 total_cost = (chicken_sandwiches * sandwich_price) + (burgers * burger_price) + (fries * fries_price) change = 35 - total_cost milkshake_price = 3 milkshakes ...
A store has 200 markers. They sell half of them and then 10% of what is left is stolen. How many markers are there now?
def solve() -> int: markers = 200 sold_markers = markers / 2 remaining_markers = markers - sold_markers stolen_markers = remaining_markers * 0.1 result = remaining_markers - stolen_markers return result
Jack buys 7000 feet of cable. He cuts the cable into sections of 35 feet each. He distributes 1/3rd of the cable to his brother. Following that, he stores one-third of the remaining cable in his office. How much cable does he keep with himself?
def solve() -> int: cable_length = 7000 section_length = 35 num_sections = cable_length // section_length brother_cable = num_sections // 3 * section_length remaining_cable = cable_length - brother_cable office_cable = remaining_cable // 3 jack_cable = remaining_cabl...
Possible new questions and programs are: A rectangular garden has a length of 12 meters and a width of 8 meters. A gardener wants to plant flowers along the perimeter of the garden, leaving a gap of 1 meter between each flower. How many flowers does the gardener need?
def solve() -> int: perimeter = 2 * (12 + 8) flowers = perimeter / 1 result = flowers return result
Hayley is going to spend 6 hours at an amusement park. The wait for the roller coaster is 55 minutes, the wait for the log flume is 20 minutes, and the wait for the haunted house is 30 minutes. If Hayley rides the roller coaster 3 times and the haunted house 5 times, how many times can she ride the log flume?
def solve() -> int: hours_at_park = 6 roller_coaster_wait = 55 log_flume_wait = 20 haunted_house_wait = 30 roller_coaster_rides = 3 haunted_house_rides = 5 total_roller_coaster_wait = roller_coaster_wait * roller_coaster_rides total_haunted_house_wait = haunted_house_wait * haunted_...
In a garden, there are 10 marigolds and 15 more petunias than marigolds. If there are also 5 more sunflowers than petunias, how many flowers are in the garden in total?
def solve() -> int: marigolds = 10 petunias = marigolds + 15 sunflowers = petunias + 5 total_flowers = marigolds + petunias + sunflowers result = total_flowers return result
Alex took a survey and asked people how many hours they practiced music each week. Out of the 800 people he asked, 142 reported that they practice music for 0 hours, 266 reported that they practice for 1 hour, and 152 reported that they practice for 3 hours. How many people reported that they practice music for 2 hours...
def solve() -> int: noPractice = 142 oneHourPractice = 266 threeHourPractice = 152 totalPeople = 800 remainingPeople = totalPeople - (noPractice + oneHourPractice) result = remainingPeople - threeHourPractice return result
Rachel is packing a box that is 2 feet wide, 3 feet long, and 4 feet high. She can pack a swath 6 inches wide, and can pack one cubic foot of space in 10 seconds. How long will it take her to pack the entire box in hours and minutes?
def solve() -> int: width = 2 length = 3 height = 4 swath_width = 0.5 packing_speed = 1 / 10 total_volume = width * length * height swath_volume = swath_width * length * height time_taken = total_volume / swath_volume * packing_speed hours = int(time_taken) minutes...
A shopkeeper buys 50 items for $200. If they decide to sell them at 25% profit, for how much will they sell each item?
def solve() -> int: num_items = 50 cost_price = 200 profit_percent = 0.25 selling_price_per_item = (cost_price / num_items) * (1 + profit_percent) result = selling_price_per_item return result
Student: A beauty salon offers a loyalty program where for every 12 visits, the customer gets a free haircut. Lily has received 1 free haircut already and is currently 5 visits away from receiving her 2nd. If each haircut costs $50, how much has Lily spent on haircuts?
def solve() -> int: visits_per_haircut = 12 free_haircuts = 1 visits_until_free = 5 haircut_cost = 50 total_haircuts = (free_haircuts * visits_per_haircut) + visits_until_free total_spent = total_haircuts * haircut_cost result = total_spent return result
Lucy practices piano for half an hour every day, Monday to Friday. If she practices every day of the week except for Wednesday, how many hours did she practice in total?
def solve() -> int: monday = 0.5 tuesday = 0.5 thursday = 0.5 friday = 0.5 total_hours = monday + tuesday + thursday + friday result = total_hours return result
A musician composed 5 fewer songs than the number of instruments in his orchestra and added them to his repertoire. If he now knows 25 songs, how many instruments are in his orchestra?
def solve() -> int: num_songs = 25 num_composed = num_songs - 5 num_instruments = num_composed result = num_instruments return result
Sarah has 150 inches of twine that she wants to use for a project, but she needs to cut it into smaller pieces first. She cuts it into 12 equal length pieces, but then she realizes it's too short, so she ties four pieces together. The knots then make each piece 1.25 inches shorter. How long are her pieces of twine afte...
def solve() -> int: twine_length = 150 num_pieces = 12 piece_length = twine_length / num_pieces tied_pieces = 4 shortened_length = 1.25 final_length = (piece_length * num_pieces + tied_pieces * shortened_length) / num_pieces result = final_length return result
Emily is talking with her family and learns that she is 35 years younger than her uncle. Her uncle is 13 years younger than her grandfather. If her grandfather is 80, how old is Emily?
def solve() -> int: grandfather_age = 80 uncle_age = grandfather_age - 13 emily_age = uncle_age - 35 result = emily_age return result
Rachel is known for being a slow eater because she takes 30 minutes to finish a sandwich. If fast eaters finish their sandwiches in 5 minutes or less, how many minutes less than Rachel do they take to finish a sandwich?
def solve() -> int: rachel_time = 30 fast_eater_time = 5 time_difference = rachel_time - fast_eater_time result = time_difference return result
A company sells shirts for $15, pants for $30, and shoes for $50. If a customer buys 2 shirts, 1 pair of pants, and 1 pair of shoes, how much is their total bill?
def solve() -> int: shirt_cost = 15 number_of_shirts = 2 pants_cost = 30 number_of_pants = 1 shoe_cost = 50 number_of_shoes = 1 total_bill = (shirt_cost * number_of_shirts) + (pants_cost * number_of_pants) + (shoe_cost * number_of_shoes) result = total_bill return result
Mary's garden is 15 feet long and 10 feet wide. She wants to plant flowers in 1/3 of the garden area. What is the area of the garden in square feet, and how many square feet of garden area does Mary plan to plant flowers in?
def solve() -> int: length = 15 width = 10 total_area = length * width flower_area = total_area * 1/3 result = total_area, flower_area return result
A rectangular prism has a length of 6 centimeters, a width of 4 centimeters and a height of 2 centimeters. What is the volume of the prism?
def solve() -> int: length = 6 width = 4 height = 2 volume = length * width * height result = volume return result
4. Jack wants to buy enough chocolate bars for the 20 kids in his neighborhood. He wants to make sure each kid get 3 chocolate bars. The store he's shopping from sells boxes of chocolate bars containing 10 bars each. How many boxes should Jack buy?
def solve() -> int: bars_required = 20 * 3 boxes_required = bars_required / 10 result = boxes_required return result
The total number of people who live on the island of Castor is 2000. 15% of them ride bikes to work and 10% of the bike riders also ride boats to get to work. How many islanders ride both bikes and boats to work?
def solve() -> int: bike_riders = 2000 * 0.15 boat_riders = bike_riders * 0.1 result = boat_riders return result
If a bar of chocolate is 243 grams and can be divided into equal pieces, each weighing 9 grams, how many pieces are in the bar? Sophie is selling 120 cupcakes. One-fifth of the cupcakes have sprinkles on top. How many cupcakes have sprinkles on top?
def solve() -> int: chocolate_weight = 243 piece_weight = 9 pieces_in_bar = chocolate_weight // piece_weight cupcakes_total = 120 cupcakes_with_sprinkles = cupcakes_total // 5 result = pieces_in_bar result = cupcakes_with_sprinkles return result
A container has 500 liters of water. If 20% evaporated, and another 30% of the remaining water was used, how many liters of water are left in the container?
def solve() -> int: total_water = 500 evaporated_water = total_water * 0.2 remaining_water = total_water - evaporated_water used_water = remaining_water * 0.3 water_left = remaining_water - used_water result = water_left return result
A worker gets paid $25 per hour for the first 8 hours, and $30 per hour for each additional hour. How much will he earn for working 12 hours?
def solve() -> int: hourly_rate = 25 additional_hourly_rate = 30 hours_worked = 12 if hours_worked <= 8: total_pay = hourly_rate*hours_worked else: additional_hours = hours_worked - 8 total_pay = hourly_rate*8 + additional_hourly_rate*additional_hours result = total_pay ...
A survey was taken of the favorite ice cream flavors of a group of people. 35% liked vanilla, 25% liked chocolate, and 10% liked strawberry. If the rest liked other flavors, what percentage of the group liked other flavors?
def solve() -> int: total_people = 100 vanilla = 0.35 * total_people chocolate = 0.25 * total_people strawberry = 0.10 * total_people other_flavors = total_people - (vanilla + chocolate + strawberry) percentage_other_flavors = (other_flavors / total_people) * 100 result = percentage_other_fl...
A pizza with a diameter of 10 inches costs $15. Find the price per square inch of pizza.
def solve() -> int: radius = 5 area = 3.14 * radius ** 2 price_per_square_inch = 15 / area result = price_per_square_inch return result