# Programs on Dictionary in Python Class 11 | Important Questions-Solved Exercise

Share with others

## Solution:

d={1:21,2:32,3:25}

print(sorted(d.values()))

print(d)

## Solution:

d1 = {1 :”Amit”,2 : “Suman”}

d2 = {4:”Ravi”, 5 : “Kamal”}

d3={ }

for i in (d1,d2):

d3.update(i)

print(d3)

## Solution:

d1 = {1 :”Amit”,2 : “Suman”}

def check(i):

for k in d1:

if k==i:

print(“key is present”)

break

else:

print(“key is not present”)

check(1) #This function is only to verify code

## Solution:

d1 = { }

n=int(input(“Enter any number”))

for i in range(n):

d1[i+1]=(i+1)*5

print(d1)

## Solution :

d1 = {1:2, 2:90, 3: 50}

print(sum(d1.values()))

## Solution :

d1 = {1:2, 2:90, 3: 50}

print(sum(d1.keys()))

## Solution :

d1 = {1:2,2:90, 3 : 50}

s=1

for i in d1:

s=s*i

print(s)

## Solution :

d1 = {1 : 2, 2 : 90, 3 : 50}

k=int(input(“Enter any key”))

if k in d1:

d1.pop(k)

print(d1)

else:

## Solution:

d1 = {1 : 21, 2 : 90, 3 : 50}

mx=max(d1.values())

mn=min(d1.values())

print(“Maximum Value is “ ,mx)

print(“Minimum Value is “ ,mn)

## Solution:

d1={1:”Aman”,2:”Suman”,3:”Aman”}

nd1={ }

for k,v in d1.items():

if v not in nd1.values():

nd1[k]=v

print(nd1)

## Solution:

d1={1:”Aman”,2:”Suman”,3:”Aman”,4:”Kranti”,5:”Suman”}

print(len(d1))

## Solution:

d1={1:”Aman”,2:”Suman”,3:”Aman”,4:”Kranti”,5:”Suman”}

k=int(input(“Enter the key”))

v=input(“Enter the modified value”)

d1[k]=v

print(d1)

## Solution:

t=int(input(“Enter number of terms”))

prod={ }

for i in range(t):

pid=int(input(“Enter product id”))

pn=input(“Enter product name”)

pp=int(input(“Enter product price”))

temp=(pn, pp)

prod[pid]=temp

print(prod)

## Solution:

emp={1:(“Amit”,25000),2:(“Suman”,30000),3:(“Ravi”,36000)}

pid=int(input(“Enter the product id”))

l=[ ]

if pid in emp:

l=emp[pid]

print(“Employee id, Employee Name”, “\t””Salary”)

print(pid,”\t””\t””\t””\t”,l,”\t””\t”,l)

else:

## Solution:

emp={1:(“Amit”,25000),2:(“Suman”,30000),3:(“Ravi”,36000)}

pid=int(input(“Enter the product id”))

l=[ ]

if pid in emp:

l=emp[pid]

if l>25000:

emp[pid]=(l,l+500)

print(emp)

## Solution:

emp={1:(“Amit”,25000),2:(“Suman”,30000),3:(“Ravi”,36000)}

d=list(emp.values())

print(“Employees whose Salary more than 25000 are”)

for i in d:

if i>25000:

print(i)

## Solution:

str1=input(“Enter any String”)

w=str1.split()

d={ }

for i in w:

if i not in d:

d[i]=w.count(i)

for i in d:

print(“frequency of “, i , ” is ” , d[i])

## Solution:

d={ }

s=0

for i in range(5):

rn = int(input(“Enter roll number”))

nm = input(“Enter name “)

mrk = input(“Enter marks”)

temp=(nm, mrk)

d[rn]=temp

for i in d:

L=d[i]

s=s+int(L)

print(“Sum of marks “, s)

## Solution:

str1=input(“Enter any String”)

d={ }

for i in str1:

if i not in d:

d[i]=str1.count(i)

for i in d:

print(“frequency of “, i , ” is ” , d[i])

Class 12 Computer Science Sample Paper 2020-2021.

Class 12 Computer Science Sample Paper Marking Scheme

CBSE Class 12 Board Exam Date Sheet 2020-21

Share with others
error: Content is protected !!