simbax

tryg.py

Dec 28th, 2012
6,470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # coding=utf-8
  2. # Program wyświetli wartość funkcji trygonometrycznych dla danego kąta
  3. from math import *
  4. while True:
  5.     kat = input("Podaj wielkość kąta w stopniach: ")
  6.     if kat < 0:
  7.         kat = fabs(kat)
  8.     if kat > 360:
  9.         print "Kąt",kat,"jest za duży!"
  10.         continue
  11.     else:
  12.         break
  13. kat = radians(kat)
  14. print "sin = %7.3f" % (sin(kat))
  15. print "cos = %7.3f" % (cos(kat))
  16. if degrees(kat) != 90:
  17.     print "tg  = %7.3f" % (tan(kat))
  18. else:
  19.     print "tg  = %7s" % "-"
  20. if degrees(kat) == 0 or degrees(kat) == 180 or degrees(kat) == 360:
  21.     print "ctg = %7s" % "-"
  22. else:
  23.     print "ctg = %7.3f" % (1/tan(kat))
Advertisement
Add Comment
Please, Sign In to add comment