Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Program to solve Mathematical Problems #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mathjs_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# @author anshu189
# By deafult 'requests' module is already installed with python if not found fire this command in cmd > pip install requests
import requests
chh=-1

while(int(chh)!=0):
print("1. Try a problem\n2. Help\n0. Exit")
helplst = ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "sparse", "matrix"]
chh = int(input("\nChoose any one: "))

if chh == 1:
print("\nNOTE: Don't use alphabets or invalid symbols & Algorithm Follows BODMAS Rule!")
print("Example Input: 2+3*sqrt(10/2-1) => 8 || (2+3)*sqrt((10/2)-1) => 10\n")
problem = input("Input your problem: ")
api_call = f"http://api.mathjs.org/v4/?expr={problem}"
response = requests.get(api_call)
print(f"Your solution: {response.text}")

elif chh == 2:
print("\n<===== Help Desk =====>")
print(*helplst, sep="\n")
ch=input("Input the name of the category correctly: ")
api_call = f"http://api.mathjs.org/v4/?expr=help({ch})"
response = requests.get(api_call)
print(response.text)
print("See Ya :)")