Skip to content

Commit

Permalink
lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Dec 30, 2019
1 parent d32a158 commit 3431157
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 21 deletions.
13 changes: 13 additions & 0 deletions autoGUI/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# purpose : Program to check mouse position on the move
# author : rakesh kumar
# licence : MIT
import pyautogui
print("Press CTRL+C to stop")
try:
while True:
x,y = pyautogui.position()
positionStr = "X :"+str(x).rjust(4) +" Y :"+ str(y).rjust(4)
print(positionStr, end='')
print('\b' * len(positionStr), end='', flush=True)
except KeyboardInterrupt:
print("\n Done")
2 changes: 1 addition & 1 deletion fileHandling/Bulk_Image_Resizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def small(source,target,original):
dest = target + '\\' +original
with open(original, 'r+b') as f:
with Image.open(f) as image:
cover = resizeimage.resize_cover(image, [900, 450], validate=False)
cover = resizeimage.resize_cover(image, [960, 640], validate=False)
cover.save(dest, image.format)

def deleteFiles():
Expand Down
14 changes: 8 additions & 6 deletions functions/lambda_function.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#program to define lambda function in python
# program to define lambda function in python

f = lambda x : x**2

#lambda function with map() function
l1=[1,2,4,5,6,7,78,7,4,34,4,14,44,4,4]
result = map(f,l1)
print(result)
def f(x): return x**2


# lambda function with map() function
l1 = [1, 2, 4, 5, 6, 7, 78, 7, 4, 34, 4, 14, 44, 4, 4]
result = list(map(f, l1))
print(result)
11 changes: 11 additions & 0 deletions functions/python_kwargs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# python program to demonstrate the use of kwargs arguments in pyhon
# made by : rakesh kumar


def sum_kwargs(**kwargs):
for x, y in kwargs.items():
print('{} and its valiue {}'.format(x, y))


if __name__ == "__main__":
sum_kwargs(name='rakesh', school='DAV', salary=50000)
22 changes: 10 additions & 12 deletions functions/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
def check_prime(n):
flag = True
for x in range(2, n//2):
if n % x == 0:
flag = False

return flag

if __name__ == "__main__":
n = int(input('Enter any integer number : '))
result = check_prime(n)
print("Prime Number " if (result) else '"Not prime Number')
# program to define lambda function in python


def f(x): return x**2


# lambda function with map() function
l1 = [1, 2, 4, 5, 6, 7, 78, 7, 4, 34, 4, 14, 44, 4, 4]
result = map(f, l1)
print(result)
14 changes: 14 additions & 0 deletions functions/variable_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# function to demonstrate the workin of args and kwards paramater
# made by : rakesh kumar


def sum_values(*args):
sum = 0
for x in args:
sum += x
return sum


if __name__ == "__main__":
res = sum_values(1, 2, 3, 4, 5, 6, 7, 8, 9)
print('Sum of values :', res)
2 changes: 0 additions & 2 deletions numpy/sumOfDD.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
a = np.array([(1, 2, 3), (4, 5, 6), (7, 8, 9)])
b = np.sum(a, 1)
print(b)

``

0 comments on commit 3431157

Please sign in to comment.