question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
A company manufactured 1000 pieces of a particular product in the first month. If they managed to increase their production by 20% every month, what will be the total production after 8 months?
def solve() -> int: initial_production = 1000 total_production = initial_production for month in range(1, 9): production = total_production * 0.2 total_production += production result = total_production return result
John can walk at a speed of 4 miles/hour. If he walks for 30 minutes, how far would he have covered?
def solve() -> int: speed = 4 time = 30 / 60 distance = speed * time result = distance return result
Ian's friend buys him a necklace that is 12 inches long. He wanted to have something special as he loved triangles, so he asked his friend to cut off the edges of the necklace, 1/3 of the original necklace's length from each side. Calculate the new length of the necklace?
def solve() -> int: NecklaceLength = 12 EdgesCut = 1/3 NewLength = NecklaceLength * (1 - (2 * EdgesCut)) result = NewLength return result
Mike is making a 3-tiered cake for a party, but he wants to save time. He spends 1 hour per tier, then it takes him 45 minutes to assemble the cake. How many minutes did it take Mike on average to bake each tier, if each tier took the same amount of time to bake?
def solve() -> int: tier_baking_time = 60 assembly_time = 45 number_of_tiers = 3 total_time = (tier_baking_time * number_of_tiers) + assembly_time average_baking_time = total_time / number_of_tiers result = average_baking_time return result
If the volume of a cube is 27 cubic meters, what is the length of one side of the cube?
def solve() -> int: cube_volume = 27 side_length = cube_volume ** (1/3) result = side_length return result
Ethan's spam filter blocks all but 15% of spam emails, and 30% of the emails it doesn't block are actually important. What percentage of emails aren't important and don't get blocked?
def solve() -> int: spam_blocked_percentage = 0.15 important_emails_percentage = 0.30 not_important_and_not_blocked_percentage = (1 - spam_blocked_percentage) * (1 - important_emails_percentage) result = not_important_and_not_blocked_percentage return result
Student: Lefty needs to buy a rope of length 50 feet. He can only buy it in 15 foot pieces. How many pieces of rope will Lefty need to buy?
def solve() -> int: rope_length = 50 piece_length = 15 pieces_needed = rope_length // piece_length + (rope_length % piece_length > 0) result = pieces_needed return result
In 7 years, Alex will be as old as Mia is now. If Alex is 14 now, how old was Mia when she was Alex's age now?
def solve() -> int: alex_age_now = 14 years_in_future = 7 alex_age_in_future = alex_age_now + years_in_future mia_age_now = alex_age_in_future mia_age_when_alex_was_same_age = mia_age_now - years_in_future result = mia_age_when_alex_was_same_age return result
Johnny has a snowball launcher, which can shoot a snowball that travels 100 feet every second. If it takes him 5 seconds to reload the launcher, how far could Johnny shoot the snowball in 15 seconds?
def solve() -> int: time = 15 speed = 100 reload_time = 5 distance = time*speed - reload_time*speed result = distance return result
Student: 8. Ranveer had 54 pencils in his schoolbag which he wanted to share with his friends. Each of them received an equal number of pencils. How many pencils did each of them get?
def solve() -> int: pencils = 54 friends = 4 result = pencils // friends return result
A newly opened store has a 25% markup on its items. If an item costs $20 before the markup, what is the new price?
def solve() -> int: original_price = 20 markup_amount = original_price * 0.25 new_price = original_price + markup_amount result = new_price return result
A shopkeeper had 25 t-shirts in her store, but sold 6.7% of them yesterday. How many t-shirts does she have left in her store?
def solve() -> int: total_tshirts = 25 sold_percent = 6.7 sold_tshirts = (sold_percent/100) * total_tshirts remaining_tshirts = total_tshirts - sold_tshirts result = remaining_tshirts return result
A factory produces 1000 shirts a day. If they produce shirts for 5 days, how many shirts will be produced in total?
def solve() -> int: shirts_per_day = 1000 days = 5 total_shirts = shirts_per_day * days result = total_shirts return result
Student: Kaye has a dinner party of 15 guests coming over to her house. She needs to order 9 pizzas to feed everyone. How many slices should each guest receive in order for everyone to have an equal portion?
def solve() -> int: num_guests = 15 num_pizzas = 9 total_slices = num_pizzas * 8 slices_per_guest = total_slices / num_guests result = slices_per_guest return result
A truck can travel 300 miles in 5 hours, while a car can travel the same distance in 6 hours. How long will it take for both to travel 900 miles if they start at the same time?
def solve() -> int: time = ((900/300) + (900/600))*60 result = time return result
Student: If a pizza has a diameter of 20 cm, what is its circumference?
def solve() -> int: diameter = 20 radius = diameter / 2 pi = 3.14159 circumference = 2 * pi * radius result = circumference return result
In a factory, there are 2 machines working 21 hours a day. The owner decided to buy a third machine, which works only 8 hours a day. One machine can produce 3 kg of material every hour. The factory sells the produced material for $51 per 1 kg. How much can this factory earn in one day?
def solve() -> int: hourly_production = 3 no_of_machines = 2 hours_worked = 21 sale_price = 51 daily_production = hourly_production * no_of_machines * hours_worked daily_earnings = daily_production * sale_price result = daily_earnings return result
Student: A bookstore orders 250 copies of a book for $1500. How much does the bookstore save per book if they managed to get a $2.5 discount on each book?
def solve() -> int: num_copies = 250 price_per_book = 1500 discount_per_book = 2.5 total_price = num_copies * price_per_book discount_total = num_copies * discount_per_book total_price_after_discount = total_price - discount_total price_per_book_after_discount = total_price_after_discount / ...
A group of 20 students are on a field trip for 5 days. Each student brings 3 sets of clothes per day. The hotel they stay at has a laundry service that can hold 50 sets of clothes per load. How many loads of laundry do they have to do in total?
def solve() -> int: students = 20 days = 5 clothes_per_day = 3 laundry_capacity = 50 total_clothes = students * days * clothes_per_day total_loads = total_clothes // laundry_capacity result = total_loads return result
The minimum age required to vote in a local election is 18 years. Jessie is keen on voting in the election and will be half the age of Rachel in two years. If Rachel is currently 32 years old, what is the age of Jessie and when will she be able to vote in the election?
def solve() -> int: rachel_age = 32 jessie_age = (rachel_age / 2) - 2 voting_age = 18 years_to_vote = voting_age - jessie_age result = f'<<<Jessie is {jessie_age} years old and will be able to vote in {years_to_vote} years.>>>' return result
The ratio of the length of a rectangle to its breadth is 3:2. If the perimeter of the rectangle is 100m, find its area.
def solve() -> int: area = 30 * 20 result = area return result
Every week, Lisa earns some cash. In the first day, she earned $10. In the next two days, she earned $25 altogether. On the third day, she earned $30 but spent $15. How much cash did Lisa have by the end of the third day?
def solve() -> int: day1_earnings = 10 day2_earnings = 25 day3_earnings = 30 day3_expenses = 15 total_earnings = day1_earnings + day2_earnings + day3_earnings total_expenses = day3_expenses cash_by_end_of_day3 = total_earnings - total_expenses result = cash_by_end_of_day3 ...
Possible new questions and python programs: A roller coaster has 16 cars. Each car can seat 4 people. The roller coaster runs 12 times an hour. How many people can ride the roller coaster in an hour?
def solve() -> int: cars = 16 seats = 4 runs = 12 result = cars * seats * runs return result
ome possible questions and programs are: Bert has four overdue loans. The first loan of $500 charges 12% annual interest compounded monthly and is 4 months overdue. The second loan of $300 charges 4% annual interest compounded quarterly and is 6 months overdue. The third loan of $400 charges a $25 late fee for each ove...
def solve() -> int: loan1_interest = 500*(1+0.12/12)**(12*4/12) - 500 loan2_interest = 300*(1+0.04/4)**(4*6/12) - 300 loan3_fee = 25*3 loan4_fee = 50 + 100 loan1_total = 500 + loan1_interest loan2_total = 300 + loan2_interest loan3_total = 400 + loan3_fee loan4_total = 600 + loan4_fe...
If the HCF of two numbers is 6 and their product is 360, what are the two numbers?
def solve() -> int: num1 = 36 num2 = 10 result = (num1, num2) return result
Taylor is trying to save for a new phone. She earns $12 an hour and plans to work an extra 5 hours per week. If the phone costs $500, how many weeks will it take Taylor to save enough money?
def solve() -> int: hourly_wage = 12 extra_hours_per_week = 5 phone_cost = 500 weekly_earnings = hourly_wage * extra_hours_per_week weeks_to_save = phone_cost / weekly_earnings result = weeks_to_save return result
Mr.Ray has a total of 240 pills and he wants to divide it equally among 8 of his patients. How many pills should he give each patient?
def solve() -> int: total_pill = 240 patient_number = 8 pill_per_patient = total_pill // patient_number result = pill_per_patient return result
Student: A crate containing 150 apples weighs 250 kg. The weight of the crate is 20 kg. What is the weight of an apple?
def solve() -> int: crate_weight = 20 total_weight = 250 total_apples = 150 apples_weight = total_weight - crate_weight result = apples_weight / total_apples return result
Student: John saves $200 each month. How much money will he save after 2 years?
def solve() -> int: monthly_saving = 200 number_of_months = 24 total_saving = monthly_saving * number_of_months result = total_saving return result
John has 4 blue marbles, 5 red marbles, and 2 green marbles. If he picks 2 marbles, what are the odds that both marbles are green?
def solve() -> int: total_marbles = 11 total_green_marbles = 2 prob_first_green = total_green_marbles/total_marbles prob_second_green = (total_green_marbles-1)/(total_marbles-1) prob_both_green = prob_first_green * prob_second_green result = prob_both_green return result
An ice cream shop sells cones and cups. There are 70 people who purchased cones and 95 people who purchased cups. There were 47 people who bought both cones and cups. If there were no other sales, how many people bought ice cream?
def solve() -> int: cones = 70 cups = 95 both = 47 ice_cream = cones + cups - both result = ice_cream return result
An animal farm has to send 6800 chickens to the abattoir. During transport, 300 chickens escape and therefore cannot be sold. How many chickens can be sold if the farm charges $90 for each 22 chickens?
def solve() -> int: total_chickens = 6800 lost_chickens = 300 sold_chickens = total_chickens - lost_chickens chickens_per_box = 22 price_per_box = 90 boxes = sold_chickens//chickens_per_box cost = boxes*price_per_box result = cost return result
Sarah has 500 coins and wants to make two identical stacks. If each stack requires 220 coins, how many more coins does she need?
def solve() -> int: coins = 500 stacks = 2 coins_per_stack = 220 total_coins_needed = stacks * coins_per_stack coins_needed = total_coins_needed - coins result = coins_needed return result
Mr. Johnson has marked 60 exams this week, which adds up to 10 hours of grading. If he wants to finish grading in 7 hours, how many exams should he complete per hour?
def solve() -> int: number_of_exams = 60 total_time = 10 target_time = 7 result = number_of_exams / (total_time - target_time) return result
A pizza parlor can make 12 pizzas in an hour. How many pizzas can it make in a 8-hour workday?
def solve() -> int: pizzas_per_hour = 12 hours = 8 total_pizzas = pizzas_per_hour*hours result = total_pizzas return result
Leo is reading a book that has 200 pages. He reads 20 pages every day for the first 5 days, then he reads 15 pages every day for the next 5 days. How many pages does he have left to finish the book?
def solve() -> int: book_pages = 200 pages_per_day_1 = 20 pages_per_day_2 = 15 days_1 = 5 days_2 = 5 pages_read_1 = pages_per_day_1 * days_1 pages_read_2 = pages_per_day_2 * days_2 pages_read = pages_read_1 + pages_read_2 pages_left = book_pages - pages_read ...
David runs a fruit stand. He can sell each apple for $0.50. A bag of apple seeds weighs 15 pounds and costs $3. Each apple tree will need 5 seeds to grow fruit. If he makes $60 profit from selling apples, how many did he sell?
def solve() -> int: apple_price = 0.50 seed_weight = 15 seed_cost = 3 seeds_per_tree = 5 profit = 60 total_seed_cost = seed_cost * (seed_weight / seeds_per_tree) total_apple_sales = profit + total_seed_cost apples_sold = total_apple_sales / apple_price result = apples_sold ...
A cookier shop sold 4 times as many cookies as cupcakes. If there were 28 cookies sold, how many cupcakes did the store sell?
def solve() -> int: cookies = 28 cupcakes = 4 * cookies result = cupcakes return result
A recipe for 4 people requires 2 eggs. How many eggs are needed for 12 people?
def solve() -> int: eggs = 2 * 12 / 4 result = eggs return result
Diana goes shopping and buys a shirt for $25 and a pair of shoes for $50. Her friend buys a dress for $80 and pays for 60% of the bill. They tip 12%. How much does Diana pay with tip?
def solve() -> int: shirt_price = 25 shoes_price = 50 dress_price = 80 friend_payment = dress_price * 0.6 total_bill = shirt_price + shoes_price + dress_price tip = total_bill * 0.12 diana_payment = total_bill - friend_payment + tip result = diana_payment return result...
In a restaurant, there are 40 tables. If 20% of them are reserved and the rest are open, how many tables are open?
def solve() -> int: table_count = 40 reserved_tables = 0.2 * table_count open_tables = table_count - reserved_tables result = open_tables return result
A delivery truck travels 300 kilometers in 5 hours. What is the average speed (in kilometers per hour) of the truck?
def solve() -> int: distance = 300 time = 5 average_speed = distance / time result = average_speed return result
A car travels 120 miles in 2 hours. If it maintains the same speed, how long will it take to travel 360 miles?
def solve() -> int: distance = 120 time = 2 speed = distance/time new_distance = 360 new_time = new_distance/speed result = new_time return result
A farmer had 18 chickens, 6 cows, 4 pigs, and 10 rabbits. He sold 12 chickens and 2 cows at the market, and gave away 3 pigs and 5 rabbits to his neighbors. Then, a fox sneaked into the farm and ate 4 chickens and 2 rabbits. How many animals does the farmer have left?
def solve() -> int: chickens = 18 cows = 6 pigs = 4 rabbits = 10 chickens = chickens - 12 cows = cows - 2 pigs = pigs - 3 rabbits = rabbits - 5 chickens = chickens - 4 rabbits = rabbits - 2 result = chickens + cows + pigs + rabbits return result
Student: A candy store sells chocolate bars for $2 each and gummy bears for $1 each. If Johnny buys 3 chocolate bars and 5 gummy bears, how much does he pay in total?
def solve() -> int: chocolate_bars = 3 gummy_bears = 5 total_cost = chocolate_bars * 2 + gummy_bears * 1 result = total_cost return result
A farmer harvested 120 kilograms of potatoes and sold them at the local market. He sold 60% of them for $1.5 per kilogram and the rest for $1.2 per kilogram. He also had to pay a 10% commission to the market manager. How much profit did he make after paying the commission?
def solve() -> int: potatoes_15 = 120 * 0.6 potatoes_12 = 120 - potatoes_15 revenue = potatoes_15 * 1.5 + potatoes_12 * 1.2 commission = revenue * 0.1 profit = revenue - commission result = profit return result
A recipe for brownies calls for 3/4 cup of sugar for every 1/2 cup of flour. If you want to make 24 brownies, how much sugar do you need?
def solve() -> int: brownies = 24 flour_cups = brownies/4 sugar_cups = flour_cups*3/2 result = sugar_cups return result
zy earns $8.50 an hour for her part-time job. Last week, she worked for 12.5 hours while this week, she worked for 18.75 hours. How much did Suzy earn in two weeks for her part-time job?
def solve() -> int: hours_week1 = 12.5 hours_week2 = 18.75 hourly_rate = 8.50 total_earned = (hours_week1 + hours_week2) * hourly_rate result = total_earned return result
Ethan and his sister were playing a game. Ethan had won 6 times and his sister had won 10 times. Ethan was determined to win by at least 3 games. How many more times does Ethan have to win to reach his goal if his sister wins another 2 times?
def solve() -> int: ethan_wins = 6 sister_wins = 10 ethan_goal = sister_wins - ethan_wins + 3 ethan_goal -= 2 result = ethan_goal return result
Jennifer has two bicycles. Her older bicycle is 6 years old, which is three times the age of Jennifer's younger bicycle when the younger bicycle was a year younger. Jennifer's younger bicycle is 2 years old. What is the combined age of Jennifer's bicycles?
def solve() -> int: older_bike_age = 6 younger_bike_age = 2 younger_bike_age_one_year_ago = younger_bike_age - 1 older_bike_age_one_year_ago = older_bike_age / 3 * younger_bike_age_one_year_ago combined_age = older_bike_age + younger_bike_age result = combined_age re...
Vera has 3 times as many books as Wendy. Wendy has 10 books more than Xavier. If Xavier has 20 books, how many books does Vera have?
def solve() -> int: wendy = 20 + 10 vera = wendy * 3 result = vera return result
Mary has $800 and she wants to buy a laptop that costs $975, but she can only pay $400 upfront. She decides to finance the rest of the amount by paying $50 each month for 11 months. How much finance charges will she pay if the finance charges are $10 per month?
def solve() -> int: cash_payment = 400 finance_payment_per_month = 50 number_of_finance_payments = 11 finance_charges_per_month = 10 laptop_price = 975 finance_amount = laptop_price - cash_payment finance_amount_with_charges = finance_amount + (finance_charges_per_month * number_of_finance_p...
Mia needs to buy a rug. The rug is 6 feet by 8 feet. How many square feet is the rug?
def solve() -> int: rug_length = 6 rug_width = 8 rug_square_feet = rug_length * rug_width result = rug_square_feet return result
Student: Gia has 5 times as many pencils as Harry. Harry has one-sixth as many pencils as Ivy does. If Ivy has 36 pencils, how many does Gia have?
def solve() -> int: ivy_pencils = 36 harry_pencils = ivy_pencils / 6 gia_pencils = harry_pencils * 5 result = gia_pencils return result
Student: 7. If Mr. John and his three friends put the money they have left after spending on public transport and basic necessities into a joint savings account, how much money will be in the account together?
def solve() -> int: john_money = 10 friend1_money = 15 friend2_money = 20 friend3_money = 25 total_money = john_money + friend1_money + friend2_money + friend3_money result = total_money return result
A school has 120 students. In one year, 35% of the students switched to another school. How many students are left in the school?
def solve() -> int: total_students = 120 percent_left = 0.65 students_left = total_students * percent_left result = students_left return result
Alice and her dad went on a road trip. They traveled for 900 kilometers, and her dad uses 10 liters of fuel for every 100 kilometers they traveled. How much fuel did her dad use during their road trip?
def solve() -> int: TotalKilometers = 900 FuelPer100Km = 10 TotalFuel = (TotalKilometers / 100) * FuelPer100Km result = TotalFuel return result
Student: Grandpa Joe bought 134 donuts at a bakery shop. He ate 8 donuts and shared 16 with his grandchildren. How many donuts were left?
def solve() -> int: donuts_bought = 134 donuts_eaten = 8 donuts_shared = 16 donuts_left = donuts_bought - donuts_eaten - donuts_shared result = donuts_left return result
Mia bakes cookies from 3 PM to 6 PM every day. She can bake 2 dozen cookies per hour. How many hours will she need to bake a total of 1000 cookies?
def solve() -> int: cookies_per_hour = 2 * 12 total_cookies = 1000 hours = total_cookies / cookies_per_hour result = hours return result
If a recipe requires 2 1/2 cups of flour and you only have a 1 cup measuring cup, how many times will you need to fill it up to get the exact amount of flour?
def solve() -> int: required_flour = 2.5 measuring_cup = 1 times_to_fill = required_flour / measuring_cup result = times_to_fill return result
John has a rectangle measuring 4 cm by 6 cm while Michael has a square measuring 9 cm by 9 cm. What is the difference of their perimeter?
def solve() -> int: length_john = 4 width_john = 6 perimeter_john = 2 * (length_john + width_john) side_michael = 9 perimeter_michael = side_michael * 4 diff = perimeter_michael - perimeter_john result = diff return result
A car travels at a speed of 50 km/hour. How much distance will it cover in 2.5 hours?
def solve() -> int: distance = 50 * 2.5 result = distance return result
A rectangular garden is 5 meters wide and its perimeter is 24 meters. What is the length of the garden?
def solve() -> int: perimeter = 24 width = 5 length = (perimeter-2*width)/2 result = length return result
Student: There are 72 flowers in a garden. 24 of them are roses and twice as many are daisies. The rest are sunflowers. How many sunflowers are in the garden?
def solve() -> int: roses = 24 daisies = 2 * roses sunflowers = 72 - roses - daisies result = sunflowers return result
Mark is going on a hike and needs to traverse a path that goes both up and down a mountain. It takes him 3 hours and 15 minutes to hike up the mountain, and then 1 hour and 20 minutes to hike down. How many hours in total does it take him for the entire hike?
def solve() -> int: hike_up = 3 * 60 + 15 hike_down = 1 * 60 + 20 total_time = hike_up + hike_down total_time_in_hours = total_time / 60 result = total_time_in_hours return result
Alice needs to practice for her driver’s license test for 40 hours. She has decided to take 1.5 hour-long lessons four times a week for eight weeks. How many more hours will Alice need to take before her test?
def solve() -> int: hoursThisWeek = 1.5 * 4 totalHours = hoursThisWeek * 8 result = 40 - totalHours return result
Maria sets up a stationery shop. It cost $5,000 to open the shop initially. It also costs 1.5% of that to run per day. She sells 40 pens a day for $2 each. How many days will it take her to get her initial investment back?
def solve() -> int: initial_investment = 5000 daily_cost = initial_investment * 0.015 pen_price = 2 pens_sold_per_day = 40 daily_profit = pens_sold_per_day * pen_price - daily_cost days_to_recover_investment = initial_investment / daily_profit result = int(days_to_recover_investmen...
In an airport, the weight of a cargo plane is measured in November. By December, the cargo plane adds 10,000 pounds to its weight. By January, the cargo plane doubles the weight they had in December. If the cargo plane has 80,000 pounds in weight in January, what was the original weight of the cargo plane in November?
def solve() -> int: november_weight = 0 december_weight = november_weight + 10000 january_weight = december_weight * 2 november_weight = january_weight / 2 - 10000 result = november_weight return result
A television weighs 25 kg and a Playstation 4 Pro weighs 2 kg. If Alex wants to move these, how much weight will he be carrying?
def solve() -> int: tv_weight = 25 playstation_weight = 2 total_weight = tv_weight + playstation_weight result = total_weight return result
If Tom can buy 3 candy bars for $5, how much will 12 candy bars cost him?
def solve() -> int: candy_per_purchase = 3 cost_per_purchase = 5 candy_needed = 12 total_cost = (cost_per_purchase / candy_per_purchase) * candy_needed result = total_cost return result
Answer 1: 2 goals Jake and his family went to the zoo. They saw 12 elephants, 8 giraffes, 6 lions, and 9 monkeys. How many animals did they see in total?
def solve() -> int: elephants = 12 giraffes = 8 lions = 6 monkeys = 9 total_animals = elephants + giraffes + lions + monkeys result = total_animals return result
A book costs $12. If John buys 3 books and Sarah buys 5 books, how much do they have to pay in total?
def solve() -> int: cost_of_1_book = 12 john_books = 3 sarah_books = 5 total_cost = (john_books + sarah_books) * cost_of_1_book result = total_cost return result
A beaver had chopped down 120 trees to build its lodge and dam during the six months of summer and autumn. It divided the trees into six equal parts, one for each month, and then used some from each part, leaving 16 trees for each month. The beaver stored the ones it did not use to repair its constructions in the first...
def solve() -> int: trees_used = (120 - 16 * 6) / 6 trees_for_repairs = trees_used * 6 result = trees_for_repairs return result
A train travels 500 miles in 6 hours and 40 minutes. What is its speed in miles per hour?
def solve() -> int: distance = 500 time_hours = 6 + (40/60) speed = distance / time_hours result = speed return result
Jacob's comic book collection contains 1200 issues that he wants to organize by the superhero. If he wants to have categories of equal size and each book in a group with 30 other comics, how many times does he need to divide the groups?
def solve() -> int: num_comics = 1200 comics_per_group = 30 num_groups = num_comics // comics_per_group result = num_groups return result
Student: Dora wants to buy a book that costs $12. She has $4 in her piggy bank and earns $2 for each chore she does. How many chores does she need to do to buy the book if she also has to pay a 10% sales tax on the book?
def solve() -> int: book_cost = 12 piggy_bank = 4 chore_earning = 2 sales_tax = 0.1 total_cost = book_cost * (1 + sales_tax) total_cost_without_piggy_bank = total_cost - piggy_bank num_chores = total_cost_without_piggy_bank / chore_earning result = round(num_chores) return result
heila had $12 and she spent $4 of it on comic books. How much money does she have left?
def solve() -> int: amount = 12 amount_spent = 4 amount_left = amount - amount_spent result = amount_left return result
A ladder 15 feet long is leaning against a wall. If the bottom of the ladder is placed 5 feet from the wall, how high up the wall does the ladder reach?
def solve() -> int: ladder_length = 15 distance_from_wall = 5 height = ((ladder_length**2) - (distance_from_wall**2))**0.5 result = height return result
James can paint a house in 6 hours and Jack can paint the same house in 8 hours. If they work together, how long will it take for them to finish painting the house?
def solve() -> int: time_taken_by_James_to_paint_house = 6 time_taken_by_Jack_to_paint_house = 8 fraction_of_house_painted_in_one_hour_by_James = 1/time_taken_by_James_to_paint_house fraction_of_house_painted_in_one_hour_by_Jack = 1/time_taken_by_Jack_to_paint_house fraction_of_house_painted_in_on...
Student: At the Williams family reunion, there were 51 children and three times as many adults. One sixth of the adults wore brown. How many adults did not wear brown?
def solve() -> int: children = 51 adults = 3 * children brown_adults = adults / 6 not_brown_adults = adults - brown_adults result = not_brown_adults return result
Leo rents out bikes, he charges $5 per hour for a regular bike, $8 per hour for a mountain bike, and $12 per hour for an electric bike. How much money did he earn if he rented out 6 regular bikes for 3 hours, 4 mountain bikes for 2 hours, and 2 electric bikes for 4 hours?
def solve() -> int: regular_price = 5 mountain_price = 8 electric_price = 12 regular_quantity = 6 mountain_quantity = 4 electric_quantity = 2 regular_hours = 3 mountain_hours = 2 electric_hours = 4 regular_revenue = regular_price * regular_quantity * regular_hours mounta...
... And so on Possible questions and programs: Barbara is baking cookies for her friends and each cookie needs 1/4 cup of flour. If she has 3 cups of flour left in her pantry, how many cookies can she make?
def solve() -> int: flour_total = 3 flour_per_cookie = 1/4 cookies = flour_total / flour_per_cookie cookies = int(cookies) result = cookies return result
A box contains 6 red balls and 4 blue balls. If two balls are drawn at random without replacement, what is the probability that both are blue?
def solve() -> int: result = 2/15 return result
A toy store has 48 different kinds of stuffed animals on display. The store sells teddy bears in six different colors, pandas in two different sizes, and lions in three different patterns. Kevin collects stuffed animals and wants to buy one of each kind, but he only has enough money to buy two stuffed animals per week....
def solve() -> int: kinds = 6 + 2 + 3 weeks = kinds / 2 result = weeks return result
A bag contains 4 blue marbles, 5 red marbles, and 7 green marbles. If a marble is chosen at random, what is the probability that it is not red?
def solve() -> int: blue_marbles = 4 red_marbles = 5 green_marbles = 7 total_marbles = blue_marbles + red_marbles + green_marbles probability_not_red = (total_marbles - red_marbles) / total_marbles result = probability_not_red return result
Emily loves to garden. She recently planted a vegetable patch that measured 10ft x 5ft. If each square foot of garden was worth 5 dollars, how much is the vegetable patch worth in total?
def solve() -> int: length = 10 width = 5 area = length * width value_per_square_foot = 5 total_value = area * value_per_square_foot result = total_value return result
Lisa needed to carry 4 bags of flour home from the store. She brought two equal-sized backpacks and a small purse. In each backpack, she put twice as many bags of flour as she put in the purse. How many bags of flour did Lisa put in the purse?
def solve() -> int: backpacks = 2 purse = 1 total_bags = 4 bags_per_backpack = total_bags / (backpacks + purse) bags_per_purse = bags_per_backpack / 2 result = bags_per_purse return result
Jane has 10 apples and she gives 3 to Tom. Tom eats 1 apple and gives 2 to Lisa. Lisa eats half of what she has left and gives 1 to John. How many apples does John have?
def solve() -> int: janes_apples = 10 tom_apples = 3 tom_apples -= 1 lisa_apples = 2 tom_apples -= 2 lisa_apples /= 2 john_apples = 1 john_apples += lisa_apples result = john_apples return result
Student: In a geometry class, the ratio of the number of boys to girls is 4:5. If there are 36 students in the class, how many girls are there?
def solve() -> int: boys = 4 girls = 5 total_students = 36 girls_number = total_students * girls / (boys + girls) result = round(girls_number) return result
Karen can read 12 pages in 12 minutes. How many pages can she read in 6 minutes?
def solve() -> int: time = 12 pages = 12 rate = pages/time time = 6 result = rate * time return result
David is painting a room. It takes him 40 minutes to paint the walls and a third of that time to paint the ceiling. It takes him 20 minutes to clean up, twice as long to let the paint dry, and 1/5th the combined painting and drying time to rearrange the furniture. How many minutes does David spend painting and decorati...
def solve() -> int: painting_time = 40 ceiling_time = painting_time / 3 clean_up_time = 20 drying_time = painting_time * 2 painting_drying_time = painting_time + drying_time furniture_time = painting_drying_time / 5 total_time = painting_time + ceiling_time + clean_up_time + drying_time...
Ella has a jar with 20 marbles. She takes out 4 marbles at random and puts them in a bag. Then she takes out 3 more marbles from the jar and puts them in another bag. How many marbles are in each bag and how many marbles are left in the jar?
def solve() -> int: marbles_in_jar_after_first_step = 20 - 4 marbles_in_jar_after_second_step = marbles_in_jar_after_first_step - 3 bag1 = 4 bag2 = 3 result = marbles_in_jar_after_second_step return result
1. Dexter weighed a block of material and found that it was 45kg. After he cut a 20kg piece from it, he burned the rest. How much did the block weigh after it was burned?
def solve() -> int: total_weight = 45 piece_weight = 20 burned_weight = total_weight - piece_weight result = burned_weight return result
A factory produces 10,000 bottles per day in 2010 and 12,000 bottles per day in 2015. What is the average increase in production per year?
def solve() -> int: bottles_2010 = 10000 bottles_2015 = 12000 years = 2015 - 2010 increase = bottles_2015 - bottles_2010 average_increase = increase / years result = average_increase return result
There are 25 cows in a local Farmer's field. If 7 of the cows were moved to another field, how many cows would be left in the first field?
def solve() -> int: totalCows = 25 movedCows = 7 cowsLeft = totalCows - movedCows result = cowsLeft return result
A 9 m long and 6 m wide rectangular carpet is to be cut into two equal parts by a straight line that is parallel to the width of the carpet. What is the length of the cut line?
def solve() -> int: part_width = 6 / 2 cut_line_length = 9 result = cut_line_length return result
- Emily likes to read mystery novels and has a collection of 15 books. She has already read 7 of them and each one took her 6 hours to finish. She wants to read the remaining 8 books, but some of them are longer than others and have different reading speeds. The table below shows the number of pages and the reading spe...
def solve() -> int: books = [('A', 300, 40), ('B', 250, 50), ('C', 280, 45), ('D', 320, 35), ('E', 270, 50), ('F', 350, 40), ('G', 290, 45), ('H', 260, 55)] total_hours = 0 for book in books: name, pages, speed = book hours = pages / speed total_hours += hours result = t...
A supermarket has 1200 watermelons in stock and the average weight of each watermelon is 10 kilograms. How many tonnes of watermelons does the supermarket have in stock?
def solve() -> int: kilograms_per_watermelon = 10 total_kg = 1200 * kilograms_per_watermelon total_tonnes = total_kg / 1000 result = total_tonnes return result
-At John's company 70% of the employees are men and the rest are women. Of the women, 60% have a master's degree and 12 do not. How many men work at John's company?
def solve() -> int: men_percentage = 70 women_percentage = 100 - men_percentage women_without_masters = 12 women_with_masters = (100 - women_without_masters) * women_percentage / 100 total_women = women_with_masters + women_without_masters total_employees = 100 men = total_employees - total_...
A classroom has 40 students, if the ratio of boys to girls is 3:2, how many boys are in the room?
def solve() -> int: boys = 3 / (3 + 2) * 40 result = boys return result