Adjusted_Python_Lab_Solutions
Adjusted_Python_Lab_Solutions
lst = [1, 2, 3, 4, 5]
print(f"Sum of the list: {recursive_sum(lst)}")
5. Numbers divisible by 5
lst = [10, 23, 45, 66, 75]
result = [x for x in lst if x % 5 == 0]
print(f"Numbers divisible by 5: {result}")
6. Create a new list with odd numbers from the first list and even from the second
list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 10]
result = [x for x in list1 if x % 2 != 0] + [x for x in list2 if x % 2 == 0]
print(f"New list: {result}")
data = {1: {"Name": "Alice", "Marks": 85}, 2: {"Name": "Bob", "Marks": 90}}
with open("students.pkl", "wb") as file:
pickle.dump(data, file)