Lab2 - Questions Only CON
Lab2 - Questions Only CON
print(d['b'])
print("Keys of the dictionary are",d.keys())
print("Values of the dictionary are", d.values())
print("Items of the dictionary", d.items())
ball
Keys of the dictionary are dict_keys(['a', 'b', 'c'])
Values of the dictionary are dict_values(['apple', 'ball', 'cat'])
Items of the dictionary dict_items([('a', 'apple'), ('b', 'ball'),
('c', 'cat')])
ENter a number n3
Enter r2
ncr 0.16666666666666666
Exercise 9: Create a list of list with the daily average temperatures of a week as
[['sun',33.3], ['mon',32.1], ['tue',34.5], ['wed',28.7], ['thu',29.9], ['fri',28.6], ['sat',25.5]].
Using a function find the warmest and the coldest day of the week and the corresponding
temperature. Ouput : Warmest is ['tue':34.5] Coldest is ['sat':25.5]
def maxmin(temps1):
out = sorted(temps1, key = operator.itemgetter(1))
return(out)
import operator
temps = [['sun',33.3], ['mon',32.1], ['tue',34.5], ['wed',28.7],
['thu',29.9], ['fri',28.6], ['sat',25.5]]
temps = maxmin(temps)
print("The Coldest Day is", temps[0])
print("The Warmest Day is", temps[len(temps) - 1])
import operator
weekly_temp = eval(input("Enter the daily temperature in a week as
[[]]"))
p = maxmin(weekly_temp)
print("The coldest day is:", p[0])
print("The warmest day is:", p[len(p)-1])