question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
A person's salary increases every year by 4%. If they currently make $50,000, how much will they make in 10 years?
def solve() -> int: current_salary = 50000 annual_increase = 0.04 years = 10 result = None return result
Ben has four times as many stickers as Alice. Chris has 48 stickers and three times as many as Alice. How many stickers do the three of them have altogether?
def solve() -> int: ben = 0 alice = 0 chris = 48 alice = chris / 3 ben = alice * 4 total = ben + alice + chris result = 112 return result
Sam has 20 dollars in his bank account. He deposits 5 dollars every week for four weeks. Then he withdraws 10 dollars to buy a gift. How much money does he have left in his bank account?
def solve() -> int: money = 20 for week in range(4): money = money + 5 money = money - 10 result = money return result
A store is having a sale where 20% off is given to all customers. If a customer purchases a watch originally priced at $250, how much do they pay after the discount?
def solve() -> int: original_price = 250 discounted_price = original_price*0.2 result = original_price - discounted_price return result
Leo can run 5 kilometers in 25 minutes without any aid. A pair of sneakers reduces his running time by 10%. A running belt with water bottles adds 5% to his running time. How much faster can Leo run 5 kilometers with sneakers and a running belt than without any aid?
def solve() -> int: distance = 5 time_without = 25 sneakers_factor = 0.9 belt_factor = 1.05 time_sneakers = time_without * sneakers_factor time_sneakers_belt = time_sneakers * belt_factor diff = time_without - time_sneakers_belt result = diff return result
Alice wants to buy a laptop that costs $800 cash. She can get a 10% discount if she pays in full within 6 months. She decides to save $100 every month for 6 months and then buy the laptop. How much will Alice pay for the laptop after the discount?
def solve() -> int: discount_rate = 0.1 discounted_price = 800 * (1 - discount_rate) monthly_savings = 100 number_of_months = 6 savings = monthly_savings * number_of_months if savings >= discounted_price: result = discounted_price else: result = 800 return result...
Ken hit 20 baskets in a basketball game. If he made 50% of his shots, how many shots did he take to hit 20 baskets?
def solve() -> int: basket_percentage = 0.50 num_baskets = 20 num_shots = num_baskets / basket_percentage result = num_shots return result
Possible new questions are: Ashley makes 15 bracelets, 12 necklaces, and 9 earrings. What percentage of her jewelry were earrings?
def solve() -> int: total = 15 + 12 + 9 fraction = 9 / total percentage = fraction * 100 result = percentage return result
Student: Geoff wants to save for his retirement. He plans to deposit $2200 annually into his bank account, which has a 0.55% fixed yearly interest rate. How much money will he have saved in 20 years if he does not withdraw any money?
def solve() -> int: annual_deposit = 2200 interest_rate = 0.0055 years = 20 total_deposit = annual_deposit * years interest_earned = total_deposit * interest_rate * years total_savings = total_deposit + interest_earned result = total_savings return result
A video game costs $60, but the store is running a special discount sale of 25%. After the sale, there is a tax rate of 9%. What is the final cost of the video game?
def solve() -> int: original_price = 60 discount_rate = 0.25 tax_rate = 0.09 total_discount = original_price * discount_rate discounted_price = original_price - total_discount tax = discounted_price * tax_rate total_cost = discounted_price + tax result = round(total_cost, 2) return r...
John solved 10 math problems every day in August. From September, he started solving 15 math problems every day. How many more math problems did John solve in September?
def solve() -> int: august_problems = 10 * 31 september_problems = 15 * 30 difference = september_problems - august_problems result = difference return result
Ava has 7 more marbles than Jake who has one-fifth the number of marbles as Zoe. Zoe has 25 marbles. How many marbles does Ava have?
def solve() -> int: z = 25 j = z // 5 a = j + 7 result = a return result
Isaac had 16 chairs with four legs each. If 1/5 of them have one broken leg each, how many legs are intact?
def solve() -> int: broken_chairs = 16 // 5 broken_legs = broken_chairs * 1 intact_legs = 16 * 4 - broken_legs result = intact_legs return result
Janet has to buy 4 different books. The first book costs $20, the second $25, the third $30, and the fourth $35. She receives a discount of 15% on the total amount. Calculate the final amount she has to pay.
def solve() -> int: book1_price = 20 book2_price = 25 book3_price = 30 book4_price = 35 discount_percent = 15 total_amount = book1_price + book2_price + book3_price + book4_price total_discount = total_amount * discount_percent / 100 final_price = total_amount - total_discount result...
If he hunts 3 deer per week, each weighing 150 pounds, how much meat does he have left at the end of the week?
def solve() -> int: meat_per_day = 20 * 16 meat_per_week = meat_per_day * 7 deer_weight = 150 * 16 deer_per_week = 3 meat_from_deer = deer_weight * deer_per_week meat_left = meat_from_deer - meat_per_week meat_left = meat_left / 16 result = meat_left return result
Student: Charlotte had 8 fewer diamonds than Kelvin who had 3 times as many diamonds as Odin. After giving 5 diamonds to Kelvin, Charlotte has 7 diamonds left. How many diamonds did Odin have at the beginning?
def solve() -> int: c = 0 k = 0 o = 0 result = o return result
Here are some possible math questions and python programs: Rita wants to buy a bicycle that costs $315. She has already saved $75 and can earn $15 by doing chores every week. How many weeks will it take her to save enough money for the bicycle?
def solve() -> int: cost = 315 saved = 75 earn = 15 need = cost - saved weeks = need // earn remainder = need % earn if remainder!= 0: weeks = weeks + 1 result = weeks return result
Mike has 3 bags of marbles. Each bag has 12 marbles. He wants to divide the marbles evenly among his 6 cousins. How many marbles will each cousin get?
def solve() -> int: marbles_per_bag = 12 bags = 3 total_marbles = marbles_per_bag * bags cousins = 6 marbles_per_cousin = total_marbles // cousins result = marbles_per_cousin return result
Here are some possible questions and programs: Leo buys a jacket that is marked down 30% from its original price of $60. He also has a coupon that gives him an additional 15% off the discounted price. How much does he pay for the jacket in dollars before tax?
def solve() -> int: discounted_price = 60 * (1 - 0.3) final_price = discounted_price * (1 - 0.15) result = final_price return result
Emily wants to create a 30-foot by 30-foot garden in her backyard. She uses tiles that are each 4 square feet. The first 30 tiles cost $6 each and then each tile after that costs half as much. How much do the tiles for the garden cost?
def solve() -> int: length = 30 width = 30 tile_area = 4 total_area = length * width total_tiles = total_area / tile_area first_tile_cost = 6 remaining_tile_cost = first_tile_cost / 2 first_30_tiles_cost = first_tile_cost * 30 remaining_tiles_cost = remaining_tile_cost * (t...
Student: If a 19-inch TV costs $149 and a 32-inch TV costs $259, how much more expensive is the 32-inch TV than the 19-inch one?
def solve() -> int: price_19 = 149 price_32 = 259 difference = price_32 - price_19 result = difference return result
A mobile phone bill includes a $20 base fee and a charge of $0.05 per minute for all minutes used above 200. If you used 350 minutes in total, what is your phone bill?
def solve() -> int: base_fee = 20 per_minute_charge = 0.05 minutes_used = 350 extra_minutes = max(0, minutes_used - 200) extra_charge = extra_minutes * per_minute_charge total_charge = base_fee + extra_charge result = total_charge return result
Student: A company has 340 employees, 2/5 of which are male. If there are 30 more female employees than male employees, how many female employees are there?
def solve() -> int: total_employees = 340 male_employees = total_employees * 2/5 female_employees = male_employees + 30 result = female_employees return result
Possible questions and programs are: A magazine has 52 pages. A third of the pages are ads, and 8 pages are the table of contents and the editor's letter. Of the remaining pages, a quarter are interviews and the rest are articles. How many pages are articles?
def solve() -> int: pages_no_ads = 52 - 52 // 3 pages_no_toc = pages_no_ads - 8 pages_interviews = pages_no_toc // 4 pages_articles = pages_no_toc - pages_interviews result = pages_articles return result
Kevin has 12 horses. If he gives 3 horses to each of his friends, how many horses would he have left?
def solve() -> int: number_of_horses = 12 number_of_friends = 3 result = number_of_horses % (number_of_friends * 3) return result
Student: A painter charges $150 for painting a room and $50 for painting a door. He painted 10 rooms and 15 doors in a month. How much money did he earn in that month?
def solve() -> int: num_rooms = 10 num_doors = 15 room_price = 150 door_price = 50 room_total = num_rooms * room_price door_total = num_doors * door_price total_earnings = room_total + door_total result = total_earnings return result
Nina’s family wants to buy 15 different pens. Each pen costs $3 and Nina paid using a $20 bill. If the cashier gave Nina only $2 bills for her change, how many bills did Nina receive?
def solve() -> int: cash = 20 pens = 15 price = 3 total_cost = pens * price change = cash - total_cost twos = change // 2 result = twos return result
Michael walks to the library, which is 1 mile away from his house. If it takes him 30 minutes to walk to the library and he arrives at 4:30 p.m, what time did he leave his house?
def solve() -> int: distance = 1 time_taken = 30 time_taken_hours = time_taken / 60 arrival_time = 4.5 departure_time = arrival_time - time_taken_hours result = departure_time return result
A dog's tail is one-eighth its length. If a dog is 4 feet long, calculate the length of the rest of its body minus the tail.
def solve() -> int: length_of_dog = 4 tail_length = length_of_dog / 8 body_length = length_of_dog - tail_length result = body_length return result
If the price of an item is increased by 25%, then again by 15%, what is the final price if the original price was $100?
def solve() -> int: original_price = 100 price_after_first_increase = original_price * 1.25 final_price = price_after_first_increase * 1.15 result = final_price return result
7. In a grocery store, apples were sold at a price of 6 for $3. What was the cost of each apple?
def solve() -> int: number_of_apples = 6 total_price = 3 price_per_apple = total_price/number_of_apples result = price_per_apple return result
Student: Sam has 3 bags of candy, each with 20 pieces. He ate 2 pieces from each bag, then shared 1/5 of the total candy with his sister. How many pieces of candy did Sam have left?
def solve() -> int: bag1 = 20 bag2 = 20 bag3 = 20 bag1 -= 2 bag2 -= 2 bag3 -= 2 total_candy = bag1 + bag2 + bag3 shared_candy = total_candy * 1/5 result = total_candy - shared_candy return result
Ben wants to make a cake and needs 200 g of flour. He only has a measuring cup that shows milliliters. He knows that 1 ml of water weighs 1 g, but 1 ml of flour weighs only 0.6 g. How many ml of flour should he measure with his cup?
def solve() -> int: flour = 200 water = 1 flour_density = 0.6 flour_volume = flour / flour_density result = flour_volume return result
A movie theater charges $10 for a ticket and $5 for popcorn. If 5 people buy tickets and all of them want popcorn, how much money did they spend in total?
def solve() -> int: ticket_price = 10 popcorn_price = 5 people_count = 5 total_spent = (ticket_price * people_count) + (popcorn_price * people_count) result = total_spent return result
A pizza restaurant offers 4 different toppings: pepperoni, mushrooms, onions, and peppers. Half of the pizzas ordered have pepperoni, and 3/4 of the pepperoni pizzas also have mushrooms. If the restaurant made 120 pizzas and 30 of them were mushroom pizzas with no pepperoni, how many pizzas had both pepperoni and mushr...
def solve() -> int: total_pizzas = 120 pepperoni_pizzas = total_pizzas / 2 mushroom_pepperoni_ratio = 3 / 4 pepperoni_and_mushroom_pizzas = mushroom_pepperoni_ratio * pepperoni_pizzas pizzas_with_mushrooms_but_no_pepperoni = 30 pizzas_with_mushrooms_and_pepperoni = pepperoni_and_mushroom_pizzas ...
A baseball team has 25 players. 40 percent are pitchers, and 75 percent of the pitchers are left-handed. How many left-handed pitchers are there?
def solve() -> int: players = 25 pitchers = players * 0.4 left_handed_pitchers = pitchers * 0.75 result = left_handed_pitchers return result
Aaron loves to make sandwiches for his family picnic. He wants to make sandwiches for 16 people with two slices of bread each. A pack of bread has 24 slices and costs $3.50. How many packs of bread does Aaron need to buy?
def solve() -> int: bread_slices_needed = 2 * 16 packs_needed = bread_slices_needed // 24 + 1 cost = packs_needed * 3.5 result = packs_needed return result
Lauren is renting a car for the weekend. The rental company charges $40 per day and $0.20 per mile driven. If Lauren rents the car for 3 days and drives a total of 250 miles, how much does she pay?
def solve() -> int: cost_per_day = 40 cost_per_mile = 0.20 number_of_days = 3 total_miles_driven = 250 total_cost = (cost_per_day * number_of_days) + (cost_per_mile * total_miles_driven) result = total_cost return result
If Brian earns $2400 per month and his rent is $1000, how much money does he have left after paying his rent and all of his bills that cost $800 per month in total?
def solve() -> int: salary = 2400 rent = 1000 bills = 800 money_left = salary - rent - bills result = money_left return result
Mary has 8 coins in her pocket. She knows that 3 of them are quarters, 2 of them are dimes, and the rest are nickels. How much money does Mary have in her pocket in total?
def solve() -> int: quarters = 3 dimes = 2 nickels = 8 - quarters - dimes quarter_value = 0.25 dime_value = 0.10 nickel_value = 0.05 total_value = quarters * quarter_value + dimes * dime_value + nickels * nickel_value result = total_value return result
Libby has 108 rocks and wants to divide them up equally among herself and her friends Bonnie and Kaira. If Bonnie and Kaira get 10 times the amount of rocks as Libby, how many rocks does Kaira get?
def solve() -> int: rocks_total = 108 libby = rocks_total // 12 bonnie_kaira = libby * 10 kaira = (rocks_total - libby - bonnie_kaira) result = kaira return result
Emma, who weighs 70 pounds, wants to play on the see-saw with her little brother, who weighs 30 pounds. How many 2-pound rocks does Emma need to hold to make their weights equal?
def solve() -> int: emma_weight = 70 brother_weight = 30 rock_weight = 2 total_weight = emma_weight + brother_weight rocks_needed = (total_weight - emma_weight) / rock_weight result = rocks_needed return result
Martin wants to buy a laptop that costs $800, a pair of headphones that cost $150, and a backpack that costs $50. He also needs to pay $300 for his phone bill, $250 for his rent, and $100 for his food. He earns $18 per hour at his job. How many hours will Martin need to work this month?
def solve() -> int: total_cost = 800 + 150 + 50 + 300 + 250 + 100 hours = total_cost / 18 result = hours return result
There are 40 coins in a jar. One-fifth of the coins are quarters, one-fourth are dimes and the rest are nickels. How much money is in the jar?
def solve() -> int: quarters = 40 // 5 dimes = 40 // 4 nickels = 40 - quarters - dimes quarters_value = quarters * 0.25 dimes_value = dimes * 0.1 nickels_value = nickels * 0.05 value = quarters_value + dimes_value + nickels_value result = value return result
Paul wanted to make a pizza for his friends. He had enough ingredients to make 5 large pizzas. If each large pizza requires 4 cups of flour, how many cups of flour did Paul need in total?
def solve() -> int: num_pizzas = 5 num_cups_flour_per_pizza = 4 total_cups_flour = num_pizzas*num_cups_flour_per_pizza result = total_cups_flour return result
A bicycle is on sale at a discount of 15%. If the original price of the bicycle was $200, what is the sale price?
def solve() -> int: original_price = 200 discount = 0.15 sale_price = original_price - (original_price * discount) result = sale_price return result
In 3 weeks, Olivia will celebrate her 25th birthday. How old was she 2 years ago?
def solve() -> int: age_in_3_weeks = 25 current_age = age_in_3_weeks - (3 / 52) age_2_years_ago = current_age - 2 result = age_2_years_ago return result
In a library, there are 6 times as many books as magazines, and 10 times as many magazines as newspapers. If there are 15 newspapers in the library, how many books are there?
def solve() -> int: magazines = 15 * 10 books = magazines * 6 result = books return result
A company produces 5600 widgets a month. If they want to produce 6720 widgets in order to fulfill a large order, how many more widgets than usual do they need to produce?
def solve() -> int: last_production = 5600 large_order = 6720 extra_production = large_order - last_production result = extra_production return result
Ben has a data plan of 3 GB per month. He uses 0.5 GB of data on emails and 0.8 GB of data on streaming videos. How many MB of data does he use on average per day?
def solve() -> int: data_total = 0.5 + 0.8 data_total = data_total * 1000 days = 30 data_average = data_total / days result = data_average return result
A store is having a 20% discount on all items. If an item originally costs $50, how much would it cost after the discount?
def solve() -> int: original_price = 50 discount_percentage = 0.20 discount_amount = original_price * discount_percentage discounted_price = original_price - discount_amount result = discounted_price return result
Mike has to deliver 200 packages in a day. After optimizing his route, he was able to increase the number of deliveries by 70%. He then decided to invest in better transportation and was able to increase the number of deliveries by an extra 20%. How many packages can he deliver in total now?
def solve() -> int: initial_deliveries = 200 optimized_deliveries = initial_deliveries * 1.7 transportation_deliveries = optimized_deliveries * 1.2 total_deliveries = transportation_deliveries result = total_deliveries return result
Student: An electronics store is offering a 10% discount on all laptops. If a laptop's original price is $800, what is the new price after the discount?
def solve() -> int: original_price = 800 discount_rate = 0.1 discount_amount = original_price * discount_rate new_price = original_price - discount_amount result = new_price return result
A restaurant wants to donate 40% of its profits to charity. If the restaurant earns 5000 dollars in profit this month, how much will they be donating?
def solve() -> int: profit = 5000 donation_percent = 0.4 donation_amount = profit * donation_percent result = donation_amount return result
At a birthday party, there were 50 cupcakes. If Sarah ate one-third of them, how many cupcakes were left?
def solve() -> int: cupcakes = 50 ate_cupcakes = cupcakes / 3 remaining_cupcakes = cupcakes - ate_cupcakes result = remaining_cupcakes return result
Jessica has been saving money for a new bike for 2 weeks. In the first week she saved $100, and the second week she saved $200. How much money did she save in total?
def solve() -> int: saving_week_1 = 100 saving_week_2 = 200 total_saving = saving_week_1 + saving_week_2 result = total_saving return result
Student: The book store sells novels for $5 each and comics for $3 each. A boy has a coupon that gives him a 20% discount on any purchase. He wants to buy 4 novels and 6 comics. How much money, in dollars, does he need to pay after using the coupon?
def solve() -> int: novel_price = 5 comic_price = 3 novel_quantity = 4 comic_quantity = 6 discount = 0.2 novel_cost = novel_price * novel_quantity comic_cost = comic_price * comic_quantity total_cost = novel_cost + comic_cost discount_amount = total_cost * discount final_cost = t...
Ava works at a coffee shop and makes an average of 80 cups of coffee every day. On Wednesdays, her sales are about 20% lower than the daily average. How many cups of coffee does she sell in a week if the shop is open from Monday to Friday?
def solve() -> int: daily_average = 80 wednesday_decrease = 0.2 wednesday_sales = daily_average * (1 - wednesday_decrease) weekly_sales = (daily_average * 4) + wednesday_sales result = weekly_sales return result
If 80% of a number is equal to 120, then what is the number?
def solve() -> int: percent = 80 num_percent = 120 num = (num_percent*100)/percent result = num return result
Mary asked her siblings how many cupcakes they wanted for dessert. Both Tom and Sarah agreed they wanted 2 cupcakes each. Ben said he could eat three times the amount of cupcakes as his siblings while Jane said she could eat only half the total amount of cupcakes his siblings had. How many cupcakes did Mary need to bak...
def solve() -> int: tom_cupcakes = 2 sarah_cupcakes = 2 ben_cupcakes = 3 * (tom_cupcakes + sarah_cupcakes) jane_cupcakes = (tom_cupcakes + sarah_cupcakes) / 2 total_cupcakes = tom_cupcakes + sarah_cupcakes + ben_cupcakes + jane_cupcakes result = total_cupcakes return result
George was planning a big picnic and wanted to make sandwiches for his guests. He calculated that he needed 3 pieces of bread for each sandwich. If George has 18 pieces of bread, how many sandwiches can he make?
def solve() -> int: sandwich_amount = 0 bread_pieces = 18 bread_per_sandwich = 3 while (bread_pieces > 0): sandwich_amount = sandwich_amount + 1 bread_pieces = bread_pieces - bread_per_sandwich result = sandwich_amount return result
A store sells pencils in packs of 5. If a pack costs $1.50 and a box contains 24 packs, what is the price of one pencil?
def solve() -> int: pencil_pack = 5 pack_cost = 1.5 pack_in_box = 24 total_pencils = pencil_pack * pack_in_box pencil_price = pack_cost / total_pencils result = f'<<<{pencil_price}>>>' result = pencil_price return result
The area of a square is 289 sq cm. What is the length of each side of the square?
def solve() -> int: area = 289 side = area ** 0.5 result = side return result
If the 30 4-wheel drive cars in the parking lot each have a spare tire and we assume the average car tire has a circumference of 2.3m, how much total circumference is there in the parking lot?
def solve() -> int: total_circumference = 0 number_cars = 30 circumference = 2.3 total_tires = number_cars*2 total_circumference = total_tires*circumference result = total_circumference return result
A factory produces 2000 items per day. If a shipment of defective items is found, reducing production by 25%, how many items will be produced?
def solve() -> int: original_production = 2000 reduced_production = original_production * 0.75 result = reduced_production return result
A company has 40 employees, of which 30% are women. How many male employees are there in the company?
def solve() -> int: women_employees = 0.3 * 40 male_employees = 40 - women_employees result = male_employees return result
A rectangle has a width of 5cm and a perimeter of 16cm. What is the length of the rectangle?
def solve() -> int: perimeter = 16 width = 5 length = (perimeter/2) - width result = length return result
In a classroom, the number of boys is double the number of girls. If there are a total of 54 students, how many boys are in the class?
def solve() -> int: girls = 54 / 3 boys = 2 * girls result = boys return result
A baker bought three times as many bags of flour as he did of sugar. If the baker bought 12 bags of sugar, how many bags of flour did he buy?
def solve() -> int: sugar_bags = 12 flour_bags = sugar_bags * 3 result = flour_bags return result
-Assume that all the values are integers and that there are no fractions or decimals involved. Some possible questions and programs are: Kevin counted 3 boxes of cookies with 12 cookies each in the pantry and 4 boxes of cookies with 10 cookies each in the cupboard. He also saw 2 boxes of cookies with 8 cookies each on ...
def solve() -> int: cookies_in_pantry = 3 * 12 cookies_in_cupboard = 4 * 10 cookies_on_table = 2 * 8 total_cookies = cookies_in_pantry + cookies_in_cupboard + cookies_on_table result = 3 * 12 + 4 * 10 + 2 * 8 return result
The average weight of 5 people is 60 kg. If one person weighing 70 kg joins them, what is the new average weight?
def solve() -> int: people = 5 initial_total_weight = 60*people new_person_weight = 70 new_total_weight = initial_total_weight + new_person_weight new_people = people + 1 new_avg_weight = new_total_weight/new_people result = new_avg_weight return result
san spends $45 on lunch every week. If she wants to save 20% for a vacation, how much money will she save in 6 months?
def solve() -> int: saved_for_vacation = ((45*0.2)*26) result = saved_for_vacation return result
Teacher Beth has 40 pencils and wants to divide them evenly among her 4 students. How many pencils will each student get?
def solve() -> int: pencils = 40 students = 4 pencils_per_student = pencils / students result = pencils_per_student return result
A class collected 24 kg of paper for recycling. They packed the paper into 8 boxes of equal weight. How much paper was in each box?
def solve() -> int: paper_per_box = 24 / 8 result = paper_per_box return result
A rectangular plot of land has a length of 40 meters and a width of 30 meters. What is the area of the land in square meters?
def solve() -> int: length = 40 width = 30 area = length * width result = area return result
5. If Glenn buys 12 bags of marshmallows, and each bag weight 12 ounces, how many total ounces of marshmallows did Glenn buy?
def solve() -> int: total_ounces = 12 * 12 result = total_ounces return result
ome possible questions and programs are: Lara and her mom Rachel celebrated their birthdays together. Lara had 8 candles on her cake. Rachel was 4 times older than Lara. How many candles did Rachel need for her cake?
def solve() -> int: lara = 8 rachel = 4 rachel_age = rachel * lara rachel_candles = rachel_age result = rachel_candles return result
Student: Joe has 2 bottles of Sprite, each containing 10 cans. If 3 people take 1 can each, how many cans left?
def solve() -> int: bottle1 = 10 bottle2 = 10 people = 3 can_taken = people * 1 cans_left = bottle1 + bottle2 - can_taken result = cans_left return result
A bottle of water contains 500 ml and costs $1. A pack of juice contains 1 L and costs $2.50. Which drink is cheaper per milliliter?
def solve() -> int: cost_per_ml_water = 1 / 500 cost_per_ml_juice = 2.5 / 1000 if cost_per_ml_water < cost_per_ml_juice: result = "Water is cheaper" elif cost_per_ml_juice < cost_per_ml_water: result = "Juice is cheaper" else: result = "They are the same price" return res...
A cake recipe calls for 1 1/4 cups of sugar and makes 12 servings. How much sugar is needed to make 30 servings?
def solve() -> int: cups_of_sugar = 1.25 servings_in_recipe = 12 servings_needed = 30 sugar_needed = (cups_of_sugar/servings_in_recipe)*servings_needed result = sugar_needed return result
Jean and his 8 friends play a card game for 5 dollars each. The winner gets 70% of the money and the second place gets the remaining 30%. How much money does the second place get?
def solve() -> int: total_players = 9 amount_per_player = 5 total_amount = total_players * amount_per_player amount_first_place = total_amount * 0.7 amount_second_place = total_amount - amount_first_place result = amount_second_place return result
Karen is 3 years older than John, and their current ages sum up to 31. How old is Karen?
def solve() -> int: john_age = (31-3)//2 karen_age = john_age + 3 result = karen_age return result
The profits of a company are divided among 4 employees, Jack, Jill, Sarah, and Tom in the ratio 5:3:4:2 respectively. If Sarah earns $1800, how much will Jack get after donating $300 for charity?
def solve() -> int: jack_ratio = 5 jill_ratio = 3 sarah_ratio = 4 tom_ratio = 2 sarah_earnings = 1800 total_ratio = jack_ratio + jill_ratio + sarah_ratio + tom_ratio jack_share = (jack_ratio / total_ratio) * (sarah_earnings - 300) result = jack_share return result...
Chris is driving from New York City to Los Angeles (a distance of 2800 miles). If he drives 70 miles per hour, how long will it take him to get to Los Angeles?
def solve() -> int: distance = 2800 speed = 70 time_needed = distance / speed result = time_needed return result
Leo earned $2000 from his part-time job, and spent 30% of it on rent, 20% of it on food, and 15% of it on entertainment. He then saved the rest of his money in a bank account that pays 5% annual interest. How much money will Leo have in his account after one year?
def solve() -> int: income = 2000 rent_rate = 0.3 food_rate = 0.2 entertainment_rate = 0.15 interest_rate = 0.05 rent = income * rent_rate food = income * food_rate entertainment = income * entertainment_rate saved = income - rent - food - entertainment account = saved * (1 ...
A jar has 80 blue marbles and 120 green marbles. If a marble is randomly selected from the jar, what is the probability of it being green?
def solve() -> int: total = 80 + 120 green = 120 probability = green / total result = probability return result
At a science fair, there were 50 projects and 10 more models. Each judge evaluated 5 projects. If a packet containing 20 evaluation forms is priced at $4, how much did the science fair organizers spend on evaluation forms?
def solve() -> int: projects = 50 models = projects + 10 judges = 5 evaluation_forms_per_packet = 20 packet_price = 4 total_projects_and_models = projects + models total_evaluations = total_projects_and_models * judges total_packets = total_evaluations / evaluation_forms_per_packet ...
Student: Betty has 15 stamps and wants to make sets of 3. How many complete sets of 3 stamps does Betty have?
def solve() -> int: stamps = 15 sets = stamps // 3 remainder = stamps % 3 result = sets return result
Student: A basketball team scores an average of 90 points per game for 20 games. If they score 80 points in their next game, what will their new average be?
def solve() -> int: total_points = 0 total_games = 20 total_points = total_games * 90 total_points += 80 total_games += 1 result = total_points / total_games return result
Possible questions and programs: Anna has 4 bowls of candy. Each bowl has 12 pieces of candy. She wants to share them equally with her 3 friends. How many pieces of candy will each person get?
def solve() -> int: bowls = 4 candy_per_bowl = 12 friends = 3 total_candy = bowls * candy_per_bowl candy_per_person = total_candy // (friends + 1) result = candy_per_person return result
10. Charles needs to travel from the store to the beach, which is 150 miles away. The car can go 65 miles per hour. It costs $0.41 per mile plus a flat fee of $25. How much did he pay for the trip?
def solve() -> int: distance = 150 speed = 65 mileFee = 0.41 flatFee = 25 totalFee = (distance * mileFee) + flatFee result = totalFee return result
Julia has $100 in her bank account. She spends $20 on groceries and then deposits $50. How much money does she have in her account now?
def solve() -> int: bank_balance = 100 grocery_spending = 20 deposit = 50 result = bank_balance - grocery_spending + deposit return result
A restaurant has 80 plates of food but 20 of them were not good enough to serve. After disposing of them, 12 plates were served to customer A, and a certain number of plates were served to customer B. Finally, 18 plates were served to customer C. How many plates of food were served to customer B?
def solve() -> int: plates_total = 80 plates_not_good = 20 plates_good = plates_total - plates_not_good plates_A = 12 plates_C = 18 plates_B = plates_good - plates_A - plates_C result = plates_B return result
Student: What is the cost of 5 apples if each costs $4 after a 20% discount?
def solve() -> int: original_price = 4 discount_rate = 0.2 discounted_price = original_price * (1 - discount_rate) cost = 5 * discounted_price result = cost return result
7. Emily has twice as many pink houses as yellow houses. She also has 12 fewer pink houses than blue houses. If she has 60 pink houses, how many yellow houses does Emily have?
def solve() -> int: pink_houses = 0 yellow_houses = pink_houses * 2 blue_houses = pink_houses + 12 total_houses = pink_houses + yellow_houses + blue_houses total_houses = 60 pink_houses = total_houses blue_houses = pink_houses - 12 yellow_houses = blue_houses - 12 result = yellow_hou...
A monthly gym membership costs $60. A one-time session costs $15. What's the minimum number of gym sessions you will need to attend every month so that the monthly membership is strictly cheaper per session?
def solve() -> int: monthly_membership_cost = 60 one_time_session_cost = 15 cost_per_session = monthly_membership_cost / 1 minimum_sessions = monthly_membership_cost / one_time_session_cost + 1 result = minimum_sessions return result
Kelly is buying notebooks for school. Each notebook costs $1.50. She has enough money to buy 25, but learns the price has increased to $1.75. How many notebooks can she afford to buy now?
def solve() -> int: notebook_price = 1.50 initial_quantity = 25 new_price = 1.75 initial_cost = notebook_price * initial_quantity affordable_quantity = initial_cost // new_price result = affordable_quantity return result
Student: A rectangular garden has a length of 15 feet and a width of 10 feet. A gardener wants to plant flowers along the perimeter of the garden. Each flower requires 1 square foot of space. How many flowers can the gardener plant?
def solve() -> int: length = 15 width = 10 flower_space = 1 perimeter = 2 * (length + width) num_flowers = perimeter * flower_space result = num_flowers return result
A store is selling 5 types of cereals. Each box of cereal costs $2.50. If a customer wants to buy 4 boxes of each type, how much would they spend altogether?
def solve() -> int: num_types = 5 num_boxes_per_type = 4 cost_per_box = 2.50 total_cost = num_types * num_boxes_per_type * cost_per_box result = total_cost return result
-Add a newline after each program. There are 100 students in a school. 40 percent of them are boys and the rest are girls. Each boy has 2 books and each girl has 3 books. How many books are there in total in the school?
def solve() -> int: boys = 0.4 * 100 girls = 100 - boys boys_books = boys * 2 girls_books = girls * 3 total_books = boys_books + girls_books result = total_books return result