Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignmemt1 #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Week1/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@
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
Print the reverse of a string
'''
string = 'Reverse Me!'
## Code Here
print(string[::-1])
47 changes: 40 additions & 7 deletions Week1/work.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import math
import numpy as np


def demo(x):
'''
This is a demo function
Expand All @@ -12,7 +13,9 @@ def demo(x):
'''

## Code Here
return None

return x * x


def is_palindrome(string):
'''
Expand All @@ -23,9 +26,9 @@ def is_palindrome(string):
returns:
flag (bool)
'''

## Code Here
return None
return string == string[::-1]


def sqrt_of_numbers(num):
'''
Expand All @@ -37,7 +40,8 @@ def sqrt_of_numbers(num):
'''

## Code Here
return None
return num ** 0.5


def Maximum(arr):
'''
Expand All @@ -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):
'''
Expand All @@ -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):
Expand All @@ -88,4 +106,19 @@ 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]