Tabmwp Critic

LangChain Hub prompt: arietem/tabmwp_critic

P
promptbench
·May 3, 2026·
27 0 13
$7.99
Prompt
951 words

Write Python Code to solve the following questions. Store your result as a variable named 'answer'. Use 'print(answer)' to output your answer. Your answer should follow the previous pattern and format.


Read the following table and then write Python code to answer a question:

llama | $2,860.00 macaw | $8,897.00 parrot | $1,586.00 boa constrictor | $1,382.00 kinkajou | $2,629.00

Question: How much money does Kendra need to buy a kinkajou and a parrot?

kinkajou_price = 2629.00
parrot_price = 1586.00
total_money = kinkajou_price + parrot_price

Execution: Done Output: answer = None

What's the problem with the above code?

The problem with the above code is that it does not assign the result of the calculation to the variable answer. The code correctly calculates the total money Kendra needs to buy a kinkajou and a parrot, but it does not store the result in the answer variable.

Here's a better solution:

kinkajou_price = 2629.00
parrot_price = 1586.00
total_money = kinkajou_price + parrot_price
answer = total_money

Read the following table regarding "Words per page" and then write Python code to answer a question:

Stem | Leaf 3 | 3 4 | 1, 7, 8 5 | 2, 5, 6 6 | 0, 0, 1, 3, 4 7 | 2, 2, 4, 5, 8 8 | 0, 1, 4, 8 9 | 0

Question: Cameron counted the number of words per page in his new book. How many pages have at least 70 words but fewer than 90 words?

pages_with_70_words = 0
pages_with_80_words = 0
pages_with_90_words = 0
for stem, leaf in zip(stem, leaf):
    if stem == 4 and leaf >= 7 and leaf = 2 and leaf = 0 and leaf = 2 and leaf = 0 and leaf <= 4:
        pages_with_70_words += 1
    elif stem == 9 and leaf == 0:
        pages_with_70_words += 1

Execution: NameError("name 'stem' is not defined") Output: answer = None

What's the problem with the above code?

  1. The above code causes a "NameError" because it uses the variables stem and leaf without defining them. Moreover, the code tries to iterate over stem and leaf using zip, which is not correct because the stem and leaf are actually part of a single data structure, not two separate lists.
  2. The variable names in the code are a little bit confusing, and the logic for counting pages with at least 70 words but fewer than 90 words is not correct. To solve the problem, we should first properly represent the stem and leaf data structure and then count the pages with at least 70 words but fewer than 90 words.

Here's a better solution:

# Define stem and leaf data structure as a list of tuples
stem_and_leaf = [(3, [3]), (4, [1, 7, 8]), (5, [2, 5, 6]), (6, [0, 0, 1, 3, 4]), (7, [2, 2, 4, 5, 8]), (8, [0, 1, 4, 8]), (9, [0])]

# Initialize counter for pages with at least 70 words but fewer than 90 words
pages_with_70_to_89_words = 0

# Iterate through the stem and leaf data structure and count relevant pages
for stem, leaf_list in stem_and_leaf:
    for leaf in leaf_list:
        words_per_page = stem * 10 + leaf
        if 70 <= words_per_page < 90:
            pages_with_70_to_89_words += 1

answer = pages_with_70_to_89_words

Read the following table and then write Python code to answer a question:

Number of cow pastures | Number of sprinklers 1 | 10 2 | 20 3 | 30 4 | 40 5 | 50 6 | ?

Question: Each cow pasture has 10 sprinklers. How many sprinklers are in 6 cow pastures?

number_of_sprinklers_for_1_pasture = 10
number_of_sprinklers_for_2_pastures = 20
number_of_sprinklers_for_3_pastures = 30
number_of_sprinklers_for_4_pastures = 40
number_of_sprinklers_for_5_pastures = 50
number_of_sprinklers_for_6_pastures = number_of_sprinklers_for_5_pastures + number_of_sprinklers_for_1_pasture
answer = number_of_sprinklers_for_6_pastures

Execution: Done Output: answer = 60

What's the problem with the above code?

There is no problem with the above code. It correctly answers the question and calculates the number of sprinklers in 6 cow pastures. However, the code can be simplified, as there's a clear pattern in the relationship between the number of cow pastures and the number of sprinklers.

Here's a better solution:

number_of_pastures = 6
sprinklers_per_pasture = 10
total_sprinklers = number_of_pastures * sprinklers_per_pasture
answer = total_sprinklers

Read the following table regarding "Company sizes" and then write Python code to answer a question:

Company | Number of employees Madison Corporation | 454 Downtown Publishing | 442 Thompson Corporation | 452 Bronson Attorneys | 428

Question: The board of commerce recorded how many employees work at each company. Which company has the fewest employees? Please select from the following options: ['Madison Corporation', 'Downtown Publishing', 'Thompson Corporation', 'Bronson Attorneys']

company_sizes = [454, 442, 452, 428]
company_sizes = sorted(company_sizes)
answer = company_sizes[0]

Execution: Done Output: answer = 428.0

What's the problem with the above code?

The problem with the above code is that it returns the number of employees of the company with the fewest employees but not the name of the company itself, which is what the question asks for. To fix this issue, we should use a dictionary to store the company names and their corresponding number of employees. Then, we can find the company with the fewest employees by iterating through the dictionary and comparing the values.

Here's a better solution:

# Store the company names and their corresponding number of employees in a dictionary
companies = ⟨'Madison Corporation': 454,
             'Downtown Publishing': 442,
             'Thompson Corporation': 452,
             'Bronson Attorneys': 428⟩

# Find the company with the fewest employees
min_employees = float('inf')
min_company = None

for company, num_employees in companies.items():
    if num_employees < min_employees:
        min_employees = num_employees
        min_company = company

answer = min_company

{context}

This prompt contains variables shown as ⟨variable_name⟩. Replace them with your own values before using.

How to Use

Use with LangChain: hub.pull("arietem/tabmwp_critic")

Need help?

Connect with verified experts who can help you succeed.

Related Prompts

More prompts in Coding & Development

View All
Coding & Development
Universal

This Prompt Ads Sequential Function Calling To Models Other Than GPT 0613

This prompt ads sequential function calling to models other than GPT-0613

D
digitalmuse$2.99
39,910 89,588
Coding & Development
Universal

Create a personalized workout routine

Tailor a workout routine specifically designed for individual fitness goals

P
primequery$2.99
23,370 23,405
Coding & Development
Universal

GODMODE CHEATCODE

God Writes You a Letter Today. This is will help you find the perfect Bible Scripture that will guide you through a current problem you're facing.

S
signalcraft$3.99
13,574 13,622
Coding & Development
Universal

Creating a Personal Finance Tracker with [Technology/Tool]

Learn to create a personal finance tracker using [Technology/Tool]. Get code samples and budgeting tips.

F
focusqueryFree
376 385
Coding & Development
ChatGPT

Build an entire application using bubble.io with ChatGPT4

Build an entire app with bubble.io, assisted by chatGPT4, that knows bubble very well and is accurate 95% of the time. This prompt will help you maximize the quality of chatGPT assistance. Having detailed and step-by-step instructions is essential to progress fast with Bubble. This initial prompt will help you get started on a good basis. Follow it because I will make it even better.

P
promptframes$5.99
1,280 1,300
Coding & Development
Universal

Become LawyerGPT

Are you in a legal bind? This prompt can help you gain knowledge about how to handle your legal proceedings. DISCLAIMER: Please meet with a real lawyer to discuss your options.

P
promptbench$2.99
1,063 1,076