question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
William saves $30 weekly in his piggy bank. When the piggy bank is full, it takes him 50 weeks. William goes to the bank to deposit the money and starts saving again. If he repeats this process 3 additional times, how much money would he have deposited?
def solve() -> int: weekly_savings = 30 weeks_to_fill = 50 piggy_bank_total = weekly_savings * weeks_to_fill num_piggy_bank_fills = 4 total_deposited = piggy_bank_total * num_piggy_bank_fills result = total_deposited return result
Michael runs 8 kilometers every Monday, Wednesday and Friday. Then he runs half as far as he ran on Monday every Tuesday and Thursday. How many kilometers will he run in a month with 4 weeks?
def solve() -> int: monday_distance = 8 tuesday_distance = monday_distance / 2 wednesday_distance = 8 thursday_distance = tuesday_distance friday_distance = 8 week_distance = monday_distance + tuesday_distance + wednesday_distance + thursday_distance + friday_distance month_distance = w...
Mary pays 20% of her annual salary for taxes and 30% of the remaining amount for her mortgage. If she spends $18,000 a year on her mortgage, what is her annual salary?
def solve() -> int: tax_percentage = 0.2 mortgage_percentage = 0.3 annual_mortgage_expense = 18000 amount_after_taxes = annual_mortgage_expense / mortgage_percentage annual_salary = amount_after_taxes / (1 - tax_percentage) result = annual_salary result return result
At 6 miles an hour, how long will it take to travel 20 miles? Round your answer to the nearest tenth.
def solve() -> int: speed = 6 distance = 20 time_in_hours = distance / speed time_in_hours_rounded = round(time_in_hours, 1) result = time_in_hours_rounded return result
Alex watches 40 minutes of tv every night during the weekdays. On the weekends, he watches an additional 2 and a half hours in total. How many hours of tv does he watch in 20 weeks?
def solve() -> int: weekday_tv = 40 weekend_tv = 2.5 * 60 weeks = 20 total_tv = (weekday_tv * 5 + weekend_tv * 2) * weeks total_tv_hours = total_tv / 60 result = total_tv_hours return result
Anne had 122 pencils, she gave away three-tenths of her pencils to Bob. She later gave away half of her remaining pencils to Craig. How many pencils does Craig have?
def solve() -> int: anne_pencils = 122 bob_pencils = anne_pencils * 0.3 craig_pencils = (anne_pencils - bob_pencils) * 0.5 craig_pencils = (122 - (122 * 0.3)) * 0.5 craig_pencils = 48 result = craig_pencils = 48 return result
Jake purchased twice the number of shirts as Matthew did. Matthew purchased three times as many shirts as Ben did. If Ben spent $18 on shirts that cost $3 each, how much money did Jake and Matthew spend on shirts altogether?
def solve() -> int: ben_shirts = 18 / 3 matthew_shirts = 3 * ben_shirts jake_shirts = 2 * matthew_shirts total_spent = ben_shirts * 3 + matthew_shirts * 3 result = total_spent return result
There are 30 candies in a jar. If 20% of them are chocolate candies, how many non-chocolate candies are in the jar?
def solve() -> int: total_candies = 30 chocolate_candies = total_candies * 0.2 non_chocolate_candies = total_candies - chocolate_candies result = non_chocolate_candies return result
On his way to work, Peter drives 24 miles at 40 miles per hour and then drives the remaining 12 miles at 60 miles per hour. Find Peter’s average speed for the entire trip.
def solve() -> int: distance_1 = 24 distance_2 = 12 speed_1 = 40 speed_2 = 60 time_1 = distance_1 / speed_1 time_2 = distance_2 / speed_2 total_time = time_1 + time_2 total_distance = distance_1 + distance_2 average_speed = total_distance / total_time result = average_speed r...
Possible new questions and python programs are: Julia has 300 blue and red candies in a jar. She takes out 20% of the candies and finds out that 15 of them are blue. How many red candies are left in the jar?
def solve() -> int: candies_out = 0.2 * 300 blue_left = (300 - candies_out) - 15 red_left = 300 - candies_out - blue_left result = red_left return result
Student: A grocery store sells apples at $0.75 per pound. If a customer buys 5.5 pounds of apples, how much will they need to pay in total?
def solve() -> int: price = 0.75 weight = 5.5 cost = price * weight result = cost return result
Three friends, Bob, Kim, and Frank ran a mile race. Bob ran twice as fast as Kim, and Kim finished 3 minutes before Frank. How much time did Bob finish the race?
def solve() -> int: speed_kim = 1 time_frank = 3 speed_bob = speed_kim * 2 time_total = speed_kim + speed_bob time_bob = time_total - time_frank result = time_bob return result
Tony and Tina bought 10 skirts that cost $25 each and 3 shorts that cost $10 each. How much will each earn if they divided their total earnings?
def solve() -> int: num_skirts = 10 cost_skirt = 25 num_shorts = 3 cost_short = 10 total_cost = (num_skirts * cost_skirt) + (num_shorts * cost_short) earnings_each = total_cost / 2 result = earnings_each return result
A recipe for banana bread requires 2 cups of flour, 3 eggs, and 4 bananas. Sara has 10 cups of flour, 12 eggs, and 16 bananas. How many loaves of banana bread can she make with her ingredients?
def solve() -> int: times_with_flour = 10 / 2 times_with_eggs = 12 / 3 times_with_bananas = 16 / 4 times_with_recipe = min(times_with_flour, times_with_eggs, times_with_bananas) result = times_with_recipe return result
Nathan wants to get in shape. He eats 2500 calories a day and burns 3000 calories a day. If he needs to burn 3500 calories to lose 1 pound how many days will it take to lose 17 pounds?
def solve() -> int: cal_needed = 59500 cal_per_day = 2500-3000 day_needed = cal_needed/abs(cal_per_day) result = day_needed return result
A car company produces 400 cars per day. If the company wants to produce 2800 cars, how many days will it take them?
def solve() -> int: cars_per_day = 400 total_cars = 2800 days = total_cars / cars_per_day result = days return result
Fred is trying to work out how much weight his car will be carrying for a road trip. His car is carrying 15 boxes of pasta that each weigh 1.5 kg, and his car weighs 1200 kg. How much weight is Fred's car carrying?
def solve() -> int: total_weight = 0 total_weight += 15*1.5 total_weight += 1200 result = total_weight return result
A pizza restaurant has 320 slices of pizza. Four-sevenths of them are cheese slices. How many slices of pizza are not cheese?
def solve() -> int: pizza_slices = 320 cheese_slices = (4/7) * pizza_slices non_cheese_slices = pizza_slices - cheese_slices result = non_cheese_slices return result
Chris wants to know how much gas he used last week. He used 5 gallons on Monday and 2 more gallons later that day. He used twice as much on Tuesday. He didn't use any on Wednesday but on Thursday he used 8 gallons. On Friday he used 20 gallons, equaling the total amount used from Monday through Thursday combined. What ...
def solve() -> int: monday_gas = 5 tuesday_gas = monday_gas * 2 wednesday_gas = 0 thursday_gas = 8 friday_gas = 20 total_gas = monday_gas + monday_gas + tuesday_gas + wednesday_gas + thursday_gas + friday_gas average_gas = total_gas / 7 result = average_gas return result
Jose is going on vacation for a week and needs to buy food supplies for the trip. He buys five boxes of noodles for $0.50 each and three cans of beans for $2 each. How much does he have to pay in total?
def solve() -> int: total = 0 noodles = 5 * 0.50 beans = 3 * 2 total = noodles + beans result = total return result
Student: A beach is littered with shells. Anna finds 19 shells by the ocean and collects another 34 from the beach. How many shells does Anna collect in total?
def solve() -> int: shells_by_ocean = 19 shells_from_beach = 34 total_shells = shells_by_ocean + shells_from_beach result = total_shells return result
Student: At the supermarket, John bought 24 boxes of cereal for his family. Each box has 225 g of cereal and his family will eat 27 g per day. How many days will all the cereal last?
def solve() -> int: box_cereal = 24 cereal_per_box = 225 cereal_per_day = 27 total_cereal = box_cereal * cereal_per_box days = total_cereal / cereal_per_day result = days return result
Ms. Parker takes 1/4 times more students from the 1st-grade class than the 2nd-grade class to the apple orchard. If there are 30 students from the 2nd-grade, how many people are at the apple orchard, including Ms. Parker and the bus driver?
def solve() -> int: second_grade_students = 30 first_grade_students = second_grade_students + (1/4 * second_grade_students) total_students = first_grade_students + second_grade_students + 2 result = total_students return result
Sarah purchased 8 pens and 3 pencils. Each pen cost $3 and each pencil cost $2. How much did Sarah spend in all?
def solve() -> int: pens = 8 pencil = 3 pen_cost = 3 pencil_cost = 2 total_pen_cost = pens * pen_cost total_pencil_cost = pencil * pencil_cost total_cost = total_pen_cost + total_pencil_cost result = total_cost return result
Possible questions and programs: A kilogram of walnuts costs $12 and is now sold at 15% off. A jar of honey that costs $8 is now sold at 10% off. How much will you pay if you buy 2 kilograms of walnuts and 3 jars of honey?
def solve() -> int: walnut_price = 12 * 0.85 honey_price = 8 * 0.9 walnut_cost = walnut_price * 2 honey_cost = honey_price * 3 total_cost = walnut_cost + honey_cost result = total_cost return result
Jenna needed 30 pens and 45 markers for her art class. If each pen costs $0.50 and each marker costs $1.50, how much did Jenna spend on all the supplies?
def solve() -> int: price_pen = 0.50 price_marker = 1.50 num_pen = 30 num_marker = 45 total_cost = (price_pen*num_pen) + (price_marker*num_marker) result = total_cost return result
Kevin is collecting stickers for his album. He has 120 stickers so far and he needs 300 to complete his album. He can buy packs of 10 stickers for $2 each or trade 5 stickers for 1 new sticker with his friends. He has $20 to spend on stickers and he wants to trade as many stickers as possible to get new ones. How many ...
def solve() -> int: current_stickers = 120 goal_stickers = 300 pack_price = 2 pack_size = 10 trade_ratio = 5 budget = 20 packs = budget // pack_price bought_stickers = packs * pack_size new_stickers = current_stickers + bought_stickers tradeable_sticker...
Maria is making a smoothie that needs 2 cups of milk. Emily is making a milkshake that requires 3 more cups of milk. How many cups of milk do they need together?
def solve() -> int: milk_for_smoothie = 2 extra_milk_for_milkshake = 3 total_milk_needed = milk_for_smoothie + extra_milk_for_milkshake result = total_milk_needed return result
Some possible questions and programs are: Sam rented a bicycle for $15 per hour. He rode the bike for 2 hours and 45 minutes and then returned it. How much more money did he pay than the minimum possible amount if he had returned the bike at an exact hour?
def solve() -> int: minutes = 45 hours = minutes / 60 rounded_hours = round(hours + 0.5) difference = rounded_hours - hours extra_cost = difference * 15 result = extra_cost return result
A pet store has a total of 150 animals. If 30% of the animals are cats and 20% of the animals are reptiles, how many animals are dogs?
def solve() -> int: cat_animals = 0.3 * 150 rep_animals = 0.2 * 150 dog_animals = 150 - cat_animals - rep_animals result = dog_animals return result
Peter earned a total of $400 for 20 hours of work. If he needs to earn $700, how many more hours does he need to work?
def solve() -> int: total_pay = 400 total_hours_worked = 20 additional_pay_required = 700 pay_per_hour = total_pay/total_hours_worked additional_hours_required = (additional_pay_required - total_pay)/pay_per_hour result = additional_hours_required return result
A rectangular pool is 20 feet long and 20% wider than it is long. What is the area of the pool in square feet?
def solve() -> int: width = 1.2 * 20 area = width * 20 result = area return result
In a group of 30 students, 18 are taking math and 12 are taking science. If 6 students are taking both math and science, how many students are not taking either class?
def solve() -> int: math_students = 18 science_students = 12 both_classes = 6 total_students = 30 neither_class = total_students - (math_students + science_students - both_classes) result = neither_class return result
Mr. Smith has a fleet of ships and he needs to buy supplies for his voyage. He calculated that his ships would need a total of 1050 engine parts and 850 extra supplies. If each ship needs 75 engine parts and 60 extra supplies, how many ships are in his fleet?
def solve() -> int: engine_parts_per_ship = 75 extra_supplies_per_ship = 60 total_engine_parts_required = 1050 total_extra_supplies_required = 850 total_ships = total_engine_parts_required // engine_parts_per_ship + total_extra_supplies_required // extra_supplies_per_ship ...
An ice cream shop charges $3 for a regular cone and $4 for a large cone. They have a special offer that gives 10% off for every 3 cones of the same size. Anna buys 9 regular cones and 6 large cones for her friends. How much does she pay?
def solve() -> int: regular = 3 large = 4 discount = 0.1 r_cones = 9 l_cones = 6 r_groups = r_cones // 3 l_groups = l_cones // 3 r_price = regular * r_cones l_price = large * l_cones total_price = r_price + l_price r_discount = regular * discount * 3 * r_groups l_d...
Student: Julia wants to bake an average of 3 cakes each day. This week she baked 2 cakes on Monday, baked 4 cakes on Tuesday and Wednesday, didn't bake anything on Thursday, baked 2 cakes on Friday and baked 3 cakes on Saturday. How many cakes does she need to bake on Sunday to meet her goal?
def solve() -> int: monday = 2 tuesday = 4 wednesday = 4 thursday = 0 friday = 2 saturday = 3 total_cakes = monday + tuesday + wednesday + thursday + friday + saturday goal = 7 * 3 difference = goal - total_cakes result = difference return result
A book has 500 pages. If someone reads 25 pages every day, calculate the number of days it will take them to finish the book.
def solve() -> int: total_pages = 500 pages_read_daily = 25 total_days = total_pages/pages_read_daily result = total_days return result
If a book cost $15.80 and there is 10% tax, what is the total cost of the book?
def solve() -> int: book_cost = 15.80 tax_rate = 0.10 tax_amount = book_cost * tax_rate total_cost = book_cost + tax_amount result = total_cost return result
A bookstore sells books for an average of $15. If the bookstore sells 200 books in a month, how much do they earn?
def solve() -> int: num_books = 200 avg_price = 15 earnings = num_books * avg_price result = earnings return result
Jason has $98 to spend. He buys two pencils for 29 cents each and a calculator for $62. How much money does Jason have left?
def solve() -> int: cost_pencils = 0.29 * 2 cost_calculator = 62 total_cost = cost_pencils + cost_calculator remaining_money = 98 - total_cost result = remaining_money return result
A pet store has 8 puppies and 5 cats. If they are moved into new cages with 3 animals each, how many cages will they need?
def solve() -> int: animals = 8 + 5 animals_per_cage = 3 num_of_cages = animals // animals_per_cage + (animals % animals_per_cage > 0) result = num_of_cages return result
If a rectangle has a length of 8 cm and a width of 3 cm, what is its area?
def solve() -> int: length = 8 width = 3 area = length * width result = area return result
If Kim cycles at a pace of 15 mph for 45 minutes and then at a pace of 20 mph for an hour and fifteen minutes, how far has she traveled in total?
def solve() -> int: time1 = 0.75 pace1 = 15 distance1 = time1 * pace1 time2 = 1.25 pace2 = 20 distance2 = time2 * pace2 total_distance = distance1 + distance2 result = total_distance return result
arah has 82 marbles in her basket. If 25% of them are blue, how many non-blue marbles does Sarah have?
def solve() -> int: total_marbles = 82 percent_blue = 0.25 blue_marbles = total_marbles * percent_blue non_blue_marbles = total_marbles - blue_marbles result = non_blue_marbles return result
8. Gus and Paul have a total of 144 cards between them. Gus has traded 6 of his cards for 8 of Paul's cards. Paul has taken 14 of Gus's cards and given 9 of his own cards in return for 12 of Gus's cards. How many cards do Gus and Paul have each now?
def solve() -> int: cards_gus = 144 cards_paul = 144 cards_gus = cards_gus - 6 cards_paul = cards_paul - 14 cards_gus = cards_gus + 8 cards_paul = cards_paul + 12 result = [cards_gus, cards_paul] return result
A grocery store has 540 blocks of cheese in stock. How many blocks of cheese are needed to reach half of the inventory?
def solve() -> int: initial_total = 540 percent_needed = 50 percent_needed = (percent_needed / 100) * initial_total blocks_needed = initial_total - percent_needed result = blocks_needed return result
Olivia's first exam had a grade of 90. After the second exam, her average became 85. What score did she get in her second exam?
def solve() -> int: first_exam_grade = 90 average_after_second_exam = 85 second_exam_grade = (average_after_second_exam * 2) - first_exam_grade result = second_exam_grade return result
A school has 20 classrooms and 400 students. If each classroom has the same number of students, how many students are in each classroom?
def solve() -> int: num_classrooms = 20 num_students = 400 students_per_classroom = num_students / num_classrooms result = students_per_classroom return result
Sam is planning a vacation and needs to book a hotel. The hotel room costs $200 per night but he has a 15% discount on the total. How much does Sam have to pay for a seven-night stay?
def solve() -> int: room_cost = 200 discount = 0.15 num_nights = 7 total_cost = room_cost * num_nights discount_amount = total_cost * discount final_cost = total_cost - discount_amount result = final_cost return result
Kelly reads 3 books a week. Lola reads 3 times as many books a week as Kelly. How many more books does Lola read compared to Kelly?
def solve() -> int: kelly_books = 3 lola_books = kelly_books * 3 more_books = lola_books - kelly_books result = more_books return result
Student: John had 240 marbles. He gave away 1/4 of them to his friends and sold 2/3 of the rest. How many marbles did he have left?
def solve() -> int: total_marbles = 240 gave_away = total_marbles / 4 sold = (total_marbles - gave_away) * 2 / 3 left = total_marbles - gave_away - sold result = left return result
Caroline is ordering balloons for her birthday party. Each package comes with 12 balloons. If she needs 50 balloons, how many packages should she order?
def solve() -> int: num_balloons_per_pack = 12 num_balloons_needed = 50 num_packs = num_balloons_needed // num_balloons_per_pack + 1 result = num_packs return result
If I earn $15 per hour and work 5 hours per day, 6 days per week, how much money will I earn in a month (assume a month has 4 weeks)?
def solve() -> int: hourly_rate = 15 hours_per_day = 5 days_per_week = 6 money_per_day = hourly_rate * hours_per_day money_per_week = money_per_day * days_per_week weeks_per_month = 4 money_per_month = money_per_week * weeks_per_month result = money_per_month return result
A bakery sells 250 cakes every month, each cake costs $10. The bakery decides to introduce 15 new flavors and 20 more employees. How much money does the bakery earn for the month after the new hires?
def solve() -> int: number_cakes_before = 250 number_cakes_after = 500 price_per_cake = 10 number_employees = 20 total_payment = number_cakes_after * price_per_cake + number_employees * 20 result = total_payment return result
Student: Ben divided 36 candies into 6 bags. The first bag had 3 candies. The second bag had 2 candies more than the first bag. The third bag had 1 candy less than the second bag, and the fourth bag had 3 candies more than the third bag. If the fifth bag had 4 candies less than the fourth bag, how many candies did the ...
def solve() -> int: candies = 36 bags = 6 first_bag = 3 second_bag = first_bag + 2 third_bag = second_bag - 1 fourth_bag = third_bag + 3 fifth_bag = fourth_bag - 4 sixth_bag = candies - (first_bag + second_bag + third_bag + fourth_bag + fifth_bag) result = sixth_bag retur...
A printer can print 100 pages in 5 minutes. How long will it take to print 600 pages?
def solve() -> int: pages_per_minute = 100/5 minutes_to_print_600_pages = 600/pages_per_minute result = minutes_to_print_600_pages return result
Lily had 18 cupcakes. She baked 6 more cupcakes and then sold half of them at a bake sale. She gave 4 cupcakes to her friend and ate 2 herself. How many cupcakes, in total, did Lily have left?
def solve() -> int: cupcakes = 18 cupcakes = cupcakes + 6 sold_cupcakes = cupcakes / 2 cupcakes = cupcakes - sold_cupcakes cupcakes = cupcakes - 4 - 2 result = cupcakes return result
Possible new questions: Alice wants to bake a cake for her friend's birthday. She needs 4 eggs, 2 cups of flour, 1 cup of sugar, and 1/2 cup of oil for the recipe. She has 10 eggs, 5 cups of flour, 3 cups of sugar, and 1 cup of oil in her kitchen. How many cakes can she bake with the ingredients she has?
def solve() -> int: eggs_per_cake = 4 flour_per_cake = 2 sugar_per_cake = 1 oil_per_cake = 0.5 eggs_available = 10 flour_available = 5 sugar_available = 3 oil_available = 1 cakes_with_eggs = eggs_available // eggs_per_cake cakes_with_flour = flour_available // flour_per_cake ...
A car rental company charges $25 per day and $0.15 per mile. You rent a car for 3 days and drive 200 miles. How much do you have to pay?
def solve() -> int: price_per_day = 25 price_per_mile = 0.15 num_days_rented = 3 num_miles_driven = 200 total_price = num_days_rented * price_per_day + num_miles_driven * price_per_mile result = total_price return result
Student: A school has 240 students and 12 teachers. Each teacher is assigned to a class of 20 students. One day, 8 students and 1 teacher are absent. The principal decides to merge two classes into one and assign the remaining teacher to the merged class. How many students are in the merged class?
def solve() -> int: students = 240 teachers = 12 class_size = 20 absent_students = 8 absent_teachers = 1 merged_class_size = class_size * 2 - absent_students result = merged_class_size return result
If it takes Jack 3 hours to paint a room by himself, but 4 hours if he's painting the room with his friend, how much longer would it take him to paint 5 rooms with his friend?
def solve() -> int: jack_time = 3 friend_time = 4 num_rooms = 5 time_per_room = 1 / (1/jack_time + 1/friend_time) total_time = time_per_room * num_rooms result = total_time return result
Possible questions and programs are: Lila and Matt order a pizza for $8, two salads for $4 each, and three lemonades for $1.50 each. The tip is 15% of the bill. They pay with a $20 bill. How much change should they get?
def solve() -> int: bill = 8 + 4 * 2 + 1.5 * 3 tip = 0.15 * bill total = bill + tip change = 20 - total change = round(change, 2) result = change return result
In a movie theater, 480 tickets were sold for a movie premiere. On average, how many tickets were sold for each of the 8 cinemas in the theater?
def solve() -> int: total_tickets = 480 total_cinemas = 8 tickets_per_cinema = total_tickets/total_cinemas result = tickets_per_cinema return result
A toy store had a sale of stuffed animals. Fen and Joe wanted to buy a few each. Fen bought 12 stuffed animals, Joe bought two times more than Fen, and then they bought 6 times more stuffed animals than the amount that both Fen and Joe bought. How many stuffed animals did they buy in total?
def solve() -> int: total_stuffed_animals = 0 total_stuffed_animals += 12 total_stuffed_animals += 12*2 total_stuffed_animals += 12*2*6 result = total_stuffed_animals return result
Harper is playing a game of dice. He rolls a die 4 times and get the results as 3, 5, 1 and 6. What is the probability that Harper gets at least one 6 when he rolls the die 4 times?
def solve() -> int: total_outcomes = 6*6*6*6 count_1_6 = 6 count_2_6 = 15 count_3_6 = 20 count_4_6 = 6 favorable_outcomes = count_1_6 + count_2_6 + count_3_6 + count_4_6 probability = favorable_outcomes / total_outcomes result = probability return result...
A rectangular garden is 12 meters long and 8 meters wide. What is the perimeter of the garden?
def solve() -> int: length = 12 width = 8 perimeter = 2 * (length + width) result = perimeter return result
Student: Alice and Bob went to the bookstore together. Alice bought 12 books. Bob bought 3 times as many books as Alice. Bob then gave away 4 of them to his friends and donated 1/6 of them to the library. How many books does Bob have left?
def solve() -> int: alice_books = 12 bob_books = alice_books * 3 bob_books = bob_books - 4 bob_books = bob_books - bob_books / 6 result = bob_books return result
A hotel has 75 rooms. If each room is occupied by an average of 2.5 people, how many people are staying at the hotel?
def solve() -> int: rooms = 75 people_per_room = 2.5 total_people = rooms * people_per_room result = total_people return result
ally bakes 5 loaves of bread at 375°F for 12 minutes. How much time should she bake if she wants to make 10 loaves of bread at the same temperature?
def solve() -> int: time = 0 loaf = 0 while loaf < 10: loaf = loaf + 1 time = time + 12 result = time return result
- Nina ran 342 meters in a race. She ran 15 more than twice the distance of Mia. How far did Mia run in the same race?
def solve() -> int: nina = 342 mia = (nina - 15) / 2 result = mia return result
Rachel wants to buy a new TV. The unadjusted price of the TV she wants is $1,000. The store provides a discount based on Rachel's loyalty: 30% off if she has been a loyal customer for over 5 years, 15% off if she has been a loyal customer for over 2 years, and no discount if she is a new customer. Rachel earns $60/hour...
def solve() -> int: years_as_customer = 4 unadjusted_price = 1000 if years_as_customer > 5: discount = 0.3 elif years_as_customer > 2: discount = 0.15 else: discount = 0 adjusted_price = unadjusted_price - (unadjusted_price * discount) hours_per_week = ...
A recipe calls for 2 cups of flour but you only have 1.5 cups. If you reduce all the other ingredients proportionally, how many cups of milk should you use if the original recipe calls for 3 cups of milk?
def solve() -> int: flour_needed = 2 flour_available = 1.5 milk_needed = 3 proportion = flour_available / flour_needed milk_available = proportion * milk_needed result = milk_available return result
Sarah wants to buy a new laptop for her online schoolwork. If she has a budget of $1,500 and the laptop she wants costs $1,200, how much money will she have left for additional computer software?
def solve() -> int: budget = 1500 laptop_cost = 1200 additional_software_cost = budget - laptop_cost result = additional_software_cost return result
Emma paints 2 walls an hour. If she paints 12 walls in a day, how many days will it take her to paint 60 walls?
def solve() -> int: total_walls = 60 walls_per_hour = 2 hours_per_day = 6 walls_per_day = walls_per_hour * hours_per_day days = total_walls / walls_per_day result = days return result
Lily had 25 candies. She ate 7 candies and gave 4 candies to her brother. She received 8 more candies from her grandma and 6 more candies from her aunt. Then she divided the remaining candies equally among 5 friends. How many candies did each friend get?
def solve() -> int: candies = 25 candies = candies - 7 candies = candies - 4 candies = candies + 8 candies = candies + 6 candies_per_friend = candies // 5 remainder = candies % 5 result = candies_per_friend return result
Pineapples have 100 calories and cost $2 each. If Maria has $20 and needs to make sure she gets 1000 calories, how many pineapples does she need to buy?
def solve() -> int: num_calories = 1000 cal_per_pineapple = 100 cost_per_pineapple = 2 budget = 20 num_pineapples = num_calories // cal_per_pineapple if num_calories % cal_per_pineapple!= 0: num_pineapples += 1 result = num_pineapples return result
A box contains 10 red balls, 8 blue balls, and 12 green balls. What is the probability that a ball chosen at random is green?
def solve() -> int: total_balls = 10 + 8 + 12 green_balls = 12 probability = green_balls / total_balls result = probability return result
Miley realized she did not need 600 grams of blue cheese after all. To save money, she decided to buy 500 grams of blue cheese instead. How much money did she save from this decision?
def solve() -> int: price_blue = 8 grams_initial = 600 grams_changed = 500 total_initial = price_blue * grams_initial total_changed = price_blue * grams_changed saved_money = total_initial - total_changed result = saved_money return result
How many of the 30 students in the teacher's class prefer cats over dogs?
def solve() -> int: total_students = 30 students_dogs_video_games = 30 * 0.5 students_dogs_movies = 30 * 0.1 result = total_students - (students_dogs_video_games + students_dogs_movies) return result
If 2 bags of flour weigh as much as 1 bag of sugar and 1 bag of sugar weighs 30 kg, how much do 5 bags of flour weigh in pounds?
def solve() -> int: sugar_weight_kilo = 30 num_flour_bags = 5 sugar_weight_pound = sugar_weight_kilo * 2.20462 flour_weight_pound = (sugar_weight_pound / 2) * num_flour_bags result = flour_weight_pound return result
Jack had 48 toy cars. He gave 4 toy cars each to 6 friends. He gave his neighbor 6 more toy cars than he gave his friends in total. Then, he gave his little brother 12 less toy cars than he gave his neighbor. How many toy cars does Jack have left?
def solve() -> int: toy_cars = 48 cars_per_friend = 4 num_friends = 6 total_cars_friends = cars_per_friend * num_friends cars_to_neighbor = total_cars_friends + 6 cars_to_brother = cars_to_neighbor - 12 leftover_cars = toy_cars - total_cars_friends - cars_to_neighbor - cars_to_brother ...
A daycare has 30 children. The children want to make friendship bracelets. They have 400 beads in total. They want to have the same number of beads for each bracelet. How many beads will be left when they have distributed them as much as possible in equal amounts?
def solve() -> int: children = 30 beads = 400 result = beads % children return result
A piece of ribbon is 2 feet long. If it is cut into pieces that are each 1/6 of a foot long, how many pieces of ribbon are there?
def solve() -> int: ribbon_length = 2 piece_length = 1/6 num_pieces = ribbon_length/piece_length result = num_pieces return result
Peter got a $20000 bonus from his company and wanted to spend it prudently. He used half of the bonus to pay off his student loans, then put 40% of the remaining in his retirement fund. He invested 15% of that in bonds. If Peter already had $5000 in his retirement account, how much money does he have left to spend?
def solve() -> int: bonus = 20000 student_loans = bonus / 2 remaining = bonus - student_loans retirement_fund = remaining * 0.4 bonds = retirement_fund * 0.15 retirement_account = 5000 money_left = remaining - retirement_fund - bonds - retirement_account result = money_left retu...
A gym has 8 treadmills, 7 bikes and 5 ellipticals. What is the probability of selecting a treadmill or an elliptical?
def solve() -> int: total_equipment = 8 + 7 + 5 t_or_e_p = (8 + 5) / total_equipment result = t_or_e_p return result
John has 60 tennis balls. He gives 1/3 of them to his brother. How many tennis balls does he have left?
def solve() -> int: john_balls = 60 fraction_given = 1/3 balls_given = john_balls * fraction_given balls_left = john_balls - balls_given result = balls_left return result
Michael wants to surprise his coworkers with donuts for breakfast. There are 12 coworkers in Michael's office, including himself. Michael wants to get 2 donuts for each coworker, since they are a delicious breakfast treat. Each box of donuts has 6 donuts. How many boxes should Michael buy?
def solve() -> int: coworkers = 12 donuts_per_coworker = 2 donuts_per_box = 6 total_donuts_needed = coworkers * donuts_per_coworker boxes_needed = total_donuts_needed // donuts_per_box result = boxes_needed return result
Sarah spends $50 on 4 bags of apples, $20 on 2 bags of oranges and $40 on 5 bags of bananas. If each bag of apples has 4 apples, each bag of oranges has 3 oranges and each bag of bananas has 6 bananas, how much does each fruit cost?
def solve() -> int: total_apples = 4 * 4 total_oranges = 2 * 3 total_bananas = 5 * 6 cost_per_apple = 50 / total_apples cost_per_orange = 20 / total_oranges cost_per_banana = 40 / total_bananas result = round(cost_per_apple + cost_per_orange + cost_per_banana, 2) return result
A cyclist rides 25 miles per hour for the first hour of their trip and 20 miles per hour for the second hour. What is their average speed for the entire trip?
def solve() -> int: distance_first_hour = 25 distance_second_hour = 20 total_distance = distance_first_hour + distance_second_hour total_time = 2 average_speed = total_distance / total_time result = average_speed return result
Student: A square has a side length of 5cm. What is the perimeter of the square?
def solve() -> int: side_length = 5 perimeter = 4 * side_length result = perimeter return result
Possible new questions and programs: Lina spent $45 on a dress and $12 on a pair of earrings. She had $100 in her wallet before going shopping. How much money does Lina have left?
def solve() -> int: total_spent = 45 + 12 money_left = 100 - total_spent result = money_left return result
For the charity sale, Horatio bought 24 boxes of cookies. He sold 4 boxes and gave 2 to each of his friends. How many boxes of cookies did each friend get?
def solve() -> int: sale = 4 boxesPerFriend = 2 result = boxesPerFriend return result
Jake's family was planning a cookout. Each bag of burgers costs $5 and each package of buns costs $2. If they have $40, how many bags of burgers and packages of buns can they buy?
def solve() -> int: price_burgers = 5 price_buns = 2 amount = 40 num_burgers = amount // price_burgers num_buns = amount // price_buns result = num_burgers, num_buns return result
A train leaves the station and travels at a constant speed of 80 km/h. After 2 hours, a motorcycle leaves the same station and travels on the same route at a constant speed of 120 km/h. How long does it take for the motorcycle to catch up with the train?
def solve() -> int: train_distance = 160 train_speed = 80 motorcycle_speed = 120 relative_speed = motorcycle_speed - train_speed time = train_distance/relative_speed result = time return result
A box of pencils costs $30. If there are 5 pencils in the box, how much does each pencil cost?
def solve() -> int: box_cost = 30 total_pencils = 5 pencil_cost = box_cost / total_pencils result = pencil_cost return result
Dana has 20 candies and she wants to share them equally with her two friends. However, she decides to eat 4 candies before giving any to her friends. How many candies does each friend get?
def solve() -> int: total_candies = 20 dana_candies = 4 remaining_candies = total_candies - dana_candies friends = 2 friend_candies = remaining_candies / friends result = friend_candies return result
At a bake sale, Sarah sold 30 cupcakes on the first day. After two days, she realized that she had sold three times the number of cupcakes she had sold on the first day. If Sarah sold 90 more cupcakes after another three days, determine the total number of cupcakes she sold at the bake sale.
def solve() -> int: first_day = 30 second_day = first_day * 3 third_day = second_day * 3 fourth_day = third_day + 90 total_cupcakes_sold = first_day + second_day + third_day + fourth_day result = total_cupcakes_sold return result
In a bag of marbles, half of them are blue and 30% of the blue ones have a swirl pattern. If there are 45 marbles with the swirl pattern, how many marbles are in the bag?
def solve() -> int: blue_marbles = 45 / 0.3 total_marbles = blue_marbles * 2 result = total_marbles return result
In a toy store, there are 120 stuffed animals on a shelf. 4 children each grab 3 animals from the shelf to play with, then another 25 animals are sold the next day. How many stuffed animals are left on the shelf?
def solve() -> int: shelf = 120 children = 4 animals_per_child = 3 sold_animals = 25 grabbed_animals = children * animals_per_child animals_left = shelf - grabbed_animals final_animals_left = animals_left - sold_animals result = final_animals_left return result
Kevin and Lily each bought bags of dog food and cat food. Kevin paid $15 for 2 bags of dog food and 3 bags of cat food. Lily paid $10 for 1 bag of dog food and 2 bags of cat food. What is the cost of one bag of cat food?
def solve() -> int: dog_food_price = 15 / (2 + 3) cat_food_price = 10 / (1 + 2) result = cat_food_price return result