From 33aac4c3395e68ba0746ceb2255d5c06543e37cb Mon Sep 17 00:00:00 2001 From: Sudipto Mallick Date: Tue, 9 Jan 2024 10:58:43 +0530 Subject: Modify Python assignments list as instructed --- python/index.typ | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/python/index.typ b/python/index.typ index 98accaf..cafe697 100644 --- a/python/index.typ +++ b/python/index.typ @@ -146,10 +146,9 @@ = Lists -+ Write a Python program to simulate a stack and a queue using lists. - #nntiv[Note that the queue deletion operation won’t run in $O(1)$ time.] ++ Write a Python program to simulate a stack and a queue using lists using functions. + Write a Python program to find all the odd numbers and numbers divisible by 3 from a list of numbers using list comprehension. -+ Write a Python program to find the second largest number in a list of numbers. ++ Write a Python program to find the third largest number in a list of numbers without sorting. + Write a Python program to generate a list of numbers `items` using list comprehension as per the following description: $ "items"[ i ] = cases( i^2 quad "if " i "is even", @@ -161,34 +160,30 @@ = Tuples -+ Write a Python program that, given sequences of first and last names, generate a tuple of tuples each of which contains the full name of a person, using the `zip()` function. -+ Write a Python program to create and modify tuples in various ways. ++ Write a Python program that, given sequences of first and last names, generate another sequence which contains the full name of each person, using the `zip()` function. + Write a Python program to take a nested tuple with the name, Roll No. and marks of some students and find the name of the student having highest marks. -+ Write a Python program to take a list of numbers (both positive and negative) and make a new tuple out from this list with only the positive values. -+ Write a Python program to demonstrate the definition and use of a function taking variable length arguments (scatter and gather) using the `*` symbol. ++ Write a Python program to take a list of numbers (both positive and negative) and make a new tuple out from this list with only the positive values using generator expression. ++ Write a Python program to add variable number of arguments (scatter and gather) using the `*` symbol. = Sets -+ Write a Python program to remove duplicate items of a list of numbers and duplicate characters in a string using sets. + Write a Python program to implement the Jaccard and cosine similarity of two sets using the set union and intersection operations. -+ Write a Python program to show the difference between `set.remove()` and `set.discard()` methods. -+ Write a Python program that creates two sets of even numbers in the range 1 to 10 and composite numbers in the range 1 to 20 to demonstrate the use of `all()`, `issuperset()`, `len()`, `sum()` methods on the sets. -+ Write a Python program that generates a set of prime numbers and another set of odd numbers. Demonstrate the result of union, intersection, difference, symmetric difference operations on these sets. -+ Write a Python program that creates two sets: squares and cubes in the range 1 to 10 to demonstrate the use of `update()`, `pop()`, `remove()`, `add()` and `clear()` methods. ++ Write a Python program that creates two sets of even numbers in the range 1 to 50 and composite numbers in the range 1 to 50 to demonstrate the use of `all()`, `issuperset()`, `len()`, `sum()` methods on the sets. ++ Write a Python program that generates a set of prime numbers and another set of odd numbers to demonstrate the result of _union_, _intersection_, _difference_, _symmetric difference_ operations on these sets. ++ Write a Python program that creates two sets: squares and cubes in the range 1 to 50 to demonstrate the use of `update()`, `pop()`, `remove()`, `add()` and `clear()` methods. + Write a Python program to demonstrate the use of frozensets. = Dictionaries -+ Write a Python program to count the word and letter occurrences in a long string of text using dictionaries. ++ Write a Python function which takes a string and returns a dictionary containing the number of words and letters in the provided string. + Write a Python program to invert a dictionary such the previous keys become values and values become keys. #nntiv[For example: if the initial and inverted dictionaries are `d1` and `d2`, where `d1 = {1: 'a', 2: 'b', 3: 120}`, then `d2 = {'a': 1, 2: 'b', 120: 3}`.] -+ What if the values in 2 are not immutable? Use frozensets, For repeated values, use lists. For example: if `d1 = {1: 'a', 2: 'a', 4: [1, 2]}`, then `d2 = {'a': [1, 2], frozenset([1, 2]): 4}`. + Write a Python program with a function to generate the Fibonacci numbers in + Exponential time using the naïve algorithm. + Linear time using dynamic programming (memoization) with a dictionary. -+ Write a Python program to generate a dictionary where each key is a number and the corresponding value is the number’s square using dictionary comprehensions. ++ Write a Python program to generate a dictionary where each key is a number and the corresponding value is the number’s square using dictionary comprehension. + Write a Python program to store a sparse matrix as a dictionary. -+ Write a Python program that combines lists of keys and values into a dictionary. ++ Write a Python program that combines two lists, one of keys, and another of values, into a dictionary. = User-Defined Functions -- cgit 1.4.1-2-gfad0