question
stringlengths
11
2.89k
code
stringlengths
20
7.24k
Student: 3. Jason is shopping for a new laptop and needs to figure out the total cost including tax. If the laptop was $900, and the tax rate was 6%, how much does the laptop cost in total?
def solve() -> int: laptop_price = 900 tax_rate = 0.06 total_cost = laptop_price + laptop_price * tax_rate result = total_cost return result
``` Ben has $1000 and he borrows $500 from a friend. Later, he receives $800 from a debtor. He then returns $300 to his friend and spends $200 on entertainment. How much money is remaining with him?
def solve() -> int: money = 1000 money += 500 money += 800 money -= 300 money -= 200 result = money return result
A library has 80 more fiction books than non-fiction books. An author donates 200 non-fiction books to the library. If there were originally 20 non-fiction books, how many more non-fiction books than fiction books are there in the library now?
def solve() -> int: fiction_books = 0 non_fiction_books = 0 fiction_books = 20 non_fiction_books = 200 non_fiction_books += 200 fiction_books += 80 difference = non_fiction_books - fiction_books result = difference return result
Jake spent 1/4 of his allowance on books and 1/3 on clothes. If he has $30 left, how much was his allowance?
def solve() -> int: allowance = 0 total_spent = 30 books = total_spent / 4 clothes = total_spent / 3 allowance = (books + clothes + total_spent) result = allowance return result
A bottle of juice is divided into 8 equal parts. If 3 parts are consumed, how many parts are left?
def solve() -> int: bottle_of_juice = 8 consumed_parts = 3 remaining_parts = bottle_of_juice - consumed_parts result = remaining_parts return result
If Chaz can run 1.5 miles in 15 minutes, what is his speed in miles per hour?
def solve() -> int: distance = 1.5 time = 15 speed = distance / (time/60) result = speed return result
Student: Sarah has 200 feet of wire. If she uses 42 feet of wire for each project, how many projects can she build with the wire she has?
def solve() -> int: wire = 200 project_length = 42 num_projects = wire // project_length result = num_projects return result
Student: A jar has 108 candies. If 1/9 of the candies are wrapped with green, 1/3 of them are wrapped with blue, and the rest are red, how many candies are wrapped with red?
def solve() -> int: total_candies = 108 green_candies = total_candies / 9 blue_candies = total_candies / 3 red_candies = total_candies - green_candies - blue_candies result = red_candies return result
Tom has collected a total of 586 baseball cards. He has 374 rare cards and the rest are common cards. How many common cards does he have?
def solve() -> int: total_cards = 586 rare_cards = 374 common_cards = 0 common_cards = total_cards - rare_cards result = common_cards return result
ally purchased a house for $350,000 five years ago. The same house will be worth twice as much in another 10 years. How much will the worth of the house increase by?
def solve() -> int: house_price = 350000 future_year = 10 + 5 increase_rate = 2 future_house_price = house_price * increase_rate increase = future_house_price - house_price result = increase return result
A train is traveling at 60 mph and needs to travel 180 miles. How long will the trip take?
def solve() -> int: speed = 60 distance = 180 time = distance/speed result = time return result
Karen's dog food comes in bags that cost $8 each. She gets a discount of 10% when she buys more than 5 bags. If she buys 7 bags, how much does she have to pay?
def solve() -> int: num_of_bags = 7 cost_per_bag = 8 discount = 0.1 if num_of_bags > 5: cost = num_of_bags * cost_per_bag * (1 - discount) else: cost = num_of_bags * cost_per_bag result = cost return result
A backpacker hiking from Alaska to Argentina navigates for 512 days before reaching their destination. The backpacker takes a month to rest and recover before starting a blog tour, which lasts for 3 weeks. Lastly, it takes 2 days to return home. If the blogger's followers expect them to come back 1 month from now, when...
def solve() -> int: hiking_days = 512 rest_days = 30 blog_days = 21 return_days = 2 total_days = hiking_days + rest_days + blog_days + return_days days_until_return = 30 * 1 start_date = total_days - days_until_return result = start_date return...
-Number the questions from Q1 to Q10 Possible questions and programs: Q1: Laura walks up a hill that has a slope of 5%. She starts at an elevation of 300 feet and walks for 12 minutes at a speed of 3 feet per second. What is her elevation now?
def solve() -> int: speed_in_feet = 3 * 60 time_in_minutes = 12 distance = speed_in_feet * time_in_minutes elevation = 300 + distance * 0.05 result = 1110 return result
Jessica ran 3 miles for 5 days and 8 miles on the last day of the week. If she gets paid $0.25 per mile ran, how much money did she make in total?
def solve() -> int: miles_ran = 3*5 + 8 money_earned = miles_ran * 0.25 result = money_earned return result
Student: Mary has a toy box which is filled with 6 puzzle books each containing 25 pieces. If Mary take out 2/5 of the pieces from each book, calculate the number of pieces left in the box.
def solve() -> int: books = 6 pieces_per_book = 25 pieces_taken_out = (2/5) * pieces_per_book pieces_left_per_book = pieces_per_book - pieces_taken_out total_pieces_left = books * pieces_left_per_book result = total_pieces_left return result
A rectangle has a length of 8 cm and a width of 3 cm. What is the perimeter of the rectangle?
def solve() -> int: length = 8 width = 3 perimeter = (length+width)*2 result = perimeter return result
A flower store bought 40 roses at $2 each and 24 carnations for $1.50 each. They sold all the roses for 25% profit and all the carnations for 35% profit. How much profit did the store make from the sale of all flowers?
def solve() -> int: rose_cost = 40 * 2 carnation_cost = 24 * 1.5 total_cost = rose_cost + carnation_cost rose_profit = (rose_cost/total_cost) * 0.25 * rose_cost carnation_profit = (carnation_cost/total_cost) * 0.35 * carnation_cost total_profit = rose_profit + carnation_profit result = total...
Student: Sara is baking muffins with chocolate chips, blueberries, and walnuts. She wants to use twice as many chocolate chips as blueberries, 1/3 as many blueberries as walnuts, and 1/6 as many walnuts as muffins. If she has 18 muffins, how many chocolate chips does she need to use?
def solve() -> int: muffins = 18 blueberries = 0 walnuts = 0 chocolate_chips = 0 walnuts = muffins / 6 blueberries = walnuts / 3 chocolate_chips = blueberries * 2 result = chocolate_chips return result
At a jewelry store, Lily bought 4 items: a silver bracelet, a gold ring, a pair of earrings, and a necklace. The bracelet cost seven times more than the necklace, but only one-fourth the cost of the gold ring and the earrings combined. If the bracelet cost $105, how much did the ring and earrings cost combined?
def solve() -> int: bracelet_cost = 105 necklace_cost = bracelet_cost / 7 ring_earrings_cost = 4 * bracelet_cost / 7 result = ring_earrings_cost - bracelet_cost return result
Possible new questions and programs are: Anna has 18 stickers, and some of them are shiny. One fourth of Anna's stickers are shiny, and Ben has 3 times as many shiny stickers as Anna. How many shiny stickers does Ben have?
def solve() -> int: Anna = 18 shiny_A = Anna / 4 shiny_B = shiny_A * 3 result = shiny_B return result
Dan bought 9 boxes of pens. Each box had 12 pens and cost 8$. He also bought 6 notebooks. Each notebook cost 3$. He used a 10% off coupon for his total purchase. How much did he pay in all?
def solve() -> int: boxes = 9 pens_per_box = 12 box_price = 8 notebooks = 6 notebook_price = 3 coupon = 0.1 total_price = boxes * box_price + notebooks * notebook_price final_price = total_price * (1 - coupon) result = final_price return result
Julia went to the flower shop to buy some roses. The store was having a sale that offered customers a deal to buy one dozen at full price and get the second dozen for half off the full price. If she purchased two dozens that were each originally marked at a full price of $30, how much did she spend on the two dozens, i...
def solve() -> int: dozens = 2 original_price = 30 discounted_price = original_price / 2 total_cost = (original_price * dozens) + (discounted_price * dozens) result = total_cost return result
The cost to build a new house is $200,000. The owners paid $40,000 down payment and want to borrow the rest from the bank. If the interest rate on the loan is 6% per year and payment is made monthly for 25 years, what is the monthly payment?
def solve() -> int: total_cost = 200000 down_payment = 40000 loan_money = total_cost - down_payment loan_interest = 0.06 / 12 loan_duration = 25 * 12 monthly_payment = (loan_money * loan_interest * (1 + loan_interest) ** loan_duration) / ((1 + loan_interest) ** loan_duration - 1) result = mo...
Ms. White enters her eighth-period geography class and notices how small it seems. The classroom has 6 long tables that each seat 4 students, but some students are missing. If 4 students were absent due to a choir rehearsal and 9 students transferred out of the class, and 2 foreign exchange students haven't arrived yet...
def solve() -> int: num_tables = 6 seats_per_table = 4 total_seats = num_tables * seats_per_table absent_students = 4 transferred_students = 9 foreign_exchange_students = 2 total_students = total_seats - absent_students - transferred_students + foreign_exchange_...
Possible questions and programs: Daisy baked a dozen cupcakes for her classmates. She gave away a third of them to her teacher and another third to her best friend. She ate two cupcakes herself and sold the rest for 50 cents each. How much money did Daisy make?
def solve() -> int: cupcakes = 12 teacher = cupcakes // 3 friend = cupcakes // 3 self = 2 price = 0.5 sold = cupcakes - teacher - friend - self money = sold * price result = money return result
Student: Ms. Patel sews three kinds of masks for her customers. There are nine times as many cotton masks as silk masks. The number of linen masks is one sixth that of cotton masks. If Ms. Patel has 18 silk masks, how many masks does she sew in total?
def solve() -> int: silk_masks = 18 cotton_masks = silk_masks * 9 linen_masks = cotton_masks / 6 total_masks = silk_masks + cotton_masks + linen_masks result = total_masks return result
A ticket to a concert costs $75, and a backstage pass costs 4 times more than the concert ticket. What is the total cost of buying one ticket and one backstage pass?
def solve() -> int: ticket_cost = 75 backstage_pass_cost = 4 * ticket_cost total_cost = ticket_cost + backstage_pass_cost result = total_cost return result
Student: Anna has a candy store. She sells 3 types of candy: chocolate, gummy, and hard. She sells chocolate for $0.2 per piece, gummy for $0.1 per piece, and hard for $0.05 per piece. She sold 200 pieces of chocolate, 300 pieces of gummy, and 400 pieces of hard candy yesterday. How much money did she make yesterday?
def solve() -> int: chocolate_price = 0.2 gummy_price = 0.1 hard_price = 0.05 chocolate_pieces = 200 gummy_pieces = 300 hard_pieces = 400 chocolate_total = chocolate_price * chocolate_pieces gummy_total = gummy_price * gummy_pieces hard_total = hard_price * hard_pieces result = c...
Student: A salad store sells 8 types of salads priced at $6 each. If they sell 20 salads each day, how much money will they make in a week?
def solve() -> int: price_per_salad = 6 num_salads_sold_per_day = 20 num_days_in_week = 7 total_money_made = price_per_salad * num_salads_sold_per_day * num_days_in_week result = total_money_made return result
Possible questions and programs: Maria makes 3 bracelets a day. She sold 25 bracelets in the first 10 days of the month. How many bracelets a day does she have to make in the remaining 20 days to reach her goal of selling 100 bracelets in the month?
def solve() -> int: sold = 25 needed = 100 - sold days_left = 20 bracelets_per_day = needed / days_left result = bracelets_per_day return result
A car dealership sold 218 cars this week. They still have 987 cars in their inventory. How many cars did the car dealership originally have before selling this week's 218 cars?
def solve() -> int: cars_sold = 218 cars_remaining = 987 total_cars = cars_sold + cars_remaining result = total_cars return result
Emily wants to determine the volume of a rectangular prism. The length is 4 meters, the width is 6 meters, and the height is 8 meters. What is the volume of the rectangular prism?
def solve() -> int: length = 4 width = 6 height = 8 volume = length * width * height result = volume return result
Student: A bakery is selling donuts in packs only. Each pack costs $6 and contains 5 donuts. Kyle bought 27 donuts. How much did he spend?
def solve() -> int: cost_per_pack = 6 donuts_per_pack = 5 donuts_bought = 27 packs_bought = donuts_bought // donuts_per_pack total_cost = packs_bought * cost_per_pack result = total_cost return result
A movie theater has a total of 500 seats. If 150 are sold for the first showing of a movie, and then 100 for the second showing, how many seats are still empty?
def solve() -> int: total_seats = 500 first_showing_sold = 150 second_showing_sold = 100 empty_seats = total_seats - first_showing_sold - second_showing_sold result = empty_seats return result
A company wants to give a 6% raise to its employees who make less than $40,000 per year. If an employee made $35,000 last year, how much will they make this year?
def solve() -> int: old_salary = 35000 if old_salary < 40000: increase = old_salary * 0.06 else: increase = 0 new_salary = old_salary + increase result = new_salary return result
John has 376 cookies and he wants to divide them among 3 friends. How many cookies does each friend get?
def solve() -> int: total = 376 friends = 3 for_each_friend = total / friends result = for_each_friend return result
Lisa bought 2 scratch-off cards with identical numbers on each card. If 6 of the numbers on each card are winning numbers, and each winning number is worth $5, then how much money has Lisa won in total?
def solve() -> int: num_cards = 2 winning_numbers_per_card = 6 value_per_winning_number = 5 total_winning_numbers = num_cards * winning_numbers_per_card total_money_won = total_winning_numbers * value_per_winning_number result = total_money_won return result
The sum of three consecutive odd numbers is 69. What are the numbers?
def solve() -> int: total = 69 second_number = (total+3)/3 first_number = second_number-2 third_number = second_number+2 result = (first_number, second_number, third_number) return result
Joe has been driving for 8 hours and has travelled a total of 462 miles. What is his average speed?
def solve() -> int: total_distance = 462 hours_driven = 8 average_speed = total_distance / hours_driven result = average_speed return result
In a garden, there are twice as many daisies as roses. If the roses were 15, how many daisies are there?
def solve() -> int: roses = 15 daisies = 2 * roses result = daisies return result
Mira and Rina are dividing a candy bar that is 20 centimeters long. Mira is taking 5/8th of the candy bar. How many centimeters will Rina get?
def solve() -> int: candy_bar_length = 20 mira_share = (5/8) * candy_bar_length rina_share = candy_bar_length - mira_share result = rina_share return result
Olivia's income tax rate is 25%. Her salary is currently $50,000. She is getting a new job with a salary increase of 40%, which will increase her salary to $70,000. If she wants to keep her income tax bill under $15,000, how much can her salary increase?
def solve() -> int: current_salary = 50000 tax_rate = 0.25 new_salary = 70000 current_tax_bill = current_salary * tax_rate new_tax_bill = new_salary * tax_rate max_increase = (15000 + current_tax_bill - new_tax_bill) / (1 - tax_rate) - current_salary result = ro...
Jerry is reading a book, and wants to finish it by the weekend. He reads a fifth of the book on Monday, a tenth of the remaining pages on Tuesday, and a quarter of the remaining pages on Wednesday. On Thursday, he reads as many pages as he had read on Monday and Tuesday combined. On Friday, he reads the last 40 pages a...
def solve() -> int: fraction_monday = 1 / 5 fraction_tuesday = 1 / 10 fraction_wednesday = 1 / 4 fraction_remaining_monday = 1 - fraction_monday fraction_remaining_tuesday = fraction_remaining_monday - fraction_remaining_monday * fraction_tuesday fraction_remaining_wednesday = fraction_remaining...
Sarah buys 4 bags of chips. She eats 1 bag every day from Monday through Wednesday and 2 each during the remaining days of the week. If it takes her 4 such weeks to finish the 4 bags, how many chips are in a bag?
def solve() -> int: total_bags = 4 days_per_week = 7 days_to_finish = 4 * days_per_week chips_eaten = 3 + 2 * (days_to_finish - 3) chips_in_a_bag = chips_eaten / total_bags result = chips_in_a_bag return result
A train is traveling at a speed of 80 km/hour. It needs to cover a distance of 640 kilometers. How many hours will it take the train to reach its destination?
def solve() -> int: distance = 640 speed = 80 time = distance / speed result = f'<<<{time}>>>' result = time return result
A carnival gave out tickets for a free ride every Saturday. They had a total of 120 tickets and gave out 10 each Saturday for four weeks. At the end, they had 20 tickets left. How many people took the ride if only one ticket was allowed per person?
def solve() -> int: total_tickets = 120 tickets_per_week = 10 total_weeks = 4 tickets_left = 20 tickets_given_out = tickets_per_week * total_weeks tickets_used = total_tickets - tickets_left people_took_ride = tickets_used result = people_took_ride return result
Student: A wallet costs $80 with tax included. If the sales tax rate is 8%, what is the cost of the wallet before tax?
def solve() -> int: wallet_cost = 80 tax_rate = 0.08 cost_before_tax = wallet_cost / (1 + tax_rate) result = cost_before_tax return result
(Please use the format above and replace X with the numbers, i.e. Question1, Question2, etc) Pedro took a 15-day vacation. He spent 9 of the vacation days sightseeing and the rest of the days sleeping. What fraction of the days did Pedro spend sleeping?
def solve() -> int: result = 6/15 x = 15 y = 9 z = x - y result = z/x return result
ome possible questions and programs are: On the planet of Zephyr, there are 60 musicians. A fifth of the musicians play the flute, and half of the flutists have won a national award. How many musicians on Zephyr have not won a national award?
def solve() -> int: flute_award = 60 * (1/5) * (1/2) result = 60 - flute_award return result
Amy and Bob share a pizza. The pizza has 8 slices and each slice costs $2. Amy eats 3 slices and Bob eats 4 slices. How much money do they owe together?
def solve() -> int: slices = 8 price_per_slice = 2 amy_slices = 3 bob_slices = 4 total_price = slices * price_per_slice amy_owes = amy_slices * price_per_slice bob_owes = bob_slices * price_per_slice they_owe = amy_owes + bob_owes result = they_owe return result
A movie theater charges $12 per ticket. For a group of 4 people, they offer a package that includes 4 tickets, a large popcorn, and 4 drinks for $60. How much money would a group of 4 save with this package deal compared to buying the items separately?
def solve() -> int: ticket_cost = 12 package_cost = 60 num_tickets = 4 ticket_total_cost = ticket_cost * num_tickets savings = ticket_total_cost + 10 - package_cost result = savings return result
Student: If a house costs 140,000 dollars, how much must be paid for 2 such houses in total?
def solve() -> int: cost_of_one_house = 140000 total_cost_of_two_houses = cost_of_one_house * 2 result = total_cost_of_two_houses return result
A store had 120 boxes of cereals. They sold 45 boxes and then received a shipment of 80 boxes. How many boxes of cereals do they have now?
def solve() -> int: boxes = 120 boxes -= 45 boxes += 80 result = boxes return result
Michael buys a house for $500,000. He purchases a second house with twice the value of the first and sells the first house at half its value. What is Michael's total loss?
def solve() -> int: house1_value = 500000 house2_value = 2 * house1_value house1_sell_price = house1_value / 2 total_loss = house1_value - house1_sell_price + house2_value - house1_value result = total_loss return result
A clothing store sells t-shirts for $15 each and jeans for $50 each. If Sam buys 2 t-shirts and 1 pair of jeans, how much does he spend in total?
def solve() -> int: tshirt_price = 15 jean_price = 50 num_tshirts = 2 num_jeans = 1 total_cost = (tshirt_price * num_tshirts) + (jean_price * num_jeans) result = total_cost return result
The school bus can hold 48 passengers. There are 240 students who need to go on a field trip. The bus driver can make 3 trips in the morning and 3 trips in the afternoon. How many students will be left behind at school?
def solve() -> int: students_per_trip = 48 total_students_transported = 3 * 2 * students_per_trip students_left_behind = 240 - total_students_transported result = students_left_behind return result
Henry is currently 8 years old and his grandfather is 70 years old. In how many years will Henry be half as old as his grandfather?
def solve() -> int: henry_age = 8 grandfather_age = 70 years = 0 while henry_age!= (1/2) * grandfather_age: henry_age += 1 grandfather_age += 1 years += 1 result = years return result
A train is traveling at 60 miles per hour. How far will it go in two and a half hours?
def solve() -> int: speed = 60 time = 2.5 distance = speed*time result = distance return result
Eli drew 3 more than four times as many circles as his friend Maya. Maya drew 8 circles. How many did Eli draw?
def solve() -> int: maya_circles = 8 eli_circles = 4 * maya_circles + 3 result = eli_circles return result
A rectangle has a length of 10 cm and a perimeter of 32 cm. Find the width of the rectangle.
def solve() -> int: length = 10 perimeter = 32 width = (perimeter - 2*length)/2 result = width return result
Student: A tour bus can accommodate 40 passengers. On a certain day, the tour company had 3 buses full of passengers. If each passenger pays $25 for the tour, determine how much money the tour company made?
def solve() -> int: bus_capacity = 40 num_buses = 3 price_per_passenger = 25 total_passengers = bus_capacity * num_buses total_revenue = total_passengers * price_per_passenger result = total_revenue return result
Possible new questions and python programs are: Alice wants to make a sandwich. She has 4 kinds of bread, 6 kinds of cheese and 8 kinds of meat to choose from. She can use only one slice of bread, one slice of cheese and one slice of meat for her sandwich. However, if she uses rye bread, she cannot use ham. How many sa...
def solve() -> int: from itertools import product bread = ["white", "wheat", "rye", "multigrain"] cheese = ["cheddar", "swiss", "mozzarella", "gouda", "brie", "blue"] meat = ["turkey", "chicken", "beef", "salami", "ham", "bacon"] count = 0 for b, c, m in product(bread, cheese, meat): if no...
3. Liz and her friends are going to the zoo. It costs $12 admission for adults and $6 for children. From their group of five, there are 3 adults and 2 children. How much will they pay for their admission?
def solve() -> int: adults = 3 children = 2 adult_fee = adults * 12 children_fee = children * 6 total_fee = adult_fee + children_fee result = total_fee return result
- Beth works seven hours a day and earns $9.50 per hour. She gets a 10% bonus on her earnings every month. If she works 18 days a month, how much will be her total earnings for four months of work?
def solve() -> int: hourly_rate = 9.5 hours_per_day = 7 days_per_month = 18 months = 4 bonus_rate = 0.1 daily_earnings = hourly_rate * hours_per_day monthly_earnings = daily_earnings * days_per_month monthly_bonus = monthly_earnings * bonus_rate total_earnings = (monthly_earn...
Jake is a mechanic. Today, his task was changing oil. He changed the oil in 57 cars, but nine of the cars already had fresh oil. How many cars did Jake actually change the oil in?
def solve() -> int: num_cars = 57 num_fresh_oil = 9 num_changed_oil = num_cars - num_fresh_oil result = num_changed_oil return result
If there are 12 eggs in a carton and a recipe calls for 4 eggs, how many cartons will be needed for a recipe that makes 24 muffins?
def solve() -> int: eggs_per_muffin = 4 / 12 muffins_needed = 24 eggs_needed = muffins_needed * eggs_per_muffin cartons_needed = eggs_needed / 12 result = cartons_needed return result
- A book has 250 pages. David reads 20 pages per day, and he marks his progress with a bookmark that has 5 stars on it. If he moves his bookmark one star forward every time he reads a page, how many stars will be left on his bookmark when he finishes the book?
def solve() -> int: days_to_read = 250 / 20 stars_per_day = 20 / 5 stars_left = 5 - (days_to_read * stars_per_day) result = stars_left return result
Student: If a recipe calls for 2 cups of flour to make 24 cookies, how much flour would be needed to make 60 cookies?
def solve() -> int: cookies_needed = 60 cookies_per_cup = 24 flour_needed = cookies_needed / cookies_per_cup * 2 result = flour_needed return result
Jimmy bought 6 balloons, each balloon cost 50 cents. He also bought 4 markers, each marker cost 25 cents. How much did Jimmy spend in total?
def solve() -> int: price_balloons = 0.50 price_marker = 0.25 total_spent = price_balloons * 6 + price_marker * 4 result = total_spent return result
Maya goes to a dance studio on the 3rd floor every day for a week. She takes the stairs instead of the elevator, climbing up and down twice a day. If each floor is 8 feet tall, how many feet vertically does she travel in total over the week?
def solve() -> int: days = 7 floor_height = 8 trips_per_day = 2 floors_per_trip = 2 total_floors = days * trips_per_day * floors_per_trip total_feet = total_floors * floor_height result = total_feet return result
Julie has a husband and 2 rabbits. If Julie has two legs, how many legs are in total in her household?
def solve() -> int: husband_legs = 2 rabbit_legs = 4 num_rabbits = 2 total_legs = husband_legs + (rabbit_legs * num_rabbits) result = total_legs return result
Student: Kevin has a rectangular garden that is 12 meters long and 8 meters wide. He wants to fence the garden with a wire that costs $5 per meter. He also wants to plant some flowers along the fence that cost $2 per meter. How much will he spend on the wire and the flowers?
def solve() -> int: length = 12 width = 8 wire_cost = 5 flower_cost = 2 total_wire_cost = length * wire_cost + width * wire_cost total_flower_cost = length * flower_cost + width * flower_cost total_cost = total_wire_cost + total_flower_cost result = total_cost return result
Michelle needs to stock up on toilet paper. At the store, she can buy a pack of 4 for $5 or she can buy a pack of 12 for $14. How much money does she save by buying the bigger pack?
def solve() -> int: pack_4_price = 5 pack_12_price = 14 pack_4_quantity = 4 pack_12_quantity = 12 total_cost_pack_4 = pack_4_price * pack_4_quantity total_cost_pack_12 = pack_12_price * pack_12_quantity money_saved = total_cost_pack_4 - total_cost_pack_12 result = mon...
Chris earns $2,500,000 per year and employs 10 individuals, each making $24,000 per year. To increase their yearly earnings to $35,000 a year each, how much would Chris have to reduce his own annual salary?
def solve() -> int: chris_salary = 2500000 num_employees = 10 employee_salary = 24000 desired_employee_salary = 35000 total_employee_salary = num_employees * employee_salary total_desired_employee_salary = num_employees * desired_employee_salary reduction_in_chris_salary = total_em...
After last night's orders, Mr. Smith has 100 pizzas left. Ten separate orders were made, and each ordered 12 pizzas. How many pizzas are left for today?
def solve() -> int: pizzas_left = 100 orders_made = 10 pizzas_per_order = 12 total_pizzas_ordered = orders_made * pizzas_per_order pizzas_left -= total_pizzas_ordered result = pizzas_left return result
A store is selling shirts for $15 each and pants for $30 each. If John buys two shirts and one pair of pants, how much will he pay with a 15% discount and what will be his change if he pays with a $50 bill?
def solve() -> int: shirt_cost = 15 pants_cost = 30 num_shirts = 2 num_pants = 1 discount = 0.15 total_cost = (shirt_cost*num_shirts + pants_cost*num_pants) * (1-discount) change = 50 - total_cost result = total_cost, change return result
James exercised for a total of 70 hours last month. If he plans to exercise for 5 hours a day this week, how much less is his exercise time for this week?
def solve() -> int: total_exercise_time_last_month = 70 exercise_time_per_day_this_week = 5 days_in_a_week = 7 exercise_time_this_week = exercise_time_per_day_this_week * days_in_a_week exercise_time_difference = total_exercise_time_last_month - exercise_time_this_week result = exercis...
A car is driving at 50 km/h for 2 hours and then at 70 km/h for another 3 hours. What is the average speed of the whole journey?
def solve() -> int: distance1 = 50 * 2 distance2 = 70 * 3 total_distance = distance1 + distance2 total_time = 2 + 3 average_speed = total_distance / total_time result = average_speed return result
Linda wants to make a fruit salad with strawberries and bananas. She needs 1 cup of strawberries for every 2 cups of bananas. If Linda has 4 cups of strawberries and 6 cups of bananas, how many cups of fruit salad can she make?
def solve() -> int: strawberries_per_banana = 1/2 total_strawberries = 4 total_bananas = 6 fruit_salads_with_just_strawberries = total_strawberries fruit_salads_with_just_bananas = total_bananas // strawberries_per_banana // 2 number_of_fruit_salads = min(fruit_salads_with_just_strawberries, fru...
A parking space is 2.5 meters wide. If a car is 1.8 meters wide, how much clearance is left on each side of the car when it parks in the parking space?
def solve() -> int: parking_space_width = 2.5 car_width = 1.8 clearance = (parking_space_width - car_width) / 2 result = clearance return result
There are 24 apples. If 2/3 of them are red and the rest are green, how many green apples are there?
def solve() -> int: apples = 24 red_apples = apples * 2 / 3 green_apples = apples - red_apples result = green_apples return result
A department store has a sale where everything is 20% off. If a shirt originally costs $25, what is the sale price?
def solve() -> int: original_price = 25 discount = original_price * 0.20 sale_price = original_price - discount result = sale_price return result
At a restaurant, Sarah orders coffee 40% of the time. 5% of those times, she adds sugar to her coffee. Of those times, she adds cream 50% of the time. What percentage of coffee does she only drink black?
def solve() -> int: coffee_order = 0.4 sugar_added = 0.05 cream_added = 0.5 black_coffee = coffee_order - (coffee_order * sugar_added * cream_added) result = black_coffee * 100 return result
Sarah has a bag of 500 jelly beans. She eats 75% of them while watching a movie, then shares half of what she has left with her sister. If she has 56 jelly beans left, how many did she give to her sister?
def solve() -> int: jelly_beans = 500 eaten = jelly_beans * 0.75 remaining = jelly_beans - eaten shared = remaining / 2 result = jelly_beans - remaining return result
Jacob and Jay went to buy some oranges. Jacob bought 5 oranges for $2 and Jay bought 3 oranges at the same price. How much more did Jacob pay than Jay?
def solve() -> int: jacob_oranges_num = 5 jay_oranges_num = 3 cost_per_orange = 2 jacob_total_cost = jacob_oranges_num * cost_per_orange jay_total_cost = jay_oranges_num * cost_per_orange result = jacob_total_cost - jay_total_cost return result
Sophia won a prize of $750 for participating in a science fair. She decided to divide the money equally between her three friends. How much money did each friend get?
def solve() -> int: prize_money = 750 num_friends = 3 each_friend_money = prize_money / num_friends result = each_friend_money return result
Student: A training assistant who has been working for 9 years and who earns €11,500 a month has obtained a salary increase of 3%. What is his new salary?
def solve() -> int: salary = 11500 increase = 0.03 years = 9 new_salary = salary * (1 + increase) ** years result = new_salary return result
A rectangular prism has a height of 5 cm, a width of 4 cm, and a volume of 60 cubic centimeters. What is the length of the prism?
def solve() -> int: volume = 60 height = 5 width = 4 length = volume/(height*width) result = length return result
If a shirt costs $20 and a pair of shoes costs $50, how much would it cost to buy 2 shirts and 1 pair of shoes?
def solve() -> int: shirt_price = 20 shoes_price = 50 total_cost = 2*shirt_price + shoes_price result = total_cost return result
NOTE: This task is not about testing your math skills, but about generating questions that can be answered by writing Python programs. Possible questions and programs are: Tom baked 120 cookies for a charity sale. He packed them into 6 boxes with equal numbers of cookies in each box. However, he realized that he forgot...
def solve() -> int: cookies_per_box = 120 // 6 cookies_taken_out = 4 * 5 cookies_left_in_4_boxes = cookies_per_box * 4 - cookies_taken_out cookies_in_4_boxes_with_chocolate_chips = cookies_left_in_4_boxes + cookies_taken_out result = cookies_in_4_boxes_with_chocolate_chips // 4 return resul...
Sally is making necklaces by threading beads on a string. She has 180 beads in total, and she uses 12 beads for each necklace. She also leaves 5 cm of string at each end of the necklace for tying. If each bead takes up 1 cm of string, how many necklaces can Sally make with the string she has? She has 15 m of string in ...
def solve() -> int: beads = 180 necklace = 12 string = 22 total = 15 * 100 necklaces = min(beads // necklace, total // string) result = necklaces return result
Jason bought 40 stickers. He gave one-third of the stickers to his friend and then lost ten stickers. Then he gave half of the remaining stickers to his cousin. How many stickers did Jason have left with him?
def solve() -> int: jasons_stickers = 40 friends_stickers = jasons_stickers/3 remaining_stickers = jasons_stickers - friends_stickers - 10 cousins_stickers = remaining_stickers/2 stickers_left = remaining_stickers - cousins_stickers result = stickers_left return result
7. The local library ordered 17500 books to fill their shelves. If they sold 10500 books during the summer, how many books does the library have left?
def solve() -> int: books_remaining = 17500 - 10500 result = books_remaining return result
Two numbers have a sum of 75 and a product of 900. What are the two numbers?
def solve() -> int: from math import sqrt product = 900 sum_of_num = 75 diff = sqrt((sum_of_num**2) - (4 * product)) num1 = (sum_of_num + diff) / 2 num2 = (sum_of_num - diff) / 2 result = num1 return result
Student: Tania has a bag with 20 pieces of candy inside. She divides the candy evenly among 5 friends. How many extra pieces does Tania have left?
def solve() -> int: candy = 20 friends = 5 pieces_per_friend = candy // friends extra_pieces = candy % friends result = extra_pieces return result
Student: John put one third of the 40 marbles he has on the brightly lit kitchen counter and another two fifths on the dining table. How many marbles does he have on the kitchen counter?
def solve() -> int: total_marbles = 40 counter_fraction = 1/3 table_fraction = 2/5 counter_marbles = total_marbles * counter_fraction table_marbles = total_marbles * table_fraction result = counter_marbles return result
Student: A company has 400 employees. There are 4 managers for every 10 employees, and 20% of the managers have a bachelor's degree. If each manager manages the same number of employees, how many managers have a bachelor's degree?
def solve() -> int: employees = 400 employees_per_manager = 10 managers = employees // employees_per_manager * 4 percent_bachelors = 20 managers_with_bachelors = managers * percent_bachelors // 100 result = managers_with_bachelors return result
There were 48 people in a bus. A half of the people were adults, but only a third of the adults were women. How many of the people in the bus were women?
def solve() -> int: total_people = 48 adult_fraction = 1/2 woman_fraction = 1/3 adults = total_people * adult_fraction women = adults * woman_fraction result = women return result
A machine at a factory can produce 300 units in 4 hours. How many units can it produce in 7 hours?
def solve() -> int: units_per_hour = 300/4 num_hours = 7 total_units = units_per_hour*num_hours result = total_units return result