Programs 6 to 10
Programs 6 to 10
Source Code:
Source Code:
(a) Define a list ‘list1’ with 5 elements: [12, 56, 89, 10, 33].
(f) Print all elements in ‘list1’ using a for loop with indexing.
(g) Print all elements in ‘list1’ using negative indexing in a for loop.
(h) Define another list ‘list2’ with 5 elements: [23, 33, 44, 55, 11].
(i) Add ‘list1’ and ‘list2’ to create a new list ‘list3’ and print it.
Source Code:
9. Write a python program to create a list of fruits and perform list operations append,
insert, extend, pop, remove, sort and reverse elements in the fruits list
Source Code:
Source Code:
#program to input temperature and calculate mean, median, mode
import statistics
temp = [ ]
print('enter temperature of 10 cities :')
#input temperature of 10 cities using for loop
for a in range(0,10,1):
num=float(input(" "))
temp.append(num)
#calculating mean
x=statistics.mean(temp)
print("mean=",x)
#calculating median
y=statistics.median(temp)
print("median=",y)
#calculating mode
z=statistics.mode(temp)
print("mode =",z)