Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Pierwiastkowanie
#Pierwiastkowanie def _pierwiastek(pod, stopien): if pod in {0, 1}: return pod, pod przedzial = [0, 1] if pod<1 else [1, pod] while True: srednia = sum(przedzial)/2 srednia_stopien = srednia**stopien if srednia_stopien == pod: return srednia, srednia kraniec = srednia_stopien > pod if srednia == przedzial[kraniec]: return przedzial przedzial[kraniec] = srednia from numbers import Integral def pierwiastek(pod, stopien=2, rezultat=0): if not isinstance(stopien, Integral): raise TypeError('stopien musi być liczbą całkowitą') if stopien < 2: raise ArithmeticError('stopien musi być nie mniejszy niż 2') if pod >= 0: return _pierwiastek(pod, stopien)[rezultat] else: return _pierwiastek(-pod, stopien)[rezultat] * (-1 if stopien % 2 else 1j) from ast import literal_eval while True: try: print(pierwiastek(*literal_eval(input()))) except EOFError: break except Exception as e: print(type(e), e)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Skillenza- Subjects
Ej2_python_204676887
Faiha Lesson 3
Python
Find numbers with given sum of digits
Implement a stack by using an array
Gauss
Alphabet
Python3: Class I : Person (Simple)
EJ2_PYTHON_20.321.212-7
Please log in to post a comment.