Term 2 eportfolio AI- pramodh
Term 2 eportfolio AI- pramodh
Python Code:
my_list = []
my_list.extend([15, 25, 35, 45])
print(my_list)
2)Create two lists: list1 = [10, 20, 30] and list2 = [40, 50, 60]. Write a Python program to
join both lists and print the result.
Python Code:
3)Write a Python program that takes a list of numbers: [12, 5, 7, 3, 9, 1] and sorts it in
ascending order. Print the sorted list.
Python Code:
numbers = [12, 5, 7, 3, 9, 1]
numbers.sort()
print(numbers)
4)Given the list my_list = [100, 200, 300, 400, 500], write a Python program to remove the
number 300 from the list. Then print the updated list.
Python Code:
5)Write a Python program that takes the list [1, 2, 4, 5] and inserts the number 3 between 2
and 4. Print the updated list.
Python Code:
my_list = [1, 2, 4, 5]
my_list.insert(2, 3)
print(my_list)
6)Given a list fruits = ['apple', 'banana', 'cherry'], write a Python program to create a copy of
this list and print the copied list.
Python Code:
7)Write a Python program to clear the entire list numbers = [5, 10, 15, 20] so that it
becomes empty. Print the list after clearing it.
Python Code:
8)Write a Python program to find and print the length of the list colors = ['red', 'green',
'blue', 'yellow'].
Python Code:
9)Write a Python program to concatenate two lists a = [1, 2, 3] and b = [4, 5, 6] using a loop.
Print the final concatenated list.
Python Code:
a = [1, 2, 3]
b = [4, 5, 6]
concatenated_list = []
for item in a:
concatenated_list.append(item)
for item in b:
concatenated_list.append(item)
print(concatenated_list)
10)Given the list grades = [85, 90, 78, 92, 88], write a Python program to sort the list in
descending order and print the result.
Python Code: