Rony Sheth 23ibm152

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Q.

1 Define a empty list named Country_list and write the program to add the following countries one by
one. “India”, “Germany”, “Bangladesh”, “Sri-Lanka”, “Kuwait”, “Brazil”, “USA”, “UK”

Q2)Perform the following questions on the Country_list defined above and display code of each

statement, and show the output.

a) Get the length of Country_list

b) Print the items at the index at 2, 5 and 6

c) Use the slice function to get a list of [Sri-lanka, Kuwait, Brazil, USA]
d) Show the list of Country_list[0:6:2]

e) Use the slice function to get a list of [UK, USA, Brazil]

f) Insert Argentina at the 4th index

g) Add Argentina at the end

h) Count Argentina in the list

i) Remove Argentina using the pop and remove function


Q3) Write the program using for loop to get the output as below using the following list.

Fast_food = [“waffles”, “sandwich”, “burger”, fries”]

Output:

I like to eat waffles

I like to eat sandwich

I like to eat burger

I don’t like to eat fries.


Q4) 4 Write a program using for loop to get a list of prime numbers between 10 and 30 in descending
order as follows List_prime = [29, 23, 19, 17, 13, 11]
Q5) Write a program to get a list of prime numbers from a list using a while loop. List_num = [3, 17, 9, 2,
4, 8, 97, 43, 39, 49, 41, 43, 47, 52]
Q6) Write a program that takes above list of numbers as input and produces the corresponding
cumulative list where each element in the list at index i is the sum of elements at index j<=i. E.g.
Cumulative_list = [3,20,29……………]

Q7) Program to populate tuple with name of Ocean_tuple by user-entered items as given below.
“Electrical_eel”, “Jelly_fish”, “shrimp”, “Turtles”,”blue_whale”
Q8) Write a program to display whether the item is fish or not in the Ocean_tuple generated in the
above question using for loop. (E.g. The “Jelly_fish” is a fish.)
Q9 ) Write a program to show the index of each of the items in the Ocean_tuple using a while loop.

(E.g. The index of “Electrical_eel” is 0.)


Q 10) Write a program to sort the elements of the Ocean_tuple and display the output and its data

You might also like