From d0103a6b3e03474e29fba75e35afe7190b691bea Mon Sep 17 00:00:00 2001 From: Saksham Nuariyal <68427921+saksham715@users.noreply.github.com> Date: Thu, 1 Oct 2020 14:57:39 +0530 Subject: [PATCH 1/3] Update conditionals.py --- python_sandbox_finished/conditionals.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python_sandbox_finished/conditionals.py b/python_sandbox_finished/conditionals.py index 7c07182..6667b0e 100644 --- a/python_sandbox_finished/conditionals.py +++ b/python_sandbox_finished/conditionals.py @@ -64,4 +64,12 @@ # is not if x is not y: - print(x is not y) \ No newline at end of file + print(x is not y) + +x = True + +if x == True: + print("The variable x is True") + +else: + print("The variable x is false") From aac14a00cd256e7623f664d09c165e192e198fe5 Mon Sep 17 00:00:00 2001 From: Saksham Nuariyal <68427921+saksham715@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:15:54 +0530 Subject: [PATCH 2/3] Create map, filter and reduce.py --- .../map, filter and reduce.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 python_sandbox_finished/map, filter and reduce.py diff --git a/python_sandbox_finished/map, filter and reduce.py b/python_sandbox_finished/map, filter and reduce.py new file mode 100644 index 0000000..6369196 --- /dev/null +++ b/python_sandbox_finished/map, filter and reduce.py @@ -0,0 +1,22 @@ +from setuptools import reduce #importing reduce module for using reduce function + +l1 = [2,3,4,5,6] + +mapping_the_l1 = list(map(lambda x: x*2, l1)) # MAP FUNCTION APPLIES THE GIVEN COMMAND TO EVERY INDEX OF A LIST +# IN THIS CASE WE ARE MULTIPLYING EVERY CHARACTER IF LIST l1 TO 2 USING LAMBDA FUNCTION + +print(mapping_the_l1) + + +filtering_the_l1 = list(filter(lambda x: x%2 ==0)) #FILTER FUNCTION FILTERS THE LIST ACCORDING TO OUR WISH +# IN THIS CASE WE ARE FILERING THE NUMBER WHICH IS DIVISIBLE BY 2 IN l1. + +print(filtering_the_l1) + +def add(x, y): + return x+y + +reducing_the_l1 = reduce(add, l1) # REDUCE FUNCTION IS USED FOR DOING MATHEMATICAL OPERATIONS IN A LIST +# HERE, WE ARE ADDING ALL THE CHARACTERS THE LIST l1 + +print(reducing_the_l1) From 7e9409541cf44d5b3f766f704fd7cda31e200a65 Mon Sep 17 00:00:00 2001 From: Saksham Nuariyal <68427921+saksham715@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:25:21 +0530 Subject: [PATCH 3/3] Update map, filter and reduce.py --- python_sandbox_finished/map, filter and reduce.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_sandbox_finished/map, filter and reduce.py b/python_sandbox_finished/map, filter and reduce.py index 6369196..9853013 100644 --- a/python_sandbox_finished/map, filter and reduce.py +++ b/python_sandbox_finished/map, filter and reduce.py @@ -1,4 +1,4 @@ -from setuptools import reduce #importing reduce module for using reduce function +from setuptools import reduce #importing reduce module for using reduce function (Reduce module is default with python) l1 = [2,3,4,5,6]