0% found this document useful (0 votes)
4 views

1project Cs

Now its a project file based on cs final project

Uploaded by

varunka1205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

1project Cs

Now its a project file based on cs final project

Uploaded by

varunka1205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

LIST PROGRAM-1

INPUT:
l1=list()
def oddeven(l1):
for i in range(B):
if 1[i]%2==0:
l1[i]=l1[i]/2
else:
l1[i]=l1[i]*2
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

oddeven(l1)
print(l1)

OUTPUT:
Enter the size of the list:2
Enter the value:5
Enter the value:8
[10, 4.0]
LIST PROGRAM-2

INPUT:
def sumavg(a,s):
c=0
for y in a:
c+=y
av=c/s
return(av,c)

l1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

q=tuple(sumavg(l1,B))
print("average and sum respectively is",q)

OUTPUT:
Enter the size of the
list:3 Enter the value:5
Enter the value:6
Enter the value:7
average and sum respectively is (6.0, 18)
LIST PROGRAM-3

INPUT:
def number(l1,a):
for i,num in
enumerate(l1): if
num==a:
return i
return -1

l1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

a=int(input("enter number to be searched"))

result=number(l1,a)
p=result+1
if result!=-1:
print("the number was found at the position",p,"in the
list") else:
print("number not in list, please check")

OUTPUT:
Enter the size of the list:3
Enter the value:69
Enter the value:75
Enter the value:80
enter number to be searched80
the number was found at the position 3 in the list
LIST PROGRAM-4

INPUT:
L1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) L1.append(z)
A=int(input("Enter the value to be searched:"))
S=L1.index(A)
P=S+1
print("The value",A,"found at position",P)
Q=L1.count(A)
print("The total number of occurances are:",Q)

OUTPUT:
Enter the size of the
list:4 Enter the value:7
Enter the
value:7 Enter
the value:5
Enter the
value:9
Enter the value to be searched:7
The value 7 found at position 1
The total number of occurances are: 2
LIST PROGRAM-5

INPUT:
def removeodd(a):
for y in a:
if y%2>0:
l1.remove(y)
return(a)
l1=list()
l2=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)
l2=tuple(l1)
removeodd(l2)
print("List after removing odd numbers is" , l1)

OUTPUT:
Enter the size of the
list:5 Enter the value:5
Enter the
value:6 Enter
the value:7
Enter the
value:8 Enter
the value:9
List after removing odd numbers is [6, 8]
LIST PROGRAM-6

INPUT:
def sle(a):
a.sort(reverse=True)
return(a[1])

l1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

q=sle(l1)
print("The second largest element in the list is:",q)

OUTPUT:
Enter the size of the list:3
Enter the value:5
Enter the value:9
Enter the value:8
The second largest element in the list is: 8
LIST PROGRAM-7

INPUT:
l1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

l2=list(l1)
di=dict()
for j in range(B):
if l1[j] not in
di:
di[l1[j]] = 1
else:
di[l1[j]] += 1
print(di)

OUTPUT:
Enter the size of the
list:5 Enter the value:5
Enter the
value:6 Enter
the value:6
Enter the
value:7 Enter
the value:8
{5: 1, 6: 2, 7: 1, 8: 1}
LIST PROGRAM-8

INPUT:
def ew3(l1):
c=0
for num in l1:
if num%10==3:
c+=num
return c

l1=list()
B=int(input("Enter the size of the list:"))
for i in range (B):
z=int(input("Enter the
value:")) l1.append(z)

result=ew3(l1)
print("sum of all numbers ending with 3 is ",result)

OUTPUT:
Enter the size of the list:5
Enter the value:33
Enter the value:30
Enter the value:5
Enter the value:6
Enter the value:13
sum of all numbers ending with 3 is 46

You might also like