From cc4b078bda4e14a3bc062f0412423848337ce185 Mon Sep 17 00:00:00 2001 From: norvel Date: Wed, 5 Oct 2022 13:53:25 +0530 Subject: [PATCH 1/2] example2_added --- lambda/example2.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lambda/example2.py diff --git a/lambda/example2.py b/lambda/example2.py new file mode 100644 index 0000000..1f98602 --- /dev/null +++ b/lambda/example2.py @@ -0,0 +1,25 @@ +# Add 10 to argument a, and return the result: +x = lambda a : a + 10 +print(x(5)) + +# square of number +squ = lambda num: num**2 +print(squ(5)) + +# Summarize argument a, b, and c and return the result: +x = lambda a, b, c : a + b + c +print(x(5, 6, 2)) + + +# reverse a string with the help of list, map, lamda +fun=["pthon","is","fun"] +ans=(list(map(lambda x:x[::-1],fun))) +print(ans) + +# first latter of word of list +name=["python","with","s3cloudehub"] +(print(list(map(lambda n:n[0],name)))) + +# print even number +mynum=[1,2,3,4,5,6] +print(list(filter(lambda num:num%2==0,mynum))) From 88d5b5cf173f85350d23495ce4bc8b4c88884660 Mon Sep 17 00:00:00 2001 From: norvel Date: Wed, 5 Oct 2022 14:05:27 +0530 Subject: [PATCH 2/2] nested_scop_local_veriabel_example --- nested_stetment_and_scop/local_example.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 nested_stetment_and_scop/local_example.py diff --git a/nested_stetment_and_scop/local_example.py b/nested_stetment_and_scop/local_example.py new file mode 100644 index 0000000..a4d408e --- /dev/null +++ b/nested_stetment_and_scop/local_example.py @@ -0,0 +1,17 @@ +# Local Reassigment! +x=200 +print(f"just localy change x to {x}") + +# How To Run +# local_ocal_example.py" +# output just localy change x to 200 + +def myfunc(): + x = 300 #local veriabal + print(x) + +myfunc() + +# How To Run +# local_ocal_example.py" +# output 300 \ No newline at end of file