~sheosi/helenos/lua

« back to all changes in this revision

Viewing changes to uspace/dist/src/python/demo/sintab.py

  • Committer: Sergio Tortosa (sheosi)
  • Date: 2013-12-22 14:13:23 UTC
  • mfrom: (2032.1.12 mainline)
  • Revision ID: sertorbe@gmail.com-20131222141323-gbiqm4j2w9sbjty5
MergedĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# Probably not very Pythonic, but it runs well with both Python2 and Python3
 
4
 
 
5
import math
 
6
import sys
 
7
 
 
8
sys.stdout.write("    ")
 
9
for frac_part in range(0,10):
 
10
        sys.stdout.write(" %5d" % frac_part)
 
11
print("")
 
12
 
 
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("")
 
23