From 3c5c621cfe81420ebe6b9ddb6f6f1a0b71aa07bf Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 11 Apr 2022 02:30:37 -0500 Subject: [PATCH 1/6] L1Q1 Solved --- solutions/level-1/1-question.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solutions/level-1/1-question.py diff --git a/solutions/level-1/1-question.py b/solutions/level-1/1-question.py new file mode 100644 index 00000000..adb5af50 --- /dev/null +++ b/solutions/level-1/1-question.py @@ -0,0 +1,13 @@ +numbers = range(2000, 3201) +collect = [] +for x in numbers: + if x % 7 == 0 and x % 5 != 0: + collect.append(str(x)) + +result = ", ".join(collect) +# print(result) + +result2 = ", ".join([str(x) + for x in range(2000, 3201) if x % 7 == 0 and x % 5 != 0]) + +print(result2 == result) From f096155822aef6f1e7e4589b14576df60e075c7c Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 11 Apr 2022 09:41:10 -0500 Subject: [PATCH 2/6] L1Q2 solved, need explaination on second solution --- solutions/level-1/2-question.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 solutions/level-1/2-question.py diff --git a/solutions/level-1/2-question.py b/solutions/level-1/2-question.py new file mode 100644 index 00000000..420ad732 --- /dev/null +++ b/solutions/level-1/2-question.py @@ -0,0 +1,20 @@ +# Soution One +def factorial(num): + nums = range(1, num + 1) + collect = 1 + i = 1 + while i < len(nums): + collect *= nums[i] + i += 1 + print(collect) + + +# Solutions Two // need explaination +def fact(x): + if x == 0: + return 1 + return x * fact(x - 1) + + +factorial(5) +print(fact(5)) From dafd4d20428df957b946b5666dbef2727256cbf6 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 12 Apr 2022 15:23:10 -0500 Subject: [PATCH 3/6] L1 Q3&4 solved --- solutions/level-1/1-question.py | 5 +++++ solutions/level-1/2-question.py | 5 +++++ solutions/level-1/3-question.py | 14 ++++++++++++++ solutions/level-1/4-question.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 solutions/level-1/3-question.py create mode 100644 solutions/level-1/4-question.py diff --git a/solutions/level-1/1-question.py b/solutions/level-1/1-question.py index adb5af50..19430da1 100644 --- a/solutions/level-1/1-question.py +++ b/solutions/level-1/1-question.py @@ -1,3 +1,8 @@ +""" +Question: Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. +""" + + numbers = range(2000, 3201) collect = [] for x in numbers: diff --git a/solutions/level-1/2-question.py b/solutions/level-1/2-question.py index 420ad732..870a77a3 100644 --- a/solutions/level-1/2-question.py +++ b/solutions/level-1/2-question.py @@ -1,3 +1,8 @@ +""" +Question: Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated sequence on a single line. Suppose the following input is supplied to the program: 8 Then, the output should be: 40320 +""" + + # Soution One def factorial(num): nums = range(1, num + 1) diff --git a/solutions/level-1/3-question.py b/solutions/level-1/3-question.py new file mode 100644 index 00000000..6f8726a5 --- /dev/null +++ b/solutions/level-1/3-question.py @@ -0,0 +1,14 @@ +""" +Question: With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary. Suppose the following input is supplied to the program: 8 Then, the output should be: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} +""" + + +def square_dict(num): + collect = {} + for x in range(1, num + 1): + collect[x] = x * x + print(collect) + + +num = int(input("Please enter a number: ")) +square_dict(num) diff --git a/solutions/level-1/4-question.py b/solutions/level-1/4-question.py new file mode 100644 index 00000000..243915ab --- /dev/null +++ b/solutions/level-1/4-question.py @@ -0,0 +1,28 @@ +""" +Question: Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34,67,55,33,12,98 Then, the output should be: ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', '98') +""" + +# Solution without input + + +# def print_list_tuple(*string): +# print((string)) +# print([x for x in string]) + + +# print_list_tuple(34, 67, 55, 33, 12, 98) + + +# Solution w/ input + + +def input_list_tuple(value): + arr = [int(x) for x in value.split(", ")] + tup = tuple(arr) + print(arr) + print(tup) + + +value = input("Enter nums separated by commas: ") + +input_list_tuple(value) From e5c832180d98cf7f4e2abc52640bba21b34b2e65 Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 13 Apr 2022 22:30:19 -0500 Subject: [PATCH 4/6] L1Q5 solved --- solutions/level-1/5-question.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solutions/level-1/5-question.py diff --git a/solutions/level-1/5-question.py b/solutions/level-1/5-question.py new file mode 100644 index 00000000..34965469 --- /dev/null +++ b/solutions/level-1/5-question.py @@ -0,0 +1,25 @@ +# Solution + +class Yeah: + def __init__(self): + self.inp = input("Enter string: ") + self.getString = self.getString + + def getString(self): + printString = self.inp + print(printString.upper()) + return printString.upper() + + def testGetString(self, actual): + test = self.getString() + if (test == actual and type(test) is type(actual)): + print("Test Passed") + else: + print("Test Failed :(") + + +jaden = Yeah() + +# jaden.getString() + +jaden.testGetString("YEAH") From 2baf6c314ebdcc7ccd404fa3a58b6294df8acd15 Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 13 Apr 2022 22:31:35 -0500 Subject: [PATCH 5/6] Fixing branch --- solutions/level-1/6-question.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/level-1/6-question.py diff --git a/solutions/level-1/6-question.py b/solutions/level-1/6-question.py new file mode 100644 index 00000000..e69de29b From 5b9578911ed7f3d7558b3df2b97ab8034f047357 Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 13 Apr 2022 22:36:40 -0500 Subject: [PATCH 6/6] Stil fixing branch lol --- solutions/level-1/6-question.py | 1 + 1 file changed, 1 insertion(+) diff --git a/solutions/level-1/6-question.py b/solutions/level-1/6-question.py index e69de29b..a6700350 100644 --- a/solutions/level-1/6-question.py +++ b/solutions/level-1/6-question.py @@ -0,0 +1 @@ +# Solution