From 29d274c40d20d285ac493284c6a10e17b9fb4319 Mon Sep 17 00:00:00 2001 From: cabbagepsyduck Date: Thu, 21 Jan 2021 02:26:47 +0530 Subject: [PATCH 1/2] hemlo this be assignment 1 --- Week1/run.py | 14 ++++++++++++-- Week1/work.py | 46 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/Week1/run.py b/Week1/run.py index be6df67..9f5b6a3 100644 --- a/Week1/run.py +++ b/Week1/run.py @@ -5,14 +5,23 @@ Problem - 0 Print the odd values in the given array ''' -arr = [5,99,36,54,88] +arr = [5, 99, 36, 54, 88] ## Code Here - +for num in arr: + if num % 2 !=0: + print(num) ''' Problem - 1 Print all the prime numbers from 0-100 ''' ## Code Here +for num in range(0, 100): + if num > 1: + for i in range(2, num): + if (num % i) == 0: + break + else: + print(num) ''' Problem - 2 @@ -20,3 +29,4 @@ ''' string = 'Reverse Me!' ## Code Here +print(string[::-1]) diff --git a/Week1/work.py b/Week1/work.py index 0099552..bb05721 100644 --- a/Week1/work.py +++ b/Week1/work.py @@ -1,6 +1,7 @@ import math import numpy as np + def demo(x): ''' This is a demo function @@ -12,7 +13,9 @@ def demo(x): ''' ## Code Here - return None + + return x * x + def is_palindrome(string): ''' @@ -23,9 +26,9 @@ def is_palindrome(string): returns: flag (bool) ''' - ## Code Here - return None + return string == string[::-1] + def sqrt_of_numbers(num): ''' @@ -37,7 +40,8 @@ def sqrt_of_numbers(num): ''' ## Code Here - return None + return num ** 0.5 + def Maximum(arr): ''' @@ -50,7 +54,11 @@ def Maximum(arr): ''' ## Code Here - return None + arr.sort() + Max1 = arr[-1] + Max2 = arr[-2] + return Max1, Max2 + def even_sort(arr): ''' @@ -67,7 +75,17 @@ def even_sort(arr): ''' ## Code Here - return None + arr.sort() + arr1 = [] + arr2 = [] + for num in arr: + if num % 2 == 0: + arr1.append(num) + else: + arr2.append(num) + + a = arr1 + arr2 + return a def eqn_solver(A, B, C): @@ -88,4 +106,18 @@ def eqn_solver(A, B, C): ''' ## Code Here - return None + Arr1 = np.array((A, B)) + Arr1 = np.transpose(Arr1) + Arr2 = np.array(C) + a = np.linalg.solve(Arr1, Arr2) + + return a[0],a[1] + + + + + + + + + From 3fa8617d381d8b0293141a657355c63ab5dc28f3 Mon Sep 17 00:00:00 2001 From: cabbagepsyduck <76392932+cabbagepsyduck@users.noreply.github.com> Date: Thu, 21 Jan 2021 02:39:40 +0530 Subject: [PATCH 2/2] assignmemt 1 --- Week1/work.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Week1/work.py b/Week1/work.py index bb05721..3018800 100644 --- a/Week1/work.py +++ b/Week1/work.py @@ -121,3 +121,4 @@ def eqn_solver(A, B, C): +