From f6f3ad118683d62ce4776474dc91c1223d182a2a Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Thu, 17 Nov 2022 21:58:22 +0200 Subject: [PATCH] Problems from class [Seminar 5] --- Seminar5/from-class/problem1.py | 12 ++++++++++++ Seminar5/from-class/problem2.py | 16 ++++++++++++++++ Seminar5/from-class/problem3.py | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 Seminar5/from-class/problem1.py create mode 100644 Seminar5/from-class/problem2.py create mode 100644 Seminar5/from-class/problem3.py diff --git a/Seminar5/from-class/problem1.py b/Seminar5/from-class/problem1.py new file mode 100644 index 0000000..b9d45c2 --- /dev/null +++ b/Seminar5/from-class/problem1.py @@ -0,0 +1,12 @@ +#print fiibonacci numbers + +n = int(input("Enter a number: ")) +f,s = 1,1 +counter = 0 +result = [] +while(counter < n): + result.append(f) + f, s = s, f+s + counter+=1 + +print(result) \ No newline at end of file diff --git a/Seminar5/from-class/problem2.py b/Seminar5/from-class/problem2.py new file mode 100644 index 0000000..46f9e6d --- /dev/null +++ b/Seminar5/from-class/problem2.py @@ -0,0 +1,16 @@ +# print multiple fibonacci sequences + +def print_fibonacci(n): + f,s = 1,1 + counter = 0 + result = [] + while(counter < n): + result.append(f) + f, s = s, f+s + counter+=1 + print(result) + +first = int(input('Enter the first number: ')) +second = int(input('Enter the second number: ')) +for i in range(first, second): + print_fibonacci(i) \ No newline at end of file diff --git a/Seminar5/from-class/problem3.py b/Seminar5/from-class/problem3.py new file mode 100644 index 0000000..8c74212 --- /dev/null +++ b/Seminar5/from-class/problem3.py @@ -0,0 +1,18 @@ +# print an array of multiple fibonacci sequences + +def get_fibonacci(n): + f,s = 1,1 + counter = 0 + result = [] + while(counter < n): + result.append(f) + f, s = s, f+s + counter+=1 + return result + +fibonacci_list = [] +first = int(input('Enter the first number: ')) +second = int(input('Enter the second number: ')) +for i in range(first, second): + fibonacci_list.append(get_fibonacci(i)) +print(fibonacci_list) \ No newline at end of file