- Write
a program that checks if a number is even or odd using the modulo operator
and an if-else statement.
- Create
a loop that prints the first 10 multiples of 3.
- Use a
nested loop to print a simple pattern of asterisks (e.g., a right-angled triangle).
- Write a program that uses the break statement to exit a loop when a specific condition is met.
- Implement a simple calculator that performs basic arithmetic operations based on user input. #PROBLEMS ON FUNCTIONS
6. Write a function that
takes two numbers as arguments and returns their sum, difference, product, and
quotient.
7. Create a function with
default arguments that calculate the area of a rectangle.
8. Write a lambda
function that returns the square of a number, and use it in a list
comprehension to square all numbers in a given list.
9. Implement a function
that uses *args to find the maximum number among the arguments passed.
#PROBLEMS ON STRINGS
10. Write a program that reverses a string
without using the built-in reverse function.
11. Create a function that counts the number of vowels in a given string.
12. Implement a program that checks if a
string is a palindrome.
13. Write a function that capitalizes the
first letter of each word in a sentence.
14. Create a program that removes all
punctuation from a given string.
#LIST OPERATIONS
Write a function that removes duplicates from a list without using set().
Implement a program that finds the second largest number in a list.
Create a function that merges two sorted lists into a single sorted list without using the sort() method.
Write a program that rotates the elements of a list to the right by k steps.
Implement a function that finds all pairs of integers in a list whose sum is equal to a given target.#
- Tuple and its Operations
- Create a program that converts a list of tuples into a dictionary.
- Implement a function that finds the index of the maximum value in a tuple of numbers.
- Write a program that sorts a list of tuples based on the second element of each tuple.
- Create a function that zips two tuples together into a list of tuples.
- Write a function that returns the frequency of each element in a tuple.
Sets and Dictionaries
Write a function that finds the symmetric difference between two sets.
Implement a program that counts the frequency of words in a given text using a dictionary.
Create a function that merges two dictionaries, summing the values of common keys.
Write a program that finds the key with the maximum value in a dictionary.
Implement a nested dictionary to represent a simple address book and write functions to add, delete, and search for contacts.