Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Created April 21, 2014 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kwpolska/11137396 to your computer and use it in GitHub Desktop.
Save Kwpolska/11137396 to your computer and use it in GitHub Desktop.
### Use input as formula and create an output of listed table.
### Ex: Input: 5*x ---> Output: 0 5 10 15 20 25
import math
#from sympy import *
from colorama import Fore, Back
def table():
x_min, x_max, formula = raw_input("\n[x_min] [x_max] [formula] = ").split(' ', 2)
print("\n")
print("-"*35)
print('|{0:^16}|{1:^16}|'.format('X', 'Y'))
print("-"*35)
for x in range(int(x_min), int(x_max)+1):
f = '|{0:>16}|{1:>16}|'.format(x, eval(formula))
if x%2 == 0:
print(Back.RED + f + Back.RESET)
else:
print(Back.BLUE + f + Back.RESET)
print(Fore.RESET +"-"*35)
print("\n")
table()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment