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))) 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