From 0d69805c542307a951fb9a7a36634f4d61e6bf4d Mon Sep 17 00:00:00 2001 From: shnapa-sh Date: Wed, 4 Oct 2023 17:47:57 +0300 Subject: [PATCH 1/4] 4 and 5 function --- homework/github_week3/fibonacci.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index bf3a00f..0710edf 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -24,12 +24,12 @@ def fibonacci_single(n: int) -> int: def golden_section_num() -> float: """Returns the golden section number (capital Phi)""" - pass + return (sqrt(5)+1)/2 def golden_section_reciprocal() -> float: """Returns the reciprocal of the golden section number (lowercase phi)""" - pass + return (sqrt(5)-1)/2 def power(num: int, n: int) -> int: From 8d97e0ddc92af30a806d39ddae0dfa0ead6af974 Mon Sep 17 00:00:00 2001 From: shnapa-sh Date: Wed, 4 Oct 2023 17:52:26 +0300 Subject: [PATCH 2/4] 4 and 5 function --- homework/github_week3/fibonacci.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index 0710edf..05d7161 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -24,12 +24,12 @@ def fibonacci_single(n: int) -> int: def golden_section_num() -> float: """Returns the golden section number (capital Phi)""" - return (sqrt(5)+1)/2 + return (sqrt(5)+1)/(2) def golden_section_reciprocal() -> float: """Returns the reciprocal of the golden section number (lowercase phi)""" - return (sqrt(5)-1)/2 + return (sqrt(5)-1)/(2) def power(num: int, n: int) -> int: From 22fbdc977ad6c2d786671b93597b2966b5093e20 Mon Sep 17 00:00:00 2001 From: DeDLo1 <291dedlol5484@gamil.com> Date: Wed, 4 Oct 2023 17:57:49 +0300 Subject: [PATCH 3/4] first 3 func --- homework/github_week3/fibonacci.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index bf3a00f..05db8a5 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -9,17 +9,23 @@ def get_input() -> int: """Gets input from the user and returns it as an integer""" - pass + usr_inp = int(input("Print your numb:")) + return usr_inp def fibonacci_list(n: int) -> typing.List[int]: """Returns a list of the first n Fibonacci numbers""" - pass + lst = [] + for i in range(n + 1): + lst.append(fibonacci_single(i)) + return lst def fibonacci_single(n: int) -> int: """Returns the nth Fibonacci number""" - pass + x = (golden_section_num() ** n) - (( - golden_section_reciprocal()) ** n) + y = x / (5 ** .5) + return y def golden_section_num() -> float: From e27a855289ee664e218bfc0ad13b151f4f397c25 Mon Sep 17 00:00:00 2001 From: movchun567 Date: Wed, 4 Oct 2023 18:06:25 +0300 Subject: [PATCH 4/4] i made power and sqrt --- homework/github_week3/fibonacci.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index 05d7161..a60d3fc 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -34,12 +34,14 @@ def golden_section_reciprocal() -> float: def power(num: int, n: int) -> int: """Raises num to the nth power""" - pass + if isinstance(num, int) and isinstance(n, int): + return num**n def sqrt(num: int) -> float: """Returns the square root of num""" - pass + if isinstance(num, int): + return num**0.5 def main():