July 21, 2023

M.Sc Python Programming Assignment 6

M.Sc Python Programming Assignments Assignment 6 Question:   Write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of different sizes. Code: def find_common_elements(list1, list2): common_elements = [] for element in list1: if element in list2 and …

M.Sc Python Programming Assignment 6 Read More »

M.Sc Python Programming Assignment 5

M.Sc Python Programming Assignments Assignment 5 Question:   Write a program that prints out all the elements of the list that are less than 10 Code: def print_elements_less_than_10(lst): for element in lst: if element < 10: print(element) # Example list my_list = [4, 12, 6, 9, 15, 2, 7] print("Elements less than 10:") print_elements_less_than_10(my_list) Output: …

M.Sc Python Programming Assignment 5 Read More »

Tech Amplifier Final Logo