-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Required concepts: https://www.w3schools.com/python/python_intro.asp unpacking functions | ||
print('Question: function to return max of all keyword arguments') | ||
|
||
def findMax(**nums): | ||
val = float('-inf') | ||
name = '' | ||
for n,v in nums.items(): | ||
if v > val: | ||
# if the value is smaller update the answer | ||
name,val = n,v | ||
print(name,'is biggest with value ',val) | ||
|
||
findMax(n1=3,n4=34) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Required concepts: https://www.w3schools.com/python/python_intro.asp while loop and maths | ||
print('Question: reverse number without using strings') | ||
|
||
|
||
def getReverse(num): | ||
res = 0 | ||
while num > 0: | ||
# take last digit and put in the front of res | ||
digit = num % 10 | ||
num //= 10 | ||
res = res * 10 + digit | ||
return res | ||
|
||
|
||
print(getReverse(1234)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
# Required concepts: https://www.w3schools.com/python/python_intro.asp lists and functions | ||
|
||
print('Question: Element which is min in row and max in column') | ||
matrix = [[1,2,3], | ||
[4,5,6], | ||
[7,8,9]] | ||
|
||
def rowMinColMax(matrix): | ||
rowMin,colMax = [],[] | ||
for row in matrix: | ||
rowMin.append(min(row)) | ||
for i in range(len(matrix[0])): | ||
maxi = matrix[0][i] | ||
for j in range(len(matrix)): | ||
maxi = max(maxi,matrix[j][i]) | ||
colMax.append(maxi) | ||
|
||
#now find the overlap | ||
for i in range(len(matrix)): | ||
for j in range(len(matrix[0])): | ||
if rowMin[i] == colMax[j] == matrix[i][j]: | ||
return matrix[i][j] | ||
return False | ||
|
||
print('Answer:') | ||
print(rowMinColMax(matrix)) | ||
|
||
|
||
|
||
|
||
|
||
# Required concepts: https://www.w3schools.com/python/python_intro.asp while loop and maths | ||
print('Question: reverse number without using strings') | ||
|
||
def getReverse(num): | ||
res = 0 | ||
while num > 0: | ||
# take last digit and put in the front of res | ||
digit = num%10 | ||
num //=10 | ||
res = res*10 + digit | ||
return res | ||
print(getReverse(1234)) |