From a077ef84eebe011e15548ccce056e59f564e9f2a Mon Sep 17 00:00:00 2001 From: yulka Date: Wed, 4 Oct 2023 17:53:56 +0300 Subject: [PATCH 1/4] ya yobnuvsa --- homework/github_week3/fibonacci.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index bf3a00f..e2c8e5c 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -6,6 +6,7 @@ Fill in all the missing code in the functions and in main """ import typing +import math def get_input() -> int: """Gets input from the user and returns it as an integer""" @@ -34,12 +35,14 @@ def golden_section_reciprocal() -> float: def power(num: int, n: int) -> int: """Raises num to the nth power""" - pass + result = math.pow(num, n) + return result def sqrt(num: int) -> float: """Returns the square root of num""" - pass + result = math.sqrt(num) + return result def main(): From 60217df97ebbd4ad9703f8ff1b02db29d5261a5c Mon Sep 17 00:00:00 2001 From: Wouch Date: Wed, 4 Oct 2023 18:06:46 +0300 Subject: [PATCH 2/4] golden ratio functions --- homework/github_week3/fibonacci.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index bf3a00f..6f3b705 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -5,8 +5,10 @@ and functionally decomposes the calculations. Fill in all the missing code in the functions and in main """ +import math import typing + def get_input() -> int: """Gets input from the user and returns it as an integer""" pass @@ -23,13 +25,18 @@ def fibonacci_single(n: int) -> int: def golden_section_num() -> float: - """Returns the golden section number (capital Phi)""" - pass + """ + Returns the golden section number (capital Phi) + """ + + return (1 + math.sqrt(5)) / 2 def golden_section_reciprocal() -> float: - """Returns the reciprocal of the golden section number (lowercase phi)""" - pass + """ + Returns the reciprocal of the golden section number (lowercase phi) + """ + return (1 - math.sqrt(5)) / 2 def power(num: int, n: int) -> int: From a04920cce8f8c70720843a4bf121f93df0f39802 Mon Sep 17 00:00:00 2001 From: artur Date: Wed, 4 Oct 2023 18:36:08 +0300 Subject: [PATCH 3/4] get_input and fibonacci_list functions --- 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..e856194 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -7,14 +7,20 @@ """ import typing -def get_input() -> int: +def get_input(inputed) -> int: """Gets input from the user and returns it as an integer""" - pass + if isinstance(inputed, int): + return int(inputed) def fibonacci_list(n: int) -> typing.List[int]: """Returns a list of the first n Fibonacci numbers""" - pass + if isinstance(n, int): + fib_sequence = [1, 2] + for i in range(n-2): + add = fib_sequence[i] + fib_sequence[i + 1] + fib_sequence.append(add) + return fib_sequence def fibonacci_single(n: int) -> int: From 950a8d2120b6d88ca52bccfa65a69412e3153b94 Mon Sep 17 00:00:00 2001 From: artur Date: Wed, 4 Oct 2023 18:55:05 +0300 Subject: [PATCH 4/4] get_input and fibonacci_list functions --- homework/github_week3/fibonacci.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/homework/github_week3/fibonacci.py b/homework/github_week3/fibonacci.py index e856194..ea0462f 100644 --- a/homework/github_week3/fibonacci.py +++ b/homework/github_week3/fibonacci.py @@ -7,10 +7,9 @@ """ import typing -def get_input(inputed) -> int: +def get_input() -> int: """Gets input from the user and returns it as an integer""" - if isinstance(inputed, int): - return int(inputed) + return int(input()) def fibonacci_list(n: int) -> typing.List[int]: