Skip to content

Instantly share code, notes, and snippets.

@lymieux
Created March 23, 2022 21:49
Show Gist options
  • Save lymieux/93025c7b0b4e55d4977719e4948889ec to your computer and use it in GitHub Desktop.
Save lymieux/93025c7b0b4e55d4977719e4948889ec to your computer and use it in GitHub Desktop.
Simple python script to print Desmos function to inputed power,
#!/usr/bin/env python3
# Accepts only positive and negative integters
power, eq = int(input("Highest power of function: ")), ""
power_l = list(range(abs(power)))
for i in range(len(power_l)):
last_item = power_l.pop()
power_l.insert(i, last_item + 1)
for i in power_l:
if power < 0: # negative powers
eq = eq + "\\frac{a_{" + str(i) + "}}{x^{" + str(i) + "}}+"
else: # positive powers
eq = eq + "a_{" + str(i) + "}x^{" + str(i) + "}+"
print("Desmos function: " + eq + " b")
@lymieux
Copy link
Author

lymieux commented Mar 23, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment