sin.py 414 B

1234567891011121314151617181920212223
  1. import math
  2. import time
  3. w = 80
  4. h = 20
  5. for y in range(h):
  6. for x in range(w):
  7. d_x = x / 80.0 * 360
  8. r_x = math.radians(d_x)
  9. sin_y = math.sin(r_x)
  10. sin_y = sin_y + 1.0
  11. _y = sin_y / 2.0 * h
  12. i_y = int(_y)
  13. if y == i_y:
  14. print("*", end="")
  15. else:
  16. print(" ", end="")
  17. print()
  18. time.sleep(1)