0% found this document useful (0 votes)
11 views2 pages

Python Questions

The document provides a series of programming exercises categorized into basic and intermediate levels for strings, lists, tuples, sets, and dictionaries in Python. Each category contains specific tasks such as counting vowels, reversing strings, manipulating lists, and working with dictionaries. The exercises aim to enhance understanding and skills in handling these data structures.

Uploaded by

movieshd2314
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)
11 views2 pages

Python Questions

The document provides a series of programming exercises categorized into basic and intermediate levels for strings, lists, tuples, sets, and dictionaries in Python. Each category contains specific tasks such as counting vowels, reversing strings, manipulating lists, and working with dictionaries. The exercises aim to enhance understanding and skills in handling these data structures.

Uploaded by

movieshd2314
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

🧵 STRINGS

BASIC:
[Link] a Python program to count the number of vowels in a string.
[Link] do you reverse a string without using slicing?
[Link] code to check if a string is a palindrome.
[Link] will be the output of "hello".capitalize()?
[Link] "world" from the string "Hello world!".
INTERMIDIATE:
6. Write a program to count the frequency of each character in a string.

7. Remove all punctuation marks from a given string.


8. Replace all spaces in a string with underscores _.

9. Write a program to combine two strings using concatenation.


10. Convert "PYTHON IS FUN" → "Python is fun" using string functions.

📋 LISTS
BASIC:
[Link] a list of 5 fruits and print the second and last fruit.
[Link] "grapes" to the list using two different methods.
[Link] "apple" from a list if it exists.
[Link] a list of numbers in descending order.
[Link] code to find the sum and average of elements in a list.
INTERMIDIATE:
6. Remove all duplicates from a list without using set().

7. Merge two lists and remove duplicates.

8. Write a program to find the second largest number in a list.

9. Create a list comprehension that squares all even numbers.

10. Rotate a list by 2 positions to the right.

🍂 TUPLES
BASIC:
1. Create a tuple with 5 elements and print the first three.
2. What happens if you try to change an element of a tuple?
3. Convert a tuple to a list and modify it.
4. Find the index of a given element in a tuple.
5. Check if a particular value exists in a tuple.
INTERMIDIATE :
6. Write a program to count how many times an element appears in a tuple.
7. Concatenate two tuples and print the result.

8. Sort a tuple of numbers.

9. Find the maximum and minimum values in a tuple.


10. Convert a list of tuples → dictionary.

🧮 SETS:
BASIC:
[Link] a set of numbers and print its length.
[Link] and remove elements from a set.
[Link] if an element exists in a set.
[Link] a list with duplicates into a set.
[Link] all elements from a set.
INTERMIDIATE:
6. Find union, intersection, and difference of two sets.
7. Write a program to find common elements between two lists using sets.

8. Check if one set is a subset of another.

9. Remove duplicates from a list using set and convert back to list.

10. Create two sets and print elements that are in one but not both (symmetric difference).

📘 DICTIONARIES
BASIC:
[Link] a dictionary with name, age, and city keys.
[Link] and print the value of the key "age".
[Link] a new key-value pair to the dictionary.
[Link] a key from the dictionary.
[Link] all keys and all values separately.
INTERMIDIATE:
6. Write a program to count the frequency of words in a sentence using a dictionary.

7. Merge two dictionaries.

8. Find the key with the maximum value in a dictionary.

9. Convert two lists — one of keys and one of values — into a dictionary.

10. Create a nested dictionary of 3 students and print their details.

You might also like