You are on page 1of 4

SAMARTH SONI EMAIL ID-

SAMARTHSONI2022@VITBHOPAL.AC.IN

Challenging Task-Peer Assessment 1


In [5]: d={}
a=int (input ("Enter Number of Currencies :"))
for i in range (1, a+1) :
d[i]=input ("Enter the name of the country :")
print ("Data is :", d)

Enter Number of Currencies :3


Enter the name of the country :INDIA
Enter the name of the country :USA
Enter the name of the country :JAPAN
Data is : {1: 'INDIA', 2: 'USA', 3: 'JAPAN'}

Challenging Task-Peer Assessment 2


In [13]: dict1={'Sunny':25000, 'Ravi':23000, 'Vijay':26000, 'Messi':30000}
a=input("input ::")
del dict1[a]
print("All employee data after update ::",dict1)

input ::Sunny
All employee data after update :: {'Ravi': 23000, 'Vijay': 26000, 'Messi': 30000}

Challenging Task-Peer Assessment 3


In [16]: d = {11: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
def is_key_present (x) :
if x in d:
print ('Key is present in the dictionary')
else:
print ('Key is not present in the dictionary')
is_key_present (5)
is_key_present (9)

Key is present in the dictionary


Key is not present in the dictionary

Challenging Task-Peer Assessment 4


In [18]: n=10
a = list (map (int, input ("Enter the numbers :").strip ().split ())) [:n]
from statistics import mean, stdev
print ("Mean is :", mean (a))
print ("Standard deviation is ::",stdev (a))

Enter the numbers :1 2 3 4 5 6 7 8 9 10


Mean is : 5.5
Standard deviation is :: 3.0276503540974917

Challenging Task-Peer Assessment 5


In [23]: n=int (input ("Enter the number of words ::"))
li=[]
for i in range (n) :
c=input ("Enter the name ::")
li.append (c)
maximum=len (li [0])
index=0
print ("list is ::",li)
for i in range(1,n):
count=len (li [i])
if maximum<count:
maximum=count
index=i
else:
continue
print ("Longest word is ::", li [index])

Enter the number of words ::6


Enter the name ::joe
Enter the name ::smith
Enter the name ::wilson
Enter the name ::jack
Enter the name ::david
Enter the name ::paxton
list is :: ['joe', 'smith', 'wilson', 'jack', 'david', 'paxton']
Longest word is :: wilson

Challenging Task-Peer Assessment 6


In [25]: d = {'a': 1, 'b':2, 'c':3, 'd' :4}
print ("Initial dictionary")
print (d)
key=input ("Enter the key to delete (a-d):")
if key in d:
del d[key]
else:
print ("Key not found!")
exit (0)
print ("Updated dictionary")
print (d)

Initial dictionary
{'a': 1, 'b': 2, 'c': 3, 'd': 4}
Enter the key to delete (a-d):c
Updated dictionary
{'a': 1, 'b': 2, 'd': 4}

You might also like