Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Functions/lambda_en.py
Original file line number Diff line number Diff line change
@@ -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))

24 changes: 24 additions & 0 deletions Lists/sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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]
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)