From 11f26b18c0af444f2fc8aad08f1acfa79540ab42 Mon Sep 17 00:00:00 2001 From: jagritvats <69034224+jagritvats@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:25:10 +0530 Subject: [PATCH 1/3] Create sort.py sort and sorted method --- Lists/sort.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Lists/sort.py diff --git a/Lists/sort.py b/Lists/sort.py new file mode 100644 index 0000000..2a68cdc --- /dev/null +++ b/Lists/sort.py @@ -0,0 +1,23 @@ +# Lists have 2 main methods for sorting - sort and sorted + +# sort methods sorts the lists while sorted method does not modify the list but returns the sorted lists + +li=[7,3,9,1,0] +print(li) +li.sort() +print(li) # we can see li has become sorted + + +print() + + +li=[2345,678,2134,7687] +print(li) +li2=sorted(li) # the returned value i.e. sorted list is stored in li2 +print(li2) # sorted list +print("\n Original List:") +print(li) # we can see here original list is unchanged + +print('Reverse Sorted:') +li3=sorted(li,reverse=True) # reverse parameter sorts by descending order +print(li3) From 1fa1ff7c9986b80c5a4b6496d8be4b9c517586cc Mon Sep 17 00:00:00 2001 From: jagritvats <69034224+jagritvats@users.noreply.github.com> Date: Thu, 1 Oct 2020 15:26:34 +0530 Subject: [PATCH 2/3] Update sort.py --- Lists/sort.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lists/sort.py b/Lists/sort.py index 2a68cdc..cd2fc85 100644 --- a/Lists/sort.py +++ b/Lists/sort.py @@ -1,5 +1,6 @@ +# Here we will show sorting in lists # Lists have 2 main methods for sorting - sort and sorted - +# added by jagritvats # sort methods sorts the lists while sorted method does not modify the list but returns the sorted lists li=[7,3,9,1,0] From cdd3967959e53dc255e632ba2b528a09da6cf435 Mon Sep 17 00:00:00 2001 From: jagritvats <69034224+jagritvats@users.noreply.github.com> Date: Thu, 1 Oct 2020 21:57:43 +0530 Subject: [PATCH 3/3] Update lambda_en.py --- Functions/lambda_en.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Functions/lambda_en.py b/Functions/lambda_en.py index e553b4b..4fbfa45 100644 --- a/Functions/lambda_en.py +++ b/Functions/lambda_en.py @@ -1,6 +1,9 @@ #what is the output of this code? -gun = lambda x:x*x +#lamda functions are single line functions, they can also be used without name as anonymous functions + +gun = lambda x:x*x # gun stores the function data = 1 for i in range(1,3): data+=gun(i) print(gun(data)) +