question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
A bookstore made a profit of $1600 by selling 200 books. What is the profit earned per book?
def solve() -> int: profit = 1600 books = 200 profit_per_book = profit / books result = f'<<<{profit_per_book}>>>' result = profit_per_book return result
Juan has $15 and his three classmates each have $3. How much money should Juan give to each of his classmates so they all have an equal amount of money?
def solve() -> int: juan_money = 15 classmate_money = 3 total_classmates = 3 total_people = total_classmates + 1 total_money = juan_money + (classmate_money * total_classmates) equal_money = total_money // total_people juan_gives = juan_money - equal_money each_classmate_g...
There are 27 students in a classroom. If 15 students are girls, how many students are boys?
def solve() -> int: total_students = 27 girls = 15 boys = total_students - girls result = boys return result
A farmer has 50 chickens and 20 ducks in his barn. He collects eggs from them every day and sells them at the market. He knows that each chicken lays an average of 5 eggs per week and each duck lays an average of 3 eggs per week. He also knows that each chicken egg sells for $0.25 and each duck egg sells for $0.35. How...
def solve() -> int: chickens = 50 ducks = 20 chicken_eggs_per_week = 5 duck_eggs_per_week = 3 chicken_egg_price = 0.25 duck_egg_price = 0.35 weeks_per_year = 52 chicken_eggs_per_year = chickens * chicken_eggs_per_week * weeks_per_year duck_eggs_per_year = ducks * duck_eggs_per_week...
Student: Jane went grocery shopping and bought 4 bags of apples for $3 each and 3 packs of oranges for $5 each. If she used a $10 coupon, how much did she pay in total?
def solve() -> int: apples = 4 apple_price = 3 oranges = 3 orange_price = 5 coupon = 10 apple_cost = apples * apple_price orange_cost = oranges * orange_price total_cost = apple_cost + orange_cost total_cost -= coupon result = total_cost return result
Olivia has $6000. She spends $2000 on a guitar, and then spends half of what's left on a vacation. Olivia then wins a quarter of what she has left by playing a lottery game. How much money does she end up with?
def solve() -> int: olivia_money = 6000 guitar_cost = 2000 olivia_money -= guitar_cost vacation_cost = olivia_money / 2 olivia_money -= vacation_cost lottery_winnings = olivia_money / 4 olivia_money += lottery_winnings result = olivia_money return result
Dinah wants to buy enough balloons for her daughter's birthday party, there will be 10 adults and 10 kids attending. Each balloon pack cost $4.99 and includes 10 balloons. How much will Dinah spend on balloons?
def solve() -> int: price_per_pack = 4.99 num_of_adults = 10 num_of_kids = 10 num_of_balloons = num_of_adults + num_of_kids num_of_packs = num_of_balloons // 10 + 1 total_cost = num_of_packs * price_per_pack result = total_cost return result
Kelly is trying to follow a recipe that requires a total of 4 eggs. On the first step, she uses 1 egg. On the second step, she uses 0.5 eggs but then realizes she needs to replace 0.2 eggs. On the third step, she uses 1.3 eggs. How many more eggs does she need to use to complete the recipe? At a football game, there ar...
def solve() -> int: eggs_used_step1 = 1 eggs_used_step2 = 0.5 eggs_replaced_step2 = 0.2 eggs_used_step3 = 1.3 total_eggs_used = eggs_used_step1 + eggs_used_step2 - eggs_replaced_step2 + eggs_used_step3 eggs_needed = 4 eggs_remaining = eggs_needed - total_eggs_used spectators_in...
It takes 5 workers 10 hours to build a house. How many hours will it take 8 workers to build the same house?
def solve() -> int: hours = 10 workers = 5 new_workers = 8 new_hours = (hours*workers)/new_workers result = new_hours return result
On the first day, Jenny found 11 shells at the beach. She found twice as many shells the following two days consecutively. How many shells in total did Jenny find?
def solve() -> int: number_1 = 11 number_2 = number_1 * 2 number_3 = number_2 * 2 result = number_1 + number_2 + number_3 return result
There was some money in the wallet. Tim spent 10 dollars from the wallet. James spent 50% of the money that Tim spent. If there were 27 dollars left in the wallet, how much money was initially in the wallet?
def solve() -> int: initial_money = 0 tim_spent = 10 james_spent = 0 initial_money = tim_spent + 27 james_spent = 0.5 * tim_spent result = initial_money + james_spent return result
A company printed 100,000 brochures. They were required to print 20 percent in color. If the cost difference of a colored brochure and a black and white brochure is $0.04, how much extra did it cost to print the brochures in color?
def solve() -> int: cost_difference = 0.04 colored_brochures = 100000*0.2 extra_cost = colored_brochures * cost_difference result = extra_cost return result
Here are some possible questions and programs: Luis, Nina, and Omar are brothers and sisters who like collecting stamps. Luis has 36 stamps, which is 60% of Nina's stamps, and Omar has 12 stamps less than Luis. How many stamps do all of the siblings have?
def solve() -> int: luis = 36 nina = luis / 0.6 omar = luis - 12 total = luis + nina + omar result = total return result
Mrs. Johnson has a toy store. She has 40% of her toys on sale for 25% off. She also has 240 toys that aren't on sale. How many total toys does Mrs. Johnson have?
def solve() -> int: percent_on_sale = 40 percent_off = 25 toys_on_sale = percent_on_sale / 100 * 240 toys_not_on_sale = 240 total_toys = toys_on_sale + toys_not_on_sale result = total_toys return result
A car dealer sold a car for $15,000, making a profit of 20%. What was the cost price of the car?
def solve() -> int: selling_price = 15000 profit_percentage = 0.20 cost_price = selling_price / (1 + profit_percentage) result = cost_price return result
A toy store has 12 toy cars. 4 children want to buy 2 toy cars each. How many toy cars does the toy store have after the purchase?
def solve() -> int: num_toy_cars = 12 num_children = 4 num_toy_cars_per_child = 2 total_toy_cars_sold = num_children * num_toy_cars_per_child num_toy_cars_left = num_toy_cars - total_toy_cars_sold result = num_toy_cars_left return result
A box of apples costs $30, while a box of oranges costs $40. If you have $120, how many boxes of each can you buy?
def solve() -> int: apple_cost = 30 orange_cost = 40 total_money = 120 num_apples = total_money // apple_cost num_oranges = total_money // orange_cost result = (num_apples, num_oranges) return result
Doug has 200 marbles that he needs to divide equally between himself and his 5 friends. How many marbles will each person get?
def solve() -> int: marbles = 200 num_friends = 5 marbles_per_person = marbles / (num_friends + 1) result = marbles_per_person return result
In a certain factory, there are 15 machines and 25 workers. Last week, they can build 300 products. How many products can they build this week if the number of machines and workers add up to 50?
def solve() -> int: m1 = 15 w1 = 25 p1 = 300 m2 = 35 w2 = 15 result = p1 * (m2 + w2) / (m1 + w1) return result
Kelly is a photographer who works at a studio. She takes 10 photos of each customer and charges $2 per photo. She also charges a $15 service fee for each customer. She has an average of 8 customers a day and works 6 days a week. How much money does she make in a week?
def solve() -> int: photos = 10 photo_price = 2 service_fee = 15 customers = 8 work_days = 6 photo_money = photos * photo_price * customers service_money = service_fee * customers total_money = photo_money + service_money total_money = total_money * work_days result = to...
A shopkeeper sells bags of candy. He sells for 8 hours and sells 15 bags each hour. Each bag offers 4 candies per person. How many candies are sold in total?
def solve() -> int: hours = 8 bags_per_hour = 15 candies_per_bag = 4 total_candies = hours * bags_per_hour * candies_per_bag result = total_candies return result
Ben deposited $2500 in his bank account. A year later, he saved an additional $400 into the same account and his account has now earned $75 in interest. How much does Ben have in his account now?
def solve() -> int: initial_deposit = 2500 annual_deposit = 400 annual_interest = 75 total = initial_deposit + annual_deposit + annual_interest result = total return result
A factory produces 80 batteries per hour. If the factory operates for 12 hours, how many batteries are produced?
def solve() -> int: batteries_per_day = 80 * 12 result = batteries_per_day return result
Mary wants to buy a new laptop that costs $900. The store is offering 15% off for anyone who pays in cash. Mary wants to pay with her credit card but can also pay the card off immediately. If the credit card has a 10% interest rate, would it be more beneficial for her to pay with cash or credit?
def solve() -> int: price = 900 cash_discount = 0.15 cash_price = price * (1 - cash_discount) credit_discount = 0 credit_price = price * (1 - credit_discount) interest_rate = 0.1 credit_interest = 1 + interest_rate if cash_price < credit_price * credit_interest: result = "It is m...
Possible new questions and python programs: Lily sells lemonade at a roadside stand for $2 per cup. She spends $10 per day on lemons and sugar and sells an average of 25 cups per day. How much profit does she make in a week (7 days)?
def solve() -> int: price = 2 quantity = 25 expenditure = 10 days = 7 revenue = price * quantity * days cost = expenditure * days profit = revenue - cost result = profit return result
Student: A store sells jeans for $45 each. If a customer buys 3 pairs of jeans, the store gives them a 10% discount. How much does a customer pay for 3 pairs of jeans?
def solve() -> int: price = 45 quantity = 3 discount = 0.1 total = price * quantity discount_amount = total * discount final = total - discount_amount result = final return result
In a bakery, there are four more cakes than pies. If there are 16 pies, how many slices are there in total (assuming each cake has eight slices and each pie has six slices)?
def solve() -> int: p = 16 c = p + 4 slices = 8 * c + 6 * p result = slices return result
Pat had a coupon for 25% off a $70 purchase. How much money did Pat save with the coupon?
def solve() -> int: original_price = 70 discount_percent = 25 discount_amount = original_price * discount_percent / 100 result = discount_amount return result
Possible new questions and programs are: Anna bakes 60 cupcakes and sells 24 of them at a bake sale. She then gives one-third of the remaining cupcakes to a local shelter. How many cupcakes does she have left?
def solve() -> int: cupcakes = 60 cupcakes = cupcakes - 24 shelter = cupcakes // 3 cupcakes = cupcakes - shelter result = cupcakes return result
Student: 1. My Dad was 48 years old when I was born. Now he is 67 years old. How old was I when he turned 60 years old?
def solve() -> int: dad_age_when_born = 48 dad_current_age = 67 dad_age_when_60 = 60 age_when_dad_turned_60 = dad_age_when_60 - (dad_current_age - dad_age_when_born) result = age_when_dad_turned_60 - dad_age_when_born return result
Student: There were 30 cupcakes at a bake sale. 10 were sold in the morning and then 16 were sold in the afternoon. How many cupcakes are left?
def solve() -> int: cupcakes_total = 30 cupcakes_sold_morning = 10 cupcakes_sold_afternoon = 16 cupcakes_left = cupcakes_total - cupcakes_sold_morning - cupcakes_sold_afternoon result = cupcakes_left return result
A recipe calls for 2 cups flour, 1 cup sugar, and 1/2 cup oil to make 12 muffins. If you want to make 36 muffins, how many cups of each ingredient do you need?
def solve() -> int: flour = 2/12*36 sugar = 1/12*36 oil = 1/2*1/12*36 result = (flour, sugar, oil) return result
Jim sold 35% of his stamps, and still has 200 stamps. How many stamps did he have in the beginning?
def solve() -> int: stamps_left = 200 sold_percent = 35 stamps_total = stamps_left / (1- (sold_percent/100)) result = stamps_total return result
Taylor is ordering flowers for a friend's wedding. A 5% down payment is required, and the balance must be paid prior to delivery. The cost of the flowers is 40% more expensive than last year's similar order, which cost $400. What will be Taylor's remaining balance, in dollars?
def solve() -> int: last_year_cost = 400 down_payment_percentage = 0.05 increase_percentage = 0.40 down_payment = last_year_cost * down_payment_percentage total_cost = last_year_cost + (last_year_cost * increase_percentage) remaining_balance = total_cost - down_payment result = rem...
In a class of 28 students, 15 of the students are girls. What percentage of the class are boys?
def solve() -> int: Total = 28 Girls = 15 Boys_Percentage = ((Total-Girls)/Total)*100 result = Boys_Percentage return result
Matthew's puppy grows at the rate of 1 pound per week. If the puppy currently weighs 10 pounds, how much will the puppy weigh after 4 months (assuming each month is 4 weeks long)?
def solve() -> int: puppy_weight = 10 rate_of_growth = 1 weeks_in_a_month = 4 total_weeks = 4 * weeks_in_a_month weight_gained = rate_of_growth * total_weeks final_weight = puppy_weight + weight_gained result = final_weight return result
Sarah bought 3 books at $15 each and 5 pencils at $1 each. The cashier gave her a discount of $5. If Sarah paid with a $50 bill, how much change did she get back?
def solve() -> int: price_books = 3*15 price_pencils = 5*1 total_price = price_books + price_pencils - 5 change = 50 - total_price result = change return result
Student: Lisa buys 3 bags of candy. Each bag contains 12 pieces of candy and weighs 8 ounces. How many ounces of candy does Lisa buy in total?
def solve() -> int: num_bags = 3 num_pieces = 12 weight_per_bag = 8 total_weight = num_bags * num_pieces * weight_per_bag result = total_weight return result
Juan bought 18 meters of fabric and divided it into 3 equal parts. He used 2 parts of the fabric. How many meters of fabric are left unused?
def solve() -> int: fabric_length = 18 parts = 3 used_parts = 2 unused_parts = parts - used_parts unused_fabric = unused_parts * (fabric_length / parts) result = unused_fabric return result
Kyle is buying almonds. He can buy a 1 lb bag for $5.50 or a 2 lb bag for $10. Which is the better value (in cents per lb)?
def solve() -> int: lb_per_bag1 = 1 price_per_bag1 = 5.50 lb_per_bag2 = 2 price_per_bag2 = 10 price_per_lb1 = price_per_bag1 / lb_per_bag1 * 100 price_per_lb2 = price_per_bag2 / lb_per_bag2 * 100 result = min(price_per_lb1, price_per_lb2) return result
Michael earns $100 per day as a delivery driver. If he spends 40% of his earnings on gas, how much money does he have left after 25 days of work?
def solve() -> int: earnings_per_day = 100 days_of_work = 25 gas_percentage = 0.4 total_earnings = earnings_per_day * days_of_work gas_expenses = total_earnings * gas_percentage remaining_money = total_earnings - gas_expenses result = remaining_money return result
If the ratio of apples to oranges is 6 to 5, and there are 25 oranges, how many apples are there?
def solve() -> int: orange_ratio= 5 apple_ratio = 6 total_oranges = 25 total_apples = (total_oranges * apple_ratio) / orange_ratio result = total_apples return result
One pack of pasta serves 4 people. If Brian is making lasagna for 10 people, how many packs of pasta does he need?
def solve() -> int: ppl = 10 servings_per_pack = 4 num_packs = ppl/servings_per_pack result = num_packs return result
In a garden, there were 48 tulips planted in 3 rows. How many tulips are in each row?
def solve() -> int: tulips = 48 rows = 3 tulips_per_row = tulips // rows result = tulips_per_row return result
Sarah swam at 3 mph for 50 minutes. After the swim, she ran at 7 mph for 30 minutes. How many miles did she swim and run in total?
def solve() -> int: time_swam_mins = 50 time_ran_mins = 30 distance_swam = 3 * (time_swam_mins / 60) distance_ran = 7 * (time_ran_mins / 60) total_distance = distance_swam + distance_ran result = total_distance return result
Student: In 5 years, Mason will be twice as old as Addison. If Mason is currently 8 years old, what is the sum of their ages now?
def solve() -> int: mason_age = 8 addison_age = mason_age / 2 result = mason_age + addison_age return result
A company produces 3000 toys per day. Each toy costs $2 to make and sells for $5. How much profit does the company make in a day?
def solve() -> int: toys = 3000 cost_per_toy = 2 selling_price_per_toy = 5 total_revenue = toys * selling_price_per_toy total_cost = toys * cost_per_toy profit = total_revenue - total_cost result = profit return result
Daniel is making origami animals. He folds 10 cranes, 7 frogs, and 5 turtles. He uses green paper for 6 cranes, 5 frogs, and 2 turtles. What percentage of the origami animals are green?
def solve() -> int: total = 10 + 7 + 5 green = 6 + 5 + 2 percentage = (green / total) * 100 result = percentage return result
A company has 5 employees. If their average age is 35 years old, and the age of 4 employees is 30, 35, 40, and 45, how old is the fifth employee?
def solve() -> int: total_employees = 5 average_age = 35 sum_of_ages = total_employees * average_age sum_of_first_4_ages = 30 + 35 + 40 + 45 age_of_fifth_employee = sum_of_ages - sum_of_first_4_ages result = age_of_fifth_employee return result
A rectangular prism has sides of length 4cm, 5cm, and 7cm. What is the volume of the rectangular prism?
def solve() -> int: length = 4 width = 5 height = 7 result = length * width * height return result
A store has a sale for 20% off everything in the store. If an item was originally priced at $50, what is the sale price?
def solve() -> int: original_price = 50 discount_percentage = 0.2 sale_price = original_price * (1 - discount_percentage) result = sale_price return result
A piece of cloth with an area of 24 square feet was cut into two rectangular pieces. One piece is two times as long as the other. Find the length of the shorter piece.
def solve() -> int: a = 24 for i in range(1, a//2 + 1): if a % i == 0: l = i w = a / l shorter_piece = min(l, w/2) result = shorter_piece return result
Alex works full-time and earns a salary of $50,000 per year. Alex saves 40% of his salary per year. How much money does Alex save each month?
def solve() -> int: annual_salary = 50000 savings_percent = 0.4 monthly_savings = annual_salary / 12 * savings_percent result = monthly_savings return result
``` In a bag of marbles, the ratio of red to blue marbles is 3:4. If there are 21 red marbles, how many blue marbles are there?
def solve() -> int: red_marbles = 21 total_marbles = 3 + 4 blue_marbles = (total_marbles / 3) * 21 result = blue_marbles return result
A rectangular prism has a length of 4, width of 3, and height of 5. What is the volume of the prism?
def solve() -> int: length = 4 width = 3 height = 5 volume = length * width * height result = volume return result
A jar contains 9 yellow buttons, 7 red buttons, and 11 blue buttons. What is the probability of randomly drawing a red button?
def solve() -> int: total_buttons = 9 + 7 + 11 num_red_buttons = 7 probability_drawing_red_button = num_red_buttons / total_buttons result = probability_drawing_red_button return result
Sarah is baking cakes, and depending on the size of the cake, she will need different amounts of frosting. If a cake is larger than 10 inches, she will need 3 jars of frosting. If it is smaller than that, she will only need 1 jar. If she bought 30 jars of frosting with 15 small cakes, how many cakes in total did Sarah ...
def solve() -> int: small_cakes = 15 total_frosting = 30 large_cakes = (total_frosting - small_cakes) / 2 total_cakes = small_cakes + large_cakes result = total_cakes return result
A company's profits were $20,000 in the first quarter and decreased by 10% each quarter. What was the company's profit in the fourth quarter?
def solve() -> int: profit_q1 = 20000 decrease_percent = 10 decrease_factor = 1 - decrease_percent / 100 profit_q2 = profit_q1 * decrease_factor profit_q3 = profit_q2 * decrease_factor profit_q4 = profit_q3 * decrease_factor result = profit_q4 return result
Daniel climbs up 6 flights of stairs. Each flight is 9 feet. He then climbs a rope that is one-fourth that height. Finally, he climbs a ladder that is 7 feet longer than the rope. How high up did he go?
def solve() -> int: flight_height = 9 total_flights = 6 rope_height = flight_height * 1/4 ladder_height = rope_height + 7 total_height = (flight_height * total_flights) + rope_height + ladder_height result = total_height return result
arah worked 32 hours last week at a rate of $12 per hour. This week she worked 3 more hours than last week but at a pay rate of $11 per hour. How much more did she earn this week than last week?
def solve() -> int: hours1 = 32 rate1 = 12 hours2 = hours1+3 rate2 = 11 earnings1 = hours1 * rate1 earnings2 = hours2 * rate2 diff_earnings = earnings2 - earnings1 result = diff_earnings return result
John runs a coffee cart and sells lattes for $4.25. If a shot of espresso costs $0.50, milk costs $0.35 per ounce, and a cup costs $0.25, how much does it cost John to make one latte?
def solve() -> int: latte_price = 4.25 espresso_price = 0.50 milk_price = 0.35 cup_price = 0.25 espresso_cost = espresso_price milk_cost = 12 * milk_price cup_cost = cup_price total_cost = espresso_cost + milk_cost + cup_cost result = total_cost return result
A store has 600 customers per day. If 40% of the customers buy one item, 30% buy two items, and the rest buy three items, what is the average number of items purchased per customer per day?
def solve() -> int: total_customers = 600 one_item_percent = 40 two_items_percent = 30 three_items_percent = 100 - one_item_percent - two_items_percent average_items = 1*one_item_percent/100 + 2*two_items_percent/100 + 3*three_items_percent/100 result = average_items return result
Mary climbs up 4 flights of stairs. Each flight is 20 feet. She then climbs a rope that is two-thirds that height. Finally, she climbs a ladder that is 12 feet longer than the rope. How high up did she go?
def solve() -> int: flights_of_stairs = 4 height_per_flight = 20 rope_height = (2/3) * height_per_flight ladder_height = rope_height + 12 total_height = (flights_of_stairs * height_per_flight) + rope_height + ladder_height result = total_height return result
Student: In 7 years, Emma will be 5 times as old as Danny. If Emma is 15 years old today, how old is Danny today?
def solve() -> int: emma_age = 15 years_later = 7 danny_age = emma_age / 5 danny_age_in_7_years = danny_age + years_later result = danny_age_in_7_years - years_later return result
Mike wants to buy a new car stereo and speakers. He spent $800 on both items combined. He spent twice as much on the speakers as he did on the car stereo. If the car stereo costs $200, how much did Mike spend on the speakers?
def solve() -> int: car_stereo_cost = 200 total_cost = 800 speakers_cost = total_cost - car_stereo_cost result = speakers_cost return result
Possible questions: Lena and Max are making bracelets with beads. Lena uses 6 beads for each bracelet and makes 12 bracelets. Max uses 8 beads for each bracelet and makes 9 bracelets. How many more beads does Lena use than Max?
def solve() -> int: beads_lena = 6 beads_max = 8 bracelets_lena = 12 bracelets_max = 9 total_beads_lena = beads_lena * bracelets_lena total_beads_max = beads_max * bracelets_max difference = total_beads_lena - total_beads_max result = difference return resul...
Student: A shipping crate is 9 feet 8 inches by 6 feet 4 inches by 3 feet 2 inches. How many cubic feet of packing space can be utilized in the crate?
def solve() -> int: length = 9 + 8/12 width = 6 + 4/12 height = 3 + 2/12 volume = length * width * height result = volume return result
John has a collection of 95 marbles. If he gives away 30% of his marbles, how many marbles does he have left?
def solve() -> int: marbles = 95 percentage_given_away = 30 marbles_given_away = (percentage_given_away/100)*marbles marbles_left = marbles - marbles_given_away result = marbles_left return result
A pizza parlor makes 36 pizzas. If they want to make boxes of 6 pizzas in each box, how many boxes can they make?
def solve() -> int: num_pizzas = 36 pizzas_per_box = 6 num_boxes = num_pizzas // pizzas_per_box result = num_boxes return result
If Alex and Emily each order a $25 seafood platter and a $6 glass of wine, how much should Alex leave for a gratuity to cover 75% of a 18% tip for the two of them?
def solve() -> int: seafood_platter_price = 25 glass_of_wine_price = 6 tip_percentage = 18 total_bill = (seafood_platter_price + glass_of_wine_price) * 2 tip_amount = total_bill * (tip_percentage / 100) gratuity = tip_amount * 0.75 result = gratuity return result
Dave bought a bag of chips for $3.50 and paid for them with a $10 bill. After getting the chips, he received enough change to buy 3 more bags of chips. How much change did Dave get from the store keeper?
def solve() -> int: cost_1bag = 3.50 bill = 10 cost_3bag = 3 * cost_1bag change = bill - cost_3bag result = change return result
Mandy needs to buy 20 apples for her recipe, each apple costs $2.50. How much money will she need to spend overall?
def solve() -> int: apple_price = 2.50 num_apples = 20 total_cost = 0 for apple in range(num_apples): total_cost += apple_price result = total_cost return result
Maria went to the store and bought 120 flowers. She divided them equally into 6 pots. Then, she gave away 10 flowers from each pot to her friends. Afterward, she gave the remaining flowers to her mother. If Maria kept only 5 flowers, how many flowers were left?
def solve() -> int: flowers_bought = 120 pots = 6 flowers_per_pot = flowers_bought / pots flowers_given_away = 10 * pots flowers_left = flowers_bought - flowers_given_away - 5 result = flowers_left return result
Mrs. Johnson has 7 loaves of bread to share with her 35 students. If each loaf has 12 slices and everyone has 1 slice, how many slices are left?
def solve() -> int: loaves_of_bread = 7 students = 35 slices_per_loaf = 12 slices_per_student = 1 total_slices = loaves_of_bread * slices_per_loaf slices_taken = students * slices_per_student slices_left = total_slices - slices_taken result = slices_left return result
Student: Amanda has a 25-gallon aquarium and has filled it with 16 gallons of water. How much more water does Amanda need to fill the tank completely?
def solve() -> int: tank_capacity = 25 water_filled = 16 water_needed = tank_capacity - water_filled result = water_needed return result
Katie is calculating her transportation expenses for her daily errands. Her car gets 25 miles per gallon in cities and 30 miles per gallon on the highway. The distance from her house to the grocery store, one way, is 10 city miles and 20 highway miles. If gas costs $2.50 per gallon, how much will Katie need to spend in...
def solve() -> int: city_distance = 10 highway_distance = 20 city_mileage = 25 highway_mileage = 30 gas_cost = 2.50 city_gallons = city_distance / city_mileage highway_gallons = highway_distance / highway_mileage total_gallons = (city_gallons + highway_gallons) * 2 * ...
A painter can paint a room in 5 hours. If they work for 4 hours, how much of the room is painted?
def solve() -> int: hours_to_paint_room = 5 hours_worked = 4 percentage_painted = (hours_worked / hours_to_paint_room) * 100 result = percentage_painted return result
A farmer has 500 apples, and he wants to sell them in boxes of 20 apples. How many apples will be left if he sells all of the boxes he can and gives away the remainder?
def solve() -> int: num_apples = 500 apples_per_box = 20 num_boxes_sold = num_apples // apples_per_box num_apples_sold = num_boxes_sold * apples_per_box num_apples_given_away = num_apples - num_apples_sold result = num_apples_given_away return result
Tom has 15 cookies. He gives 5 cookies to his friend Jerry. Then he gets 4 more cookies from his mom. How many cookies does Tom have now?
def solve() -> int: tom = 15 jerry = 5 mom = 4 tom = tom - jerry tom = tom + mom result = tom return result
A bag of candy contains 20 pieces of chocolate and 30 pieces of gummy bears. Each piece of chocolate has 50 calories, and each piece of gummy bear has 20 calories. If a child eats 10 pieces of chocolate and 15 pieces of gummy bears from the bag, how many calories will he or she consume?
def solve() -> int: chocolate = 50 gummy_bear = 20 calories = 10 * chocolate + 15 * gummy_bear result = calories return result
Oliver has seven times as many cookies as Peter. Quincy has fourteen times as many cookies as Peter. If Quincy has 98 cookies, how many more cookies does Quincy have than Oliver?
def solve() -> int: peter_cookies = 98 / 14 oliver_cookies = peter_cookies / 7 quincy_cookies = peter_cookies difference = quincy_cookies - oliver_cookies result = difference return result
A chef can cook 20 pizzas per hour. A restaurant has a kitchen measuring 10 meters by 12 meters, and each square meter can accommodate 5 pizzas. If there are 27 working days in a month, how many chefs would it take to cook all the pizzas in the restaurant in one month?
def solve() -> int: pizzas_per_hour = 20 kitchen_area = 10 * 12 pizzas_per_square_meter = 5 working_days_per_month = 27 total_pizzas_per_hour = pizzas_per_hour * kitchen_area total_pizzas_per_day = total_pizzas_per_hour * 24 total_pizzas_per_month = total_pizzas_per_day * working_days_p...
A train traveling at 60 mph leaves a station. An hour later, another train leaves the same station on a parallel track, traveling at 80 mph. How long does it take for the second train to catch up to the first train?
def solve() -> int: distance_travelled_by_first_train = 60 distance_travelled_by_second_train = 80 speed_difference_between_trains = 80-60 time_taken_for_second_train_to_catch_up = distance_travelled_by_first_train/speed_difference_between_trains result = time_taken_for_second_train_to_catch_up ...
A rectangular prism is 12 inches long, 4 inches wide, and 2 inches high. What is the volume of the prism?
def solve() -> int: length = 12 width = 4 height = 2 volume = length * width * height result = volume return result
Imogen has $60 and she plans to purchase 10 pieces of candy. If each piece costs $2, how much money will she save?
def solve() -> int: total_money = 60 number_of_candies = 10 cost_per_candy = 2 amount_saved = total_money - (number_of_candies * cost_per_candy) result = amount_saved return result
A festival organizer declares that if the average time of a parade float exceeds 1 hour, the audience will have a discounted entry fee next year. There are 30 floats in the parade, and one encountered an accident, unable to finish the route, with an average time of 50 minutes per float. What's the minimum time needed f...
def solve() -> int: num_floats = 30 total_time = num_floats * 60 accident_time = 50 * (num_floats - 1) average_time = (total_time - accident_time) / num_floats discounted_time = (num_floats * 1 - total_time + accident_time) / 1 result = discounted_time return result
Alex drives half of the distance to work in the morning. Later in the day, he drives another 15 miles. He has now completed the 60 mile trip. How many miles did he drive in the morning?
def solve() -> int: distance_to_work = 60 distance_driven_later = 15 distance_driven_morning = (distance_to_work - distance_driven_later) / 2 result = distance_driven_morning return result
Possible new questions and python programs are: A loaf of bread weighs 400 g. A baker has just made a 12 kilogram batch of dough. How many loaves can he bake from this batch?
def solve() -> int: batch_weight = 12000 loaf_weight = 400 number_of_loaves = batch_weight // loaf_weight result = number_of_loaves return result
A car travels 360 kilometers in 4 hours. How fast is the car going in kilometers per hour?
def solve() -> int: result = 360 / 4 return result
Tom and Emily are playing a video game. Tom has scored 100 points while Emily has scored only 70 points. Emily scores another 15 points while Tom scores 32 points. By how many points is Tom still ahead?
def solve() -> int: tom_score = 100 emily_score = 70 emily_score += 15 tom_score += 32 points_ahead = tom_score - emily_score result = points_ahead return result
A toy store sells dolls for $15 each and trucks for $20 each. If someone buys 2 dolls and 3 trucks, what is the total cost?
def solve() -> int: dolls_cost = 15 * 2 trucks_cost = 20 * 3 total_cost = dolls_cost + trucks_cost result = total_cost return result
In an MLB game, a total of 20 hits and misses are made. There are three times as many hits as misses. How many hits and misses are there?
def solve() -> int: hits =0 misses = 0 total_hits_and_misses = 20 hits = total_hits_and_misses * 2/5 misses = total_hits_and_misses / 3 result = [hits, misses] return result
If you have 5 friends and each friend gives you $20, how much money did you receive?
def solve() -> int: num_friends = 5 cash_received = 20 total_cash = num_friends * cash_received result = total_cash return result
If Alex is 7 years younger than David, who is three times older than Elizabeth, and Elizabeth is 12, how old is Alex?
def solve() -> int: elizabeth_age = 12 david_age = 3 * elizabeth_age alex_age = david_age - 7 result = alex_age return result
Lisa and Emily plan to meet at the cinema. It takes 3.5 hours for Lisa to get to the cinema and it takes two times as much time for Emily to get to the cinema. If Lisa leaves her home at 2 p.m., at what time should Emily leave her home so that they both arrive at the same time?
def solve() -> int: lisa_time = 3.5 emily_time = lisa_time * 2 lisa_departure = 2 emily_departure = lisa_departure - (emily_time - lisa_time) result = emily_departure return result
The total cost of a car rental for 2 days is $160. If Jodie pays $50 upfront and wants to split the remaining cost with her friend, how much should each of them pay?
def solve() -> int: days_rented = 2 total_cost = 160 amount_paid_by_Jodie = 50 remaining_cost = total_cost - amount_paid_by_Jodie split_cost = remaining_cost / 2 result = split_cost return result
If Jack wants to buy a new TV, he has two options. The first TV costs $800, and the second TV is half as costly as the first one. How much money would Jack need to spend if he decides to purchase both TVs?
def solve() -> int: first_tv_cost = 800 second_tv_cost = first_tv_cost / 2 total_cost = first_tv_cost + second_tv_cost result = total_cost return result
Emily climbs up 7 stories of a building. Each story is 20 meters high. She then climbs a tower that is two-thirds that height. Finally, she climbs a staircase that is 15 meters longer than the tower. How high up did she go?
def solve() -> int: story_height = 20 building_stories = 7 tower_height = (2/3) * story_height staircase_height = tower_height + 15 total_height = (building_stories * story_height) + tower_height + staircase_height result = total_height return result
A bakery wants to make cupcakes for a party. The cost to make one cupcake is $2. The bakery wants to make at least 50 cupcakes. If the bakery has a budget of $100, how many cupcakes can they make?
def solve() -> int: cost_per_cupcake = 2 budget = 100 minimum_cupcakes = 50 max_cupcakes = budget // cost_per_cupcake if max_cupcakes >= minimum_cupcakes: result = minimum_cupcakes else: result = max_cupcakes return result
-**Make sure to vary the names, foods, prices, and scenarios in each question. DO NOT REPEAT THEM. ** Possible questions and programs: Lisa and Sam shared a pizza at Joe's Pizzeria. The pizza had 12 slices and cost $15. Lisa ate 3 slices and Sam ate 5 slices. They also ordered two drinks each, which cost $1.50 per drin...
def solve() -> int: pizza_cost = 15 pizza_slices = 12 lisa_slices = 3 sam_slices = 5 drink_cost = 1.50 drinks_each = 2 tip_rate = 0.15 pizza_per_slice = pizza_cost / pizza_slices lisa_pizza = pizza_per_slice * lisa_slices sam_pizza = pizza_per_slice * sam_slices total_drinks ...