Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. from math import pi
  2. from cmath import polar
  3.  
  4. def laske_osoitinmuoto(komp, arvo, taajuus=0):
  5. if komp in ('R', 'r'):
  6. return polar(arvo)
  7. elif komp in ('L', 'l'):
  8. return polar(2 * pi * taajuus * arvo * 1j)
  9. elif komp in ('C', 'c'):
  10. return polar(1 / (2 * pi * -taajuus * arvo) * 1j)
  11. else:
  12. print("Sallitut komponentit ovat R, L ja C")
  13.  
  14. komp = input("Anna komponentin tyyppi (R, L, C): ")
  15. if komp in ('R', 'r', 'C', 'c', 'L', 'l'):
  16. arvo = float(input("Anna komponentin arvo: "))
  17. if komp in ('C', 'c', 'L', 'l'):
  18. taajuus = float(input("Anna komponentin taajuus: "))
  19. else:
  20. taajuus = 0
  21. impe, kulma = laske_osoitinmuoto(komp, arvo, taajuus)
  22. if komp in ('R', 'r'):
  23. print("Komponentin impedanssi osoitinmuodossa {} < {:.3f}°".format(impe, kulma/(2*pi)*360))
  24. elif komp in ('L', 'l'):
  25. print("Komponentin impedanssi osoitinmuodossa: {} < {:.3f}°".format(impe, kulma/(2*pi)*360))
  26. elif komp in ('C', 'c'):
  27. print("Komponentin impedanssi osoitinmuodossa: {} < {:.3f}°".format(impe, kulma/(2*pi)*360))
  28. else:
  29. print("Sallittuja komponentteja ovat R, L ja C!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement