The document provides examples of Python programs involving lists, tuples, dictionaries, and sets. Some examples include multiplying all items in a list, sorting a list of tuples, removing duplicates from a list, finding common members between two lists, converting a list of numbers to a single integer, sorting dictionaries by value, merging dictionaries, and performing operations on sets like removal and clearing.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
27 views
Assignments Python
The document provides examples of Python programs involving lists, tuples, dictionaries, and sets. Some examples include multiplying all items in a list, sorting a list of tuples, removing duplicates from a list, finding common members between two lists, converting a list of numbers to a single integer, sorting dictionaries by value, merging dictionaries, and performing operations on sets like removal and clearing.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
Write a Python program to multiplies all the items in a list.
Write a Python program to get a list, sorted in increasing order by
the last element in each tuple from a given list of non-empty tuples. Write a Python program to remove duplicates from a list. Write a Python program to find the list of words that are longer than n from a given list of words Write a Python function that takes two lists and returns True if they have at least one common member. Write a Python program to find the index of an item in a specified list Write a Python program to generate all sublists of a list. Write a Python program to convert a list of multiple integers into a single integer. Go to the editor Sample list: [11, 33, 50] Expected Output: 113350
Write a Python script to sort (ascending and descending) a dictionary by value.
Write a Python script to check whether a given key already exists in a dictionary. Write a Python program to iterate over dictionaries using for loops. Write a Python script to merge two Python dictionaries Write a Python program to combine two dictionary adding values for common keys. Go to the editor d1 = {'a': 100, 'b': 200, 'c':300} d2 = {'a': 300, 'b': 200, 'd':400} Sample output: Counter({'a': 400, 'b': 400, 'd': 400, 'c': 300}) Write a Python program to sort a list alphabetically in a dictionary.
Write a Python program to remove an item from a set if it is present in the set. Write a Python program to clear a set.