Created
January 11, 2019 20:12
-
-
Save maintainer64/a28627a2b553b03f187f0f913b4dc7bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math as m | |
def search_refraction(alfa: float, d: int) -> float: | |
""" | |
This function solve that https://vk.com/@unilecs-anons-43-prelomlenie task | |
""" | |
# Значение преломления пластины | |
n = 1.5 | |
# По закону Снеллиуса: | |
betta: float = m.asin(m.sin(m.radians(alfa)) / n) | |
# По определению тангенса | |
x: float = d * m.tan(betta) | |
print(x) | |
return round(x, 2) | |
if __name__ == '__main__': | |
""" | |
Automatic testing | |
""" | |
assert search_refraction(30, 5) == 1.77 | |
assert search_refraction(90, 0) == 0 | |
assert search_refraction(0, 1) == 0 | |
assert search_refraction(45, 5) == 2.67 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment