0% found this document useful (0 votes)
6 views

python practice questions

The document outlines a programming assignment consisting of 20 tasks that involve writing functions for various data structures including lists, tuples, sets, and dictionaries. Each task specifies a particular operation to be performed, such as summing elements, removing duplicates, reversing lists, and finding maximum values. The assignment emphasizes the use of loops and does not allow the use of built-in functions for certain tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

python practice questions

The document outlines a programming assignment consisting of 20 tasks that involve writing functions for various data structures including lists, tuples, sets, and dictionaries. Each task specifies a particular operation to be performed, such as summing elements, removing duplicates, reversing lists, and finding maximum values. The assignment emphasizes the use of loops and does not allow the use of built-in functions for certain tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment-4

1. Write a function that takes a list of numbers and returns the sum of all elements using a for
loop.
2. Write a function that removes all duplicate elements from a list using a while loop.
3. Create a function that reverses a list without using built-in functions.
4. Write a function to find the maximum number in a list using a for loop.
5. Implement a function that checks if a given element exists in a list using a while loop.
6. Write a function that takes a tuple of numbers and returns a new tuple with only even
numbers.
7. Write a function that finds the index of a given element in a tuple using a for loop.
8. Create a function that converts a tuple of numbers into a list, modifies it, and returns the new
tuple.
9. Implement a function to merge two tuples using a for loop.
10. Write a function that calculates the sum of all elements in a tuple using a while loop.
11. Write a function that takes a set and a value, and removes the value if it exists using a while
loop.
12. Create a function that finds the union of two sets using a for loop.
13. Write a function to check if all elements of one set exist in another set using a loop.
14. Implement a function that finds the difference between two sets without using built-in
methods.
15. Write a function that converts a set to a list and returns the sorted list using a for loop.
16. Write a function that takes a dictionary and returns a list of all its keys using a loop.
17. Create a function that finds the key with the highest value in a dictionary.
18. Write a function that reverses keys and values in a dictionary using a for loop.
19. Implement a function that counts occurrences of each word in a list and stores them in a
dictionary.
20. Write a function that removes dictionary entries where values are less than a given threshold
using a while loop.

You might also like