Chapter folders renamed

This commit is contained in:
Karan Solanki
2021-08-13 11:44:51 +05:30
parent d9f3f5b159
commit 1eb709f83a
211 changed files with 0 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#dictcomp1.py
dict1 = {'a': 100, 'b': 200, 'c': 300}
dict2 = {x : int(y/2) for (x, y) in dict1.items() if y <=200}
print(dict2)
dict3 = {}
for x,y in dict1.items():
if y <= 200:
dict3[x] = int(y/2)
print(dict3)
+5
View File
@@ -0,0 +1,5 @@
#gencomp1.py
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
gen1 = (x for x in list1 if x % 2 ==0)
print(list(gen1))
+10
View File
@@ -0,0 +1,10 @@
#list1.py
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [x+1 for x in list1]
print(list2)
list3 = []
for x in list1:
list3.append(x+1)
print(list3)
+6
View File
@@ -0,0 +1,6 @@
#list2.py
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [x for x in list1 if x % 2 == 0]
print(list2)
+12
View File
@@ -0,0 +1,12 @@
#setcomp1.py
list1 = [1, 2, 6, 4, 5, 6, 7, 8, 9, 10, 8]
set1 = {x for x in list1 if x % 2 ==0}
print(set1)
set2 = set()
for x in list1:
if x % 2 == 0:
set2.add(x)
print(set2)