Skip to content

Commit 6ce98c9

Browse files
committed
udemy function module
1 parent 7c2fd47 commit 6ce98c9

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

count primes udemy.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def count_primes(num):
2+
count=1
3+
for i in range (3,num):
4+
for j in range (2, i):
5+
6+
if i%j==0:
7+
break
8+
else:
9+
count+=1
10+
print('The total number of primes in range {} is {}'.format(num, count))
11+
12+
13+
14+
15+
count_primes(100)

mapandfilter_lambdaexpns.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def squares(num):
2+
return num**2
3+
4+
mynumlist=[1, 2, 3 ,4,5]
5+
6+
newlist=list(map(squares,mynumlist))
7+
8+
print(newlist)
9+
10+
def checkeven(num):
11+
return num%2==0
12+
newlist2=list(filter(checkeven,mynumlist))
13+
print(newlist2)
14+
15+
newlist3=[]
16+
newlist4=[]
17+
newlist3= list(map(lambda num:num**2,mynumlist))
18+
print(newlist3)
19+
newlist4= list(filter(lambda num:num%2==0,mynumlist))
20+
print(newlist4)

0 commit comments

Comments
 (0)