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

Computer Science Practical File Term-2

Uploaded by

Deep Kashyap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Computer Science Practical File Term-2

Uploaded by

Deep Kashyap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

COMPUTER SCIENCE PRACTICAL FILE

TERM - 2
SESSION – 2021-2022

PYTHON AND MYSQL FILE


SUMITTED TO- SUBMITTED BY-
KALPANA KAUSHIK DEEP KASHYAP
COMPUTER SCIENCE 11TH-SCIENCE
Roll no. - 12

INDEX
S.NO. PROGRAM DATE T.SIGN
I. PYTHON PROGRAM

1. WAP to find the second largest element in 23-12-21


a list ‘NUM’.

2. Write a python code to delete all odd 27-12-21


numbers and negative numbers from a
given numeric list.

3. WAP to find maximum element from the 29-12-21


list along with it’s index number in the list.

4. WAP to print of elements of a tuple 3-1-22


(‘Hello’,”Isn’t”,’fun’,’?’) in separate lines
along with element’s both indexes (positive
and negative).

5. Given a tuple (1,2,”a”,”b”). There is a list 4-1-22


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 .
6. WAP to function second largest (T) 5-1-22
which take as input a tuple (T) and
return the second largest element in
the tuple.

7. WAP to iterate over dictionaries 10-1-22


using for loops.

8. WAP to get maximum and 11-1-22


minimum value in a dictionary.

9. WAP to create dictionary with key 12-1-22


as first character a word starting
with that character.

10. WAP using dictionary to print the 13-1-22


name and salary of employee.

11. WAP to count the frequency of 14-1-22


each character in string using
dictionary.
Q1 W.A.P to find the second largest element in a list ‘NUM’.

#Deep , 11thsci. Computer Science

CODE:
print("Enter the number of elements in a
list:")

N = int(input())

i = 0

num = []

while i < N:

print("Enter list values:")

num1= int(input())

num.append(num1)

i +=1

print("The Original List is:",end=' ')

for i in range (N):

print(num[i],end=' ')

if (num[0] > num[1]):

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()

print("The second largest element in the list


is:",m2)

OUTPUT:
Que-2. Write a python code to delete all odd numbers and negative
numbers from a given numeric list.

#Deep , 11thsci. Computer Science

CODE:
list1 = [11,-1,22,-3,33,55,44,-50,46,101,77,-
100,42]

len1 = len(list1)

i = 0

while i < len1:

if (list1[i] < 0):

del list1[i]

len1 = len1 - 1

i = i -1

elif (list1[i] % 2 != 0):

del list1[i]

len1 = len1 - 1

i = i - 1

i = i + 1

print("List after deletion :",list1)

OUTPUT:
Que-3. WAP to find maximum element from the list along with it’s
index number in the list.

#Deep , 11thsci. Computer Science

CODE:
lst1=eval(input("Enter List 1"))

lst2=eval(input("Enter List 2"))

mn1=min(lst1)

mn2=min(lst2)

if mn1<=mn2:

print(mn1,"the minimum value is in in the


list 1 at index ",lst1.index(mn1))

else:

print(mn2,"the minimum value is in in the


list 2 at index ",lst2.index(mn2))

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).

#Deep , 11thsci. Computer Science

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 .

#Deep , 11thsci. Computer Science

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.

#Deep , 11thsci. Computer Science

CODE:

You might also like