Add few Python demos
[helenos.git] / uspace / dist / src / python / demo / sintab.py
blobcdee7e95df9c55e4c9faed4cd7a94d04d9c952ca
1 #!/usr/bin/python
3 # Probably not very Pythonic, but it runs well with both Python2 and Python3
5 import math
6 import sys
8 sys.stdout.write(" ")
9 for frac_part in range(0,10):
10 sys.stdout.write(" %5d" % frac_part)
11 print("")
13 for angle_deg in range(0,90):
14 sys.stdout.write("%3d " % angle_deg)
15 for angle_deg_frac in range(0,10):
16 angle = math.radians(angle_deg + angle_deg_frac/10.)
17 value = math.sin(angle) * 10000 + 0.5
18 if value > 10000:
19 sys.stdout.write(" %05d" % (value))
20 else:
21 sys.stdout.write(" %04d" % (value))
22 print("")