Page 243 - Robotics and AI class 10
P. 243
#Coding & Computational Thinking
Lab Activity
1 Write a Python program to:
a. Interchange the values of the adjacent elements of the list. Print the updated list.
b. Input five names of cities in a list. Accept a name and check whether it exists in a list or not. Display
appropriate message.
c. Input five subject’s marks in a list and print the percentage of all.
d. Create a list with heterogeneous values and print the values which are only integer.
e. Create a list of five subject’s marks and print the marks >50.
2. Write a program that uses max( ) function to get maximum value in tuples.
3. Write a Python program to display all the elements of the given tuple (tup= ('o', 'r', 'a', 'n', 'g', 'e')) except
'a' and 'e'.
4. Find the output of the following programs:
a. A list is declared as
marks = [20,15,45,25,30]
What will be the output of
print(3*marks[2] - 4*marks[4])
b. word=['P','R','O','G','R','A','M']
print(word[-4:])
print(word[::-2])
c. word=['P','R','O','G','R','A','M']
print(word.count('R'))
print(word.index('R'))
d. L=[1,2,3]
L*=3
print(L)
e. list1=[10,20]
list2=[30,40]
list1.append(25)
print(list1)
list1.extend(list2)
print(list1)
Introduction to Data and Programming with Python 241

