Message Boards Message Boards

Can I Use Wolframplha's step by step api in python?

Posted 1 year ago

I'm a beginner to python and i wanna do simple code that shows step by step output for user's mathematical problem's however i tried to use step by step api app key i can't get the step by step i just get answer as an output here's my code:

import requests

app_id = 'xxxxxx'


def query_wolfram_alpha(input_query):
    base_url = 'http://api.wolframalpha.com/v2/query'
    params = {
        'input': input_query,
        'format': 'plaintext',
        'output': 'JSON',
        'appid': app_id,
    }

    response = requests.get(base_url, params=params)
    data = response.json()


    if 'pods' in data['queryresult']:

        result_pod = next((pod for pod in data['queryresult']['pods'] if pod['title'] == 'Result'), None)

        if result_pod:

            result_text = result_pod['subpods'][0]['plaintext']
            print(f"Solution: {result_text}")
        else:
            print("No solution found.")
    else:
        print("No solution found.")


query = 'expand (9x+3)^6'
query_wolfram_alpha(query)
POSTED BY: Aswin Selvam
2 Replies

Hi, did anybody find a solution ?

POSTED BY: Nadir Bertolasi
Posted 5 months ago

Hey did you figure out how to do this?

POSTED BY: Lavin M
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract