question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
Student: A car dealership orders 120 cars for the month. At the end of 3 weeks, 80% of the cars have been sold. How many cars are left to be sold?
def solve() -> int: total_cars = 120 percent_sold = 0.8 cars_sold = total_cars * percent_sold cars_left = total_cars - cars_sold result = cars_left return result
A fruit vendor has 80 apples and 60 oranges. If the vendor wants to create fruit baskets with an equal number of apples and oranges in each basket, what is the largest number of baskets that can be made?
def solve() -> int: num_apples = 80 num_oranges = 60 num_fruit_per_basket = 2 largest_num_of_baskets = min(num_apples, num_oranges) // num_fruit_per_basket result = largest_num_of_baskets return result
Matt went to the store. On the way to the store he had 4 apples. On the way back from the store he had 6 apples. What was the total number of apples Matt had?
def solve() -> int: apples_before = 4 apples_after = 6 result = apples_before + apples_after return result
The volume of a rectangular prism is 324 cubic inches. If the length and the width of the base are both 9 inches, what is the height of the prism?
def solve() -> int: length = 9 width = 9 volume = 324 height = volume / (length * width) result = height return result
Tyler is making a smoothie. The recipe calls for strawberries. To make the strawberries Tyler is going to blend 2 pints of strawberries into small pieces and then add them to the blender. First he blends each pint of strawberries in half, then blends those halves in half. How many small strawberry pieces is Tyler going...
def solve() -> int: pints_of_strawberries = 2 halves_of_pints = pints_of_strawberries * 2 small_pieces = halves_of_pints * 2 result = small_pieces return result
Student: A school enforces students to have two examinations every month and deducts 10% from their final score for failing to show up for an examination. If Sanya got a 100 on the first examination but missed the second, what is Sanya's deduction as a percentage of her final score?
def solve() -> int: first_exam_score = 100 deduction_percentage = 10 deduction = deduction_percentage / 100 final_score = first_exam_score - (first_exam_score * deduction) result = (first_exam_score - final_score) / final_score * 100 return result
Some possible questions and programs are: Nia loves to bake cakes and sell them at the school fair. She needs at least $50 to buy ingredients for her next batch of cakes. She sells each cake for $6 and spends $2 on the ingredients. How many cakes does she need to sell to reach her goal?
def solve() -> int: cake_price = 6 cake_cost = 2 goal = 50 profit = cake_price - cake_cost cakes = goal // profit remainder = goal % profit if remainder > 0: cakes += 1 result = cakes return result
Ella is making bracelets with beads. She needs 12 blue beads and 8 red beads for each bracelet. She has 120 blue beads and 64 red beads. How many bracelets can she make with all her beads?
def solve() -> int: blue_needed = 12 red_needed = 8 blue_available = 120 red_available = 64 blue_bracelets = blue_available // blue_needed red_bracelets = red_available // red_needed bracelets = min(blue_bracelets, red_bracelets) result = bracelets return result
QUESTION 3: You want to buy 5 books. The store is running a 25% off sale and the books normally retail for $19.50 each. If there is a 9% tax, how much will you need to pay for all of them?
def solve() -> int: price = 19.50 discount = 0.25 tax = 0.09 total = price * 5 discount_amount = total * discount total_after_discount = total - discount_amount tax_amount = total_after_discount * tax final_price = total_after_discount + tax_amount result = final_price retu...
An electric car can travel 100 miles on a single charge. If the car has already traveled 20 miles, how many more miles can it travel until it needs to be charged?
def solve() -> int: distance_car_can_travel_on_single_charge = 100 distance_already_traveled = 20 distance_remaining_on_current_charge = distance_car_can_travel_on_single_charge - distance_already_traveled result = distance_remaining_on_current_charge return result
Jessica wants to make a holiday wreath using pinecones and ornaments. She needs 60 pinecones and 80 ornaments. If Jessica has already collected 30 pinecones, how many ornaments does she still need to collect?
def solve() -> int: pinecones_needed = 60 ornaments_needed = 80 pinecones_collected = 30 pinecones_remaining = pinecones_needed - pinecones_collected ornaments_remaining = ornaments_needed - pinecones_remaining result = ornaments_remaining return result
If it takes Clara 4 minutes to raise her kite 120 feet into the air, how many feet can she raise in 6 minutes if she raises it at a rate of 5 feet per second?
def solve() -> int: clara_minutes_elapsed = 0 clara_feet_raised = 0 while clara_minutes_elapsed < 4: clara_minutes_elapsed += 1 clara_feet_raised += 30 clara_feet_raised_in_six_minutes = 0 while clara_minutes_elapsed < 6: clara_minutes_elapsed += 1 c...
An ice cream shop serves 30 flavors of ice cream, each scoop costing $3. If a customer buys 9 scoops, how much money will they have to pay?
def solve() -> int: num_flavors = 30 scoop_cost = 3 scoops_bought = 9 total_payment = scoops_bought * scoop_cost result = total_payment return result
Student: Nancy invested $20000 into a trust fund that earns an annual interest rate of 4.5%. How much money will Nancy have in her trust fund after 10 years?
def solve() -> int: principal = 20000 rate = 0.045 time = 10 result = principal * (1 + rate)**time return result
Michael earns $20 per hour. He worked 8 hours a day for 7 days. After paying for his daily expenses, he saved $200. How much did he spend during the 7 days?
def solve() -> int: hours_worked = 8*7 total_earnings = hours_worked*20 money_spent = total_earnings - 200 result = money_spent return result
Emily spent $45 buying a new dress, 2 pairs of shoes, and 3 necklaces. If the shoes cost $12 per pair and the necklaces cost $5 each, how much did the dress cost?
def solve() -> int: dress_cost =... result = dress_cost return result
A company needs to transport steel plates. They have 6 trucks. Three of them can each carry 10,000 pounds of steel plates. One truck carries 30% less weight than that. The remaining trucks have a total capacity that is 50% larger than the capacity of the other trucks combined. How many pounds of steel plates can the co...
def solve() -> int: truck_capacity = 10000 truck_capacity_less = truck_capacity - (truck_capacity * 0.3) remaining_trucks_capacity = (truck_capacity + truck_capacity_less) * 1.5 total_capacity = (3 * truck_capacity) + truck_capacity_less + remaining_trucks_capacity result = total_capacity ...
Mary bought a number of pens and pencils for $45. She bought twice as many pens as pencils and each pencil costs $1.50. How many pens did she buy?
def solve() -> int: total_cost = 45 pencil_cost = 1.5 num_pencils = total_cost/(2*pencil_cost+1) num_pens = 2*num_pencils result = num_pens return result
A pizza chef used 3 cups of flour, 1 cup of water, and 2 teaspoons of yeast to make pizza dough. If the recipe is doubled, how many teaspoons of yeast are needed?
def solve() -> int: flour = 3 water = 1 yeast = 2 flour *= 2 water *= 2 yeast *= 2 yeast_needed = yeast / 3 * 2 result = yeast_needed return result
Sarah and her sister were selling lemonade. Sarah sold 30 cups and her sister sold 25 cups. Sarah wanted to sell at least 10 more cups than her sister. How many more cups does Sarah need to sell if her sister sells 6 more cups?
def solve() -> int: sarah_cups_sold = 30 sister_cups_sold = 25 sarah_wants_more_cups = 10 sister_additional_cups = 6 sarah_total_cups_sold = sarah_cups_sold + sister_additional_cups sarah_additional_cups_needed = sarah_wants_more_cups - sister_additional_cups result = sarah_additio...
Michael has a coin collection that consists of 25 quarters, 12 dimes, and 6 nickels. If he gives away 10 quarters to his little brother and finds 3 more nickels on the street, how many coins does Michael have left?
def solve() -> int: quarters = 25 dimes = 12 nickels = 6 quarters -= 10 nickels += 3 total_coins = quarters + dimes + nickels result = total_coins return result
Christopher has five times as many stickers as Cindy. Cindy has 6 more than Carly, who has 36 stickers. How many stickers do Christopher and Carly have in total?
def solve() -> int: carly_stickers = 36 cindy_stickers = carly_stickers + 6 christopher_stickers = 5 * cindy_stickers total_stickers = carly_stickers + christopher_stickers result = total_stickers return result
A parking lot has a ratio of 2 handicapped spaces to every 7 regular spaces. If there are 56 regular parking spots in the lot, how many handicapped spaces are there?
def solve() -> int: regular_spaces = 56 handicapped_spaces = (2/7) * regular_spaces result = handicapped_spaces return result
ally runs for one hour and thirty minutes every day and she fishes for twenty minutes every day. How much total time does Sally spend on these two activities every day?
def solve() -> int: total_minutes = 0 total_minutes += 90 total_minutes += 20 result = total_minutes return result
James sells 100 t-shirts every week at his store. He wants to sell an additional 50 t-shirts per week. How many t-shirts will James sell each week if he sells an additional 50 t-shirts per week?
def solve() -> int: t_shirts_per_week = 100 additional_t_shirts_per_week = 50 total_t_shirts_per_week = t_shirts_per_week + additional_t_shirts_per_week result = total_t_shirts_per_week return result
David bought four books at the bookstore. The first was double the price of the second. The third and fourth book both cost the same as the second. If the total price of all the books was $52, how much did each book cost?
def solve() -> int: total = 52 book2 = total / 4 book1 = book2 * 2 book3 = book2 book4 = book2 result = round(book1, 2), round(book2, 2), round(book3, 2), round(book4, 2) return result
Ingrid went shopping and bought 6 items with her sister. The cost of each item Ingrid got was twice as much as the items her sister got. Ingrid and her sister paid a total of $180 for the items. How much did Ingrid pay for her items?
def solve() -> int: ingrid_items = 0 sister_items = 0 total = 180 ingrid_items = 2 * sister_items total_amount = ingrid_items + sister_items if total == total_amount: result = ingrid_items else: result = "incorrect" return result
If Rosie has 6 more oranges than 8 times the number of apples she has and she has 62 oranges, how many apples does she have?
def solve() -> int: apples = (62 - 6) / 8 result = apples return result
Rachel has to drive 4 miles to her office and 2 miles to the bank. If she drives to her office 6 times a week and goes to the bank once a week, what distance does she travel in her car in a week?
def solve() -> int: office_distance = 4 bank_distance = 2 office_trips_per_week = 6 bank_trips_per_week = 1 total_distance = (office_distance * office_trips_per_week) + (bank_distance * bank_trips_per_week) result = total_distance return result
Evan has been depositing $100 more each month for 2 years longer than he deposited during the previous year. If he was depositing $300 per month in the previous year, and he's now depositing 15% more, what is the total amount he has deposited in both periods? Ashley buys 15 puppies for $50 each. They grow to be 60 poun...
def solve() -> int: prev_year_deposit = 300 * 12 curr_year_deposit = (300 + 0.15 * 300 + 100) * 12 total_deposits = prev_year_deposit + curr_year_deposit cost_to_buy = 15 * 50 revenue_from_sale = 15 * 60 * 3 profit = revenue_from_sale - cost_to_buy result = tota...
In a class with 30 students, 9 students are wearing jeans, 12 are wearing shorts and the rest are wearing skirts. Tim randomly picks one student, exchanges their outfit, and then picks another student. What is the probability of the second student wearing jeans?
def solve() -> int: def calculate_probability(): total_students = 30 jeans_students = 9 probability = jeans_students/total_students result = probability return result result = calculate_probability() return result
Question Y: New question (without the solution)... Here are 10 possible math questions and their corresponding Python programs: Neil and his father go to the pet store and buy 8 bags of dog food for their two dogs. Each bag weighs 5 kgs and can feed both dogs for a week. However, when they get home, they realize that t...
def solve() -> int: bags = 8 weight = 5 dogs = 2 weeks = 4 extra_dogs = 2 total_food = bags * weight food_per_dog = total_food / (dogs * weeks) food_needed = food_per_dog * (dogs + extra_dogs) * weeks bags_needed = food_needed / weight additional_bags = bags_needed - bags ...
Julia is making lemonade. Each glass of lemonade requires 50 mL of lemon juice. If she wants to make 3 liters of lemonade, how many milliliters of lemon juice does she need?
def solve() -> int: lemonade_liters = 3 liters_to_milliliters = 1000 lemon_juice_milliliters = lemonade_liters * liters_to_milliliters * 50 result = lemon_juice_milliliters return result
Ten tulip flowers cost $30 more than a single rose flower. If three rose flowers cost $15, how much would you pay for five tulip flowers?
def solve() -> int: rose_price = 15 / 3 tulip_price = rose_price + 30 total_cost = tulip_price * 5 result = total_cost return result
Student: Carlos spent 8 hours installing 24 cabinets. How many hours did it take him to install 42 cabinets?
def solve() -> int: hours = 8 cabinets = 24 target = 42 rate = cabinets / hours hours_needed = target / rate result = hours_needed return result
John has 10 dollars. He spends 3 dollars on candy and then earns 7 dollars for washing the dishes. How much money does John have now?
def solve() -> int: money = 10 money -= 3 money += 7 result = money return result
A bakery sells cakes for $25 each. If a customer buys 4 cakes, the bakery gives them a 10% discount. What is the total cost of 4 cakes after the discount is applied?
def solve() -> int: cakes_price = 25 number_of_cakes = 4 total_cost = cakes_price * number_of_cakes if number_of_cakes == 4: discount = total_cost * 0.1 total_cost -= discount result = total_cost return result
Student: Mike gets paid $13 an hour for the first 28hours he works each week, and $22 each hour of overtime after that. If Mike worked 76 hours one week, how much money did he make?
def solve() -> int: hours_worked = 76 regular_pay = 13 * 28 overtime_pay = 22 * (hours_worked - 28) result = regular_pay + overtime_pay return result
Tom is painting his house. For every 15 walls he paints, he needs to buy more paint. It costs him $20 to buy a new can of paint. If he spent $100 on paint, how many walls has he painted?
def solve() -> int: walls_painted = 15 cost_per_can = 20 total_cost = 100 num_cans_bought = total_cost // cost_per_can walls_painted = num_cans_bought * walls_painted result = walls_painted return result
A car drives for 13 miles at a speed of 40 mph. What is the time taken to complete the journey in hours?
def solve() -> int: initial_distance = 13 speed = 40 time = initial_distance/speed result = time return result
Student: Bob can swim 20 laps in a pool in 4 minutes. Joe can swim 30 laps in the same amount of time. How many more laps can Joe swim than Bob?
def solve() -> int: bob_laps = 20 joe_laps = 30 difference = joe_laps - bob_laps result = difference return result
The total number of months in a year is the same as the number of games that Mark has. If he plays 1/8 of his games in January and 3/5 of the remainder in March, he will have 15 games left. How many games does Mark have total?
def solve() -> int: total_months = 12 games = total_months games_january = games * 1/8 games_remainder = games - games_january games_march = games_remainder * 3/5 total_games = games_january + games_march + 15 result = total_games return result
If x = 5 and y = 2, what is the value of the expression 3x^2 - 4xy^2 + 2y^3?
def solve() -> int: x = 5 y = 2 result = 3*x**2 - 4*x*y**2 + 2*y**3 return result
Julie has 30 coins. She spends 12 on candy, gives 3 to her brother, and then loses 7. If she then subtracts half the amount she has left, how many coins does she have in the end?
def solve() -> int: coins = 30 coins -= 12 coins -= 3 coins -= 7 coins -= (coins // 2) result = coins return result
Evan made 6 less than four times as many bracelets as Samantha. Lily made a seventh as many as Samantha. Lily made 8 bracelets. How many did Evan make?
def solve() -> int: samantha_bracelets = 8 * 7 evan_bracelets = 4 * samantha_bracelets - 6 result = evan_bracelets return result
A rectangular swimming pool measures 12 meters in length and 6 meters in width. Four tiles measuring 20 cm by 20 cm were used to create a pattern on the bottom of the pool. How many tiles were used in total?
def solve() -> int: pool_area = 12 * 6 tile_area = (20/100) * (20/100) tiles_used = pool_area / tile_area result = tiles_used return result
To make his favorite smoothie, Pedro needs three times as many bananas as strawberries. If he uses 15 strawberries, how many pieces of fruit does he use in total?
def solve() -> int: y = 3 * 15 result = y + 15 return result
There are 30 students in a classroom. 15 students took French, 10 students took German, and the rest took Spanish. What percentage of the students took Spanish?
def solve() -> int: total_student = 30 num_french_student = 15 num_german_student = 10 num_spanish_student = total_student - num_french_student - num_german_student result = num_spanish_student/total_student * 100 return result
Tyler has 5 times as many pesos as euros. If he exchanges half of his euros for dollars at an exchange rate of 1 euro to 1.25 dollars, and then exchanges all of his remaining pesos for dollars at a rate of 1 euro to 2.5 dollars, how much money does he end up with in dollars if he started with 100 euros?
def solve() -> int: euros = 100 pesos = 5 * euros dollars_from_half_euros = 0.5 * euros * 1.25 remaining_euros = 0.5 * euros dollars_from_pesos = pesos / 2.5 total_dollars = dollars_from_half_euros + dollars_from_pesos result = total_dollars return result
A pet store has 45 goldfish, and three times as many guppies. They added 50 more goldfish and 20 fewer than twice the number of guppies of angel fish. How many fishes are there in the pet store?
def solve() -> int: goldfish = 45 guppies = 3 * goldfish angel_fish = 2 * guppies - 20 total_fishes = goldfish + guppies + angel_fish + 50 result = total_fishes return result
Student: Mr. Oh has 8 more oranges than Mrs. Johnson. Mrs. Johnson has 15 fewer oranges than Mr. Suzu. If Mr. Suzu has 43 oranges, how many oranges do the three have in total?
def solve() -> int: mr_suzu = 43 mr_oh = mr_suzu + 8 mrs_johnson = mr_suzu - 15 total = mr_suzu + mr_oh + mrs_johnson result = total return result
Possible new questions and programs are: Laurence wants to buy a new laptop. He has saved up $800, but the laptop he likes costs $960. He decides to wait for a sale and buy it when it is discounted by 15%. How much money will he save by waiting for the sale?
def solve() -> int: original_price = 960 discount_rate = 0.15 discounted_price = original_price * (1 - discount_rate) savings = original_price - discounted_price result = savings return result
Student: In the candy store, the bulk price of candy is $3 per pound and the minimum weight is 5 pounds before tax. The candy is taxed at $0.75 per pound. If Abby has paid $26.25 for candy, by how many pounds has Abby’s purchase exceed the minimum weight?
def solve() -> int: bulk_price = 3 minimum_weight = 5 tax_rate = 0.75 total_cost = 26.25 cost_before_tax = total_cost / (1 + tax_rate/ bulk_price) weight_before_tax = (cost_before_tax / bulk_price) excess_weight = weight_before_tax - minimum_weight result = excess_weight return resu...
A coffee shop charges $3 for a regular cup of coffee and $4 for a large cup of coffee. If they sold a total of 250 cups of coffee today and made $925 in revenue, how many of each cup of coffee did they sell?
def solve() -> int: regular_price = 3 large_price = 4 total_cups = 250 total_revenue = 925 for i in range(1, total_cups): regular_cups = i large_cups = total_cups - i revenue = (regular_cups * regular_price) + (large_cups * large_price) if revenue == total_revenue: ...
A recipe calls for 2 1/2 cups of flour. If you want to make half the recipe, how many cups of flour do you need?
def solve() -> int: a = 2.5 b = 0.5 result = a * b return result
Grace's bird catches 3 worms and 6 butterflies. Jack's bird catches 1 less than four times as many animals as Grace's bird. How many animals does Jack's bird catch?
def solve() -> int: grace_worms = 3 grace_butterflies = 6 grace_animals = grace_worms + grace_butterflies jack_animals = 4 * grace_animals - 1 result = jack_animals return result
Student: Emily wants to sell an average of 10 items a day this week. On Monday, she sold 12 items, on Tuesday she sold 8 items, and on Wednesday she sold nothing. On Thursday she sold 11 items and on Friday she sold 13 items. How many items should she sell on Saturday to reach her goal?
def solve() -> int: goal = 10 monday = 12 tuesday = 8 wednesday = 0 thursday = 11 friday = 13 saturday = 0 total = monday + tuesday + wednesday + thursday + friday saturday = goal * 7 - total result = saturday return result
san has 15 apples. She eats 1 apple every day. How long will it take her to finish all the apples?
def solve() -> int: apples = 15 consumption_per_day = 1 days_to_finish = apples // consumption_per_day result = days_to_finish return result
John needs to travel 240 kilometers to visit his parents. If he drives at a speed of 60 kilometers per hour, how much time will it take him to reach his parent's house? He decides to take a 15-minute break during the journey. What will be his total journey time (excluding the time he spends in the break)?
def solve() -> int: distance = 240 speed = 60 time = distance/speed time -= 0.25 result = time return result
Some possible questions are: Sam collected 12 stamps from different countries. He traded 4 of them with his friend for 8 new stamps. Then he bought another 5 stamps from a store. How many stamps does Sam have now?
def solve() -> int: stamps_after_trade = 12 - 4 + 8 stamps_after_purchase = stamps_after_trade + 5 result = stamps_after_purchase return result
A music teacher teaches three students for one hour. If they have already taught for 5 hours, how many more hours would they have to teach to reach a total of 20 students?
def solve() -> int: students_taught = 3 hours_taught = 5 total_students = 20 students_remaining = total_students - students_taught hours_remaining = students_remaining / students_taught hours_needed = hours_remaining - hours_taught result = hours_needed return result
If Emily went shopping for three hours, with a 15-minute break, and all the stores were visited for 10 minutes except one which lasted for 30 minutes, how many stores did she visit?
def solve() -> int: hours_shopping = 3 break_time = 15 store_visit_time = 10 special_store_visit_time = 30 total_time = (hours_shopping * 60) - break_time total_store_visit_time = total_time - special_store_visit_time number_of_stores = total_store_visit_time / store_visit_time ...
A trapezium has a height of 10cm and the length of both the parallel sides are 4cm and 6cm respectively. What is the area of the trapezium?
def solve() -> int: base1 = 4 base2 = 6 height = 10 area = ((base1 + base2) / 2) * height result = area return result
If a car travels 25 miles in 30 minutes, what is its average speed in miles per hour?
def solve() -> int: distance = 25 time = 0.5 speed = distance/(time/60) result = speed return result
A cake recipe calls for 6 eggs, 2 cups of flour, and 1 cup of sugar. Katie wants to make half of the recipe. How much sugar does she need?
def solve() -> int: eggs = 6 flour = 2 sugar = 1 eggs_half = eggs / 2 flour_half = flour / 2 sugar_half = sugar / 2 result = sugar_half return result
Sarah is twice as old as her cousin Jack. In twelve more years, Jack will be 30 years old. How old is Sarah now?
def solve() -> int: jack_age = 30 - 12 sarah_age = 2 * jack_age result = sarah_age return result
A company made 500 identical bags of chips. They sold 3/5 of them and donated the rest to a charity. The charity divided the bags equally between 8 schools. How many bags of chips did each school receive?
def solve() -> int: bags_of_chips = 500 sold_bags = bags_of_chips * 3/5 donated_bags = bags_of_chips - sold_bags bags_per_school = donated_bags / 8 result = bags_per_school return result
Sam has 50 pencils in his pencil case. His friend Max gave him 1/3 of the amount he already had. If Sam decides to give 1/10 of his total amount of pencils to his teacher, how many pencils will he give to his teacher?
def solve() -> int: pencils_in_pencil_case = 50 pencils_from_max = pencils_in_pencil_case * (1/3) total_pencils = pencils_in_pencil_case + pencils_from_max pencils_to_teacher = total_pencils * (1/10) result = pencils_to_teacher return result
Rachel invested $2,000 and earned 25% interest compounded annually for 3 years. She then withdrew $500 and invested the rest until she had four times as much invested. The next year, she got a 9% return on her investment. How much money does she have now?
def solve() -> int: initial_investment = 2000 interest_rate = 0.25 years = 3 new_investment = initial_investment - 500 new_investment *= 4 new_interest = 0.09 result = new_investment * (1 + new_interest) return result
A lemonade stand sells a cup of lemonade for $0.5 and a cookie for $0.25. They also have a special offer of a combo of a cup of lemonade and a cookie for $0.6. On a sunny day, they sold 40 cups of lemonade, 30 cookies, and 20 combos. How much money did they make on that day?
def solve() -> int: lemonade_revenue = 0.5 * 40 cookie_revenue = 0.25 * 30 combo_revenue = 0.6 * 20 total_revenue = lemonade_revenue + cookie_revenue + combo_revenue result = total_revenue return result
Chloe and Liam are saving up for a road trip across Europe and it will take them 2 years to save enough. If the trip costs $15,000 and they want to share their monthly savings equally, how much money should each person save per month?
def solve() -> int: trip_cost = 15000 time_to_save = 2 total_months = time_to_save * 12 total_savings = trip_cost / 2 monthly_savings = total_savings / total_months result = monthly_savings return result
A car can travel 20 miles for every gallon of gas it uses. If a driver is going on a long trip and needs to fill up on gas every 300 miles, how many gallons of gas will they need for the trip?
def solve() -> int: miles_per_gallon = 20 trip_distance = 300 gallons_needed = trip_distance / miles_per_gallon result = gallons_needed return result
Sarah has to drive 55 miles to get to her appointment with a client and then 25 miles south to visit a museum. If her car gets 28 miles per gallon, how many gallons of gas does she need for both journeys?
def solve() -> int: distance_to_appointment = 55 distance_to_museum = 25 total_distance = distance_to_appointment + distance_to_museum miles_per_gallon = 28 gallons_needed = total_distance / miles_per_gallon result = gallons_needed return result
am works as a manager and earns a salary of $5000 every month. He pays a 35% income tax rate and also makes a charitable donation of $500 every month. How much money does Sam pay in taxes each month?
def solve() -> int: result = 0 salary = 5000 taxRate = 0.35 amountDonatedToCharity = 500 totalIncome = salary totalTaxPaid = totalIncome*taxRate finalTaxPaid = totalTaxPaid - amountDonatedToCharity result = finalTaxPaid return result
A rectangle has a length of 10 cm and a width of 5 cm. What is the perimeter of the rectangle?
def solve() -> int: length = 10 width = 5 perimeter = 2*length + 2*width result = perimeter return result
In a hospital with 1000 patients, 35% of the patients are women, and 60% of the women have high blood pressure. How many women have normal blood pressure?
def solve() -> int: total_patients = 1000 women = total_patients * 0.35 women_high_bp = women * 0.6 women_normal_bp = women - women_high_bp result = women_normal_bp return result
A pool holds 20,000 gallons of water. If the pool is being filled at a rate of 500 gallons per hour, how many hours will it take to fill the pool?
def solve() -> int: pool_gallons = 20000 fill_rate = 500 fill_time = pool_gallons / fill_rate result = fill_time return result
Los Angeles had 10,000 tourists on the first day of the winter season. The next day, they had 15% less tourists. Over the next 3 days, the number of tourists increased by 35% per day. On the fifth day, they had 3 times the number of tourists they had on the first day. How many tourists are there now?
def solve() -> int: first_day_tourists = 10000 second_day_tourists = first_day_tourists - (first_day_tourists * 0.15) third_day_tourists = second_day_tourists + (second_day_tourists * 0.35) fourth_day_tourists = third_day_tourists + (third_day_tourists * 0.35) fifth_day_tourists = first_day_tourists...
There are 60 seconds in a minute. If a race is 3 minutes and 45 seconds long, how many seconds is the race?
def solve() -> int: minutes = 3 seconds = 45 total_seconds = (minutes * 60) + seconds result = total_seconds return result
A rectangle has a length of 12 cm and a width of 8 cm. What is the perimeter of the rectangle (in cm)?
def solve() -> int: length = 12 width = 8 perimeter = 2 * (length + width) result = perimeter return result
There are 40 students in a class. If each student gets 5 sheets of paper, how many sheets in total should the teacher prepare?
def solve() -> int: total_sheets = 40 * 5 result = total_sheets return result
A personal shopper made a profit of $4,000 in a month for shopping for clients. She wants to buy a new phone costing $1,200. To raise the needed amount, she splits the profit in four and asks for donations from her clients. If she received a total of $1,000 in donations and combines it with one-fourth of her profit, ho...
def solve() -> int: profit = 4000 phone_cost = 1200 donations = 1000 split_profit = profit / 4 total_money = split_profit + donations remaining_money = total_money - phone_cost result = remaining_money return result
At a concert, there are 55 adults and 20 children. If 10 adults and 5 children leave, how many people remain in the concert?
def solve() -> int: adults = 55 children = 20 adults_left = 10 children_left = 5 adults_remaining = adults - adults_left children_remaining = children - children_left total_remaining = adults_remaining + children_remaining result = total_remaining return result
A car company has 7 luxury cars and 8 non-luxury cars. If 3 cars are selected at random, what is the probability of selecting at least 2 luxury cars?
def solve() -> int: total_cars = 15 num_luxury_cars = 7 num_non_luxury_cars = 8 prob_2_luxury = (num_luxury_cars / total_cars) * (num_luxury_cars - 1) / (total_cars - 1) * (num_non_luxury_cars / (total_cars - 2)) * 3 prob_3_luxury = (num_luxury_cars / total_cars) * ((num_luxury_cars - 1) / (total_ca...
Fred can mow the lawn in 60 minutes while Bill takes 90 minutes to do the same task. How much slower is Bill compared to Fred?
def solve() -> int: time_difference = 0 time_for_fred = 0 while time_for_fred < 60: time_for_fred += 1 time_difference += 90 result = time_difference - time_for_fred return result
In 8 years, John will be half as old as Fred. If Fred is currently 40 years old, what's the sum of their ages now?
def solve() -> int: john_age = 40 - 8 fred_age = 40 sum_of_ages = john_age + fred_age result = sum_of_ages return result
A shipment of 500 flowers had 20% of them as red roses. If each red rose had double the number of petals than a regular flower, how many petals were there in the whole shipment of flowers?
def solve() -> int: total_flowers = 500 red_roses = total_flowers * 0.2 regular_flowers = total_flowers - red_roses petals_regular = 10 petals_red = petals_regular * 2 total_petals = (petals_regular * regular_flowers) + (petals_red * red_roses) result = total_petals return result
: Ella buys a stationery set with 6 pens, 12 pencils, and twice as many erasers as pens. Then her teacher trades her 7 pens for 5 erasers. What percentage of Ella's stationery set is pens?
def solve() -> int: pens = 6 pencils = 12 erasers = 2 * pens pens -= 7 erasers += 5 total_items = pens + pencils + erasers percentage_pens = (pens / total_items) * 100 result = percentage_pens return result
Liam has a lemonade stand and sells a cup for $0.5. He spends $0.1 on each cup of lemonade and $0.2 on each paper cup. He also has a fixed cost of $10 for renting the table and the sign. If he sells 200 cups of lemonade in a day, how much profit does he make?
def solve() -> int: price_per_cup = 0.5 cost_per_lemonade = 0.1 cost_per_paper_cup = 0.2 fixed_cost = 10 sales_per_day = 200 revenue = price_per_cup * sales_per_day variable_cost = cost_per_lemonade * sales_per_day + cost_per_paper_cup * sales_per_day total_cost = fixed_co...
After spending $500 on groceries, Ethan has $200 left. If he had $1,000 before buying the groceries, how much money, in dollars, did Ethan save?
def solve() -> int: initial_money = 1000 grocery_spending = 500 remaining_money = 200 total_spending = initial_money - remaining_money money_saved = total_spending - grocery_spending result = money_saved return result
A recipe calls for 3/4 cup of sugar for every 2 cups of flour. If you want to use 10 cups of flour to make the recipe, how much sugar will you need? Write a program to calculate the answer.
def solve() -> int: cups_flour = 10 cups_sugar = cups_flour * 3/8 result = cups_sugar return result
Jacob and Isabella are cousins. Jacob is 5 years old and Isabella is 11 years old. In how many years will their combined age be 35 years old?
def solve() -> int: jacob_age = 5 isabella_age = 11 combined_age = jacob_age + isabella_age target_age = 35 years = target_age - combined_age result = years return result
A class has 24 students, and the teacher gave the students 6 booklets to share among themselves. How many booklets must each student get?
def solve() -> int: total_booklets = 24 * 6 each_student = total_booklets / 24 result = each_student return result
Alex had 40 stickers in his album. He traded 10 stickers with his friend for 8 cards. He then gave one-third of his cards to his cousin and kept the rest. Alex's cousin already had 12 cards. How many cards does Alex have now?
def solve() -> int: stickers = 40 stickers = stickers - 10 cards = 8 cards_per_cousin = cards // 3 cards = cards - cards_per_cousin result = cards return result
There are 500 students in a school. If 55% of them are girls, how many boys are in the school?
def solve() -> int: girls = 500 * 0.55 boys = 500 - girls result = boys return result
In Shaan's city, there are 57 restaurants. On average, each restaurant cooks 20 different dishes a day. Shaan decided to invest in the city and opened up 8 new restaurants. How many different dishes will all the restaurants cook in one day?
def solve() -> int: number_of_old_restaurants = 57 dishes_per_restaurant = 20 number_of_new_restaurants = 8 total_number_of_restaurants = number_of_old_restaurants + number_of_new_restaurants dishes_by_all_restaurants = total_number_of_restaurants * dishes_per_restaurant result =...
Student: Christine needs to buy a shaped rug for her living room. The rug will be in the shape of a hexagon that is 8m wide and 10m long. What is the perimeter of the rug in meters?
def solve() -> int: width = 8 length = 10 diagonal = (width/2)**2 + (length/2)**2 diagonal = diagonal**0.5 perimeter = 2 * diagonal + 4 * width result = perimeter return result
ome possible new questions and programs are: Alice makes soap bars. For each soap bar, she uses 4 ounces of olive oil and 2 ounces of lye. If she makes two more than 12 soap bars, what will be the combined weight of the soap bars in pounds?
def solve() -> int: number_of_soap_bars = 12 + 2 weight_of_one_soap_bar = 4 + 2 total_weight_in_ounces = number_of_soap_bars * weight_of_one_soap_bar total_weight_in_pounds = total_weight_in_ounces / 16 result = total_weight_in_pounds return result
Student: If a pound of apples costs $1.50, how much will 2 1/8 pounds of apples cost?
def solve() -> int: price_per_pound = 1.50 weight = 2 + 1/8 total_cost = price_per_pound * weight result = round(total_cost, 2) return result
A grocery store sells fruits and vegetables. There are a total of 250 items on the display. There are twice as many vegetables as fruits. If there are 10 different types of fruit, how many different types of vegetables are there on display?
def solve() -> int: fruit = 10 veggies = 20 total = fruit + veggies total_items = 250 veggies_items = total_items*2/3 veggies_per_item = veggies_items/veggies result = veggies_per_item return result