Computer Science Practical File Term-2
Computer Science Practical File Term-2
TERM - 2
SESSION – 2021-2022
INDEX
S.NO. PROGRAM DATE T.SIGN
I. PYTHON PROGRAM
CODE:
print("Enter the number of elements in a
list:")
N = int(input())
i = 0
num = []
while i < N:
num1= int(input())
num.append(num1)
i +=1
print(num[i],end=' ')
m,m2 = num[0],num[1]
else:
m,m2 = num[1],num[0]
for x in num[2:]:
if x > m2:
if x > m:
m2, m = m,x
else:
m2 = x
print()
OUTPUT:
Que-2. Write a python code to delete all odd numbers and negative
numbers from a given numeric list.
CODE:
list1 = [11,-1,22,-3,33,55,44,-50,46,101,77,-
100,42]
len1 = len(list1)
i = 0
del list1[i]
len1 = len1 - 1
i = i -1
del list1[i]
len1 = len1 - 1
i = i - 1
i = i + 1
OUTPUT:
Que-3. WAP to find maximum element from the list along with it’s
index number in the list.
CODE:
lst1=eval(input("Enter List 1"))
mn1=min(lst1)
mn2=min(lst2)
if mn1<=mn2:
else:
OUTPUT:
Que-4. WAP to print of elements of a tuple
(‘Hello’,”Isn’t”,’fun’,’?’) in separate lines along with element’s
both indexes (positive and negative).
CODE:
Que-5. Given a tuple (1,2,”a”,”b”). There is a list L with some
elements. Replace the first four element of list with all four
elements of the tuple in a single statement . Print the list before and
after the list is modified .
CODE:
Que-6. WAP to function second largest (T) which take as input a
tuple (T) and return the second largest element in the tuple.
CODE: