Created
April 21, 2014 09:24
-
-
Save Kwpolska/11137396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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