Professional Documents
Culture Documents
"""a = [1,2,3,4,5,6,7,8,9,10]
sum = 0
for x in a:
sum = sum+x
print(sum)"""
#Write a python program to find largest number in a given list with out using max()
"""a = [1,2,22,3,45,666]
lnum = 0
for x in a:
if x > lnum:
large = x
lnum = large
print(lnum)"""
# Write a python program to find the common numbers from two lists
"""a = [1,2,3,4,22,33,44,6,7,88]
b = [1,22,44,7,8,88]
c =[]
for x in a:
if x in b:
c.append(x)
print(c)"""
#Write a python program to print all even numbers from a given list
"""a = [1,2,3,4,5,6,7,8,9,10]
for x in a:
if x%2 == 0:
print("even numbers",x)"""
#Write a python program to create a list of even numbers and another list of odd
numbers from a given list
"""a = [1,2,3,4,5,6,7,8,9,10,11,19,22,55,3,]
b =[]
c =[]
for x in a:
if x%2 == 0:
b.append(x)
else:
c.append(x)
print("odd number:",c)
print("even numbers:",b)"""
#=================================================
#Write a python program to remove repeated elements from a given list without using
built-in methods
"""a = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,10,10]
b =[]
for x in a:
if x not in b:
b.append(x)
print(b)"""
for x in b:
if len(x)>large:
large_w = x
large = len(x)
print(large_w)
print(x," ",len(x))"""
#Write a python program to find number of occurrences of given number with out
using built-in methods
for x in b:
if x == a:
count = count+1
print(count)"""
#Write a python program to print website suffixes (com , org , net ,in) from this
list
"""a = ["www.zframez.com", "www.wikipedia.org", "www.asp.net", "www.abcd.in"]
b = a[0]
c = a[1]
d = a[2]
e = a[3]
f = b.split(".")
g = c.split(".")
h = d.split(".")
i = e.split(".")
for x in f:
print(f[2],",",end=" ")
break
for x in g:
print(g[2],",",end= " ")
break
for x in h:
print(h[2],",",end= " ")
break
for x in i:
print(i[2])
break"""
#Write a python program to sort a given list of numbers with out using sort()
function
while len(a)>0:
temp = min(a)
c.append(temp)
a.remove(temp)
print(c)"""