From dd597f3382ed46c66b25cfaee6a0f4f4b807a88b Mon Sep 17 00:00:00 2001 From: Arbaz Khan <49393716+Arbazkhan4712@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:38:04 +0530 Subject: [PATCH 1/2] Add files via upload --- Progamming_Warehouse_Task/Q0.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Progamming_Warehouse_Task/Q0.py diff --git a/Progamming_Warehouse_Task/Q0.py b/Progamming_Warehouse_Task/Q0.py new file mode 100644 index 0000000..d8ea934 --- /dev/null +++ b/Progamming_Warehouse_Task/Q0.py @@ -0,0 +1,31 @@ +# from string import ascii_lowercase + +# n=int(input("Enter the Size")) + +# width = 4*n - 3 +# s = ascii_lowercase[:n] +# s = s[::-1] + s[1:] + +# for c in s: +# pat = s[:s.index(c)] +# pat = '-'.join(pat + c + pat[::-1]) +# dashes = (width - len(pat)) // 2 * '-' +# print(dashes + pat + dashes) +def recur_fibo(n): + + if n <= 1: + return n + else: + return(recur_fibo(n-1) + recur_fibo(n-2)) + + + +nterms = int(input("How many terms? ")) + +# check if the number of terms is valid +if nterms <= 0: + print("Plese enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(nterms): + print(recur_fibo(i)) \ No newline at end of file From 2373726c9df2c172dea8ba1e8d53cb2dd9b6320a Mon Sep 17 00:00:00 2001 From: Arbaz Khan <49393716+Arbazkhan4712@users.noreply.github.com> Date: Sat, 2 Nov 2019 18:39:53 +0530 Subject: [PATCH 2/2] Add files via upload --- Progamming_Warehouse_Task/Q0.py | 38 +++++++------------------- Progamming_Warehouse_Task/fibonacci.py | 16 +++++++++++ 2 files changed, 26 insertions(+), 28 deletions(-) create mode 100644 Progamming_Warehouse_Task/fibonacci.py diff --git a/Progamming_Warehouse_Task/Q0.py b/Progamming_Warehouse_Task/Q0.py index d8ea934..2b0f878 100644 --- a/Progamming_Warehouse_Task/Q0.py +++ b/Progamming_Warehouse_Task/Q0.py @@ -1,31 +1,13 @@ -# from string import ascii_lowercase +from string import ascii_lowercase -# n=int(input("Enter the Size")) +n=int(input("Enter the Size")) -# width = 4*n - 3 -# s = ascii_lowercase[:n] -# s = s[::-1] + s[1:] +width = 4*n - 3 +s = ascii_lowercase[:n] +s = s[::-1] + s[1:] -# for c in s: -# pat = s[:s.index(c)] -# pat = '-'.join(pat + c + pat[::-1]) -# dashes = (width - len(pat)) // 2 * '-' -# print(dashes + pat + dashes) -def recur_fibo(n): - - if n <= 1: - return n - else: - return(recur_fibo(n-1) + recur_fibo(n-2)) - - - -nterms = int(input("How many terms? ")) - -# check if the number of terms is valid -if nterms <= 0: - print("Plese enter a positive integer") -else: - print("Fibonacci sequence:") - for i in range(nterms): - print(recur_fibo(i)) \ No newline at end of file +for c in s: + pat = s[:s.index(c)] + pat = '-'.join(pat + c + pat[::-1]) + dashes = (width - len(pat)) // 2 * '-' + print(dashes + pat + dashes) diff --git a/Progamming_Warehouse_Task/fibonacci.py b/Progamming_Warehouse_Task/fibonacci.py new file mode 100644 index 0000000..b773872 --- /dev/null +++ b/Progamming_Warehouse_Task/fibonacci.py @@ -0,0 +1,16 @@ +def recur_fibo(n): + + if n <= 1: + return n + else: + return(recur_fibo(n-1) + recur_fibo(n-2)) + +nterms = int(input("How many terms? ")) + +# check if the number of terms is valid +if nterms <= 0: + print("Plese enter a positive integer") +else: + print("Fibonacci sequence:") + for i in range(nterms): + print(recur_fibo(i)) \ No newline at end of file