## Challenges

Reddit challenges in python language.

Files Code and Result

### challenge98_easy

```'''
Write a program that reads two arguments from the command line:

a symbol, +, -, *, or /
a natural number n (≥ 0)

And uses them to output a nice table for the operation
from 0 to n, like this (for "+ 4"):

+  |  0  1  2  3  4
-------------------
0  |  0  1  2  3  4
1  |  1  2  3  4  5
2  |  2  3  4  5  6
3  |  3  4  5  6  7
4  |  4  5  6  7  8

If you want, you can format your output using the reddit table syntax:

|+|0|1
|:|:|:
|**0**|0|1
|**1**|1|2

Becomes this:
+ 	0 	1
0 	0 	1
1 	1 	2
'''

def interpret_operator(op, t, t2, e):
if op == '-':
e = t - t2
elif op == '+':
e = t + t2
elif op == '/':
e = t / t2
else:
op == '*'
e = t * t2
return e

def table(a, n):
num = list(range(1, n))
target = list(range(1, n))
top_string = a + ' |'
body = ''
exp = 0
for x in num:
top_string += str(x).rjust(6)
print(top_string)
print('-' * len(top_string))

for x in range(0, len(target)):
body = str(target[x]) + ' |'
for y in range(0, len(num)):
temp = target[x]
temp2 = num[y]

exp = interpret_operator(a, temp, temp2, exp)
exp = round(exp, 2)

body += str(exp).rjust(6)
print(body)

if __name__ == '__main__':
ans = table('/', 6)
```

### Result

```/ |     1     2     3     4     5
---------------------------------
1 |   1.0   0.5  0.33  0.25   0.2
2 |   2.0   1.0  0.67   0.5   0.4
3 |   3.0   1.5   1.0  0.75   0.6
4 |   4.0   2.0  1.33   1.0   0.8
5 |   5.0   2.5  1.67  1.25   1.0
```