You are on page 1of 4

Aditya Shekhar

(22BCE11112)
Challenging task module 7

Challenging Task-Peer Assessment 1


print("Enter Number of Currencies:")
n = [1,2,3,1,2,3,1,2,3,1,1]
print("Enter the name of the country 1 for India / 2 for USA / 3 for Japan")
country =int(input("Enter the option:"))
if country == 1:
count = n.count(1)
print("No of Indian Currencies:",count)
elif country == 2:
count = n.count(2)
print("No of USA Currencies:",count)
elif country == 3:
count = n.count(3)
print("No of Japan Currencies:",count)
else:
print("No option, enter the correct option")

Challenging Task-Peer Assessment 2


names = ["Sunny", "Ravi", "Vijay", "Messi"]
salary=[25000,23000, 26000, 30000]
#length=len(names)
#item=0
i=0
for item in names:
print(item,"salary is: ",salary[i])
i+=1
r_name=input("Enter the name of employee to resigned:")
for item in names:
if(r_name == item):
index = names.index(r_name)
print(index)
names.pop(index)
salary.pop(index)
#print(names[index])
print("Updated Database is:")
i=0
for item in names:
print(item,"salary is: ",salary[i])
i+=1

Challenging Task-Peer Assessment 3

# Function to check if a key exists in a dictionary


def check_key(dictionary, key):
if key in dictionary:
return True
else:
return False
my_dict = {'a': 1, 'b': 2, 'c': 3}
key = 'a'
if check_key(my_dict, key):
print("The key '" + key + "' exists in the dictionary.")
else:
print("The key '" + key + "' does not exist in the dictionary.")

Challenging Task-Peer Assessment 4

import numpy as np
my_list=[7,8,7,8,7,8,9]
print("Standard Deviation is:",np.std(my_list))
average = sum(my_list)/len(my_list)
print("Mean is: ",average)

Challenging Task-Peer Assessment 5

# Function to find the longest word in a list


def longest_word(words):
longest = ""
for word in words:
if len(word) > len(longest):
longest = word
return longest

# Input: number of words in the list


num_words = int(input("Enter number of words in the list: "))
# Input: list of words
words = []
for i in range(num_words):
word = input("Enter word: ")
words.append(word)

# Call the function and print the result


longest = longest_word(words)
print("The word with the longest length is: ", longest)

Challenging Task-Peer Assessment 6

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)

You might also like