(Only Python — no DSA, no heavy logic)
- Write a program to remove duplicates from a list while keeping the original order.
- Given a list of numbers, find the second largest element without using
sort(). - Count how many times each element appears in a list.
- Rotate a list to the right by N positions.
- Remove all negative numbers from a list.
- Find common elements between two lists.
- Reverse a list using slicing.
- Add all even numbers from a list.
- Replace every element greater than 50 with the value 50.
- Convert a nested list like
[[1,2],[3,4]]into[1,2,3,4].
- Convert a tuple into a list, modify it, and convert back to tuple.
- Find how many times a value occurs in a tuple.
- Find the maximum and minimum values in a tuple.
- Join two tuples into one.
- Check whether a given element exists in a tuple.
- Slice a tuple to get alternate elements.
- Remove an element from a tuple (using conversion).
- Create a tuple of squares from 1 to 10.
- Swap the contents of two tuples.
- Unpack a tuple of 5 elements into variables.
- Perform union, intersection, and difference of two sets.
- Remove duplicates from a list using a set.
- Check whether set A is a subset of set B.
- Get all unique words from a sentence.
- Find uncommon elements between two sets.
- Remove an item from a set without raising an error.
- Convert list → set → sorted list.
- Create a set of squares of numbers 1–10 using set comprehension.
- Find elements that are in either set A or set B but not both.
- Check if two sets are disjoint.
- Count the frequency of each character in a given string.
- Merge two dictionaries into one.
- Sort a dictionary by its keys.
- Sort a dictionary by its values.
- Find the key with the highest value.
- Convert two lists — one with keys, one with values — into a dictionary.
- Reverse keys and values in a dictionary.
- Check if a specific key exists in a dictionary.
- Remove a key from a dictionary safely.
- Create a dictionary storing squares from 1 to 10.
- Check whether a string is a palindrome.
- Remove all vowels from a string.
- Count the number of uppercase, lowercase, digits, and spaces.
- Find the longest word in a sentence.
- Reverse each word in a given sentence.
- Convert a snake_case string to camelCase.
- Count how many times each character appears.
- Remove all special characters from a string.
- Check if two strings are anagrams.
- Replace a substring in a string without using
replace().
- Find the sum of digits of a number.
- Generate the Fibonacci series up to N terms.
- Count how many prime numbers exist in a given range.
- Calculate the factorial of a number using a loop.
- Print a multiplication table for any number.
- Count numbers divisible by both 3 and 5 in a list.
- Reverse a number (e.g., 123 → 321).
- Check whether a number is Armstrong.
- Print numbers from 1 to 100 skipping multiples of 7.
- Print a simple star pyramid.
- Write a function with a default argument.
- Write a function that returns multiple values.
- Use lambda and
filter()to keep only odd numbers from a list. - Write a recursive function to find factorial.
- Write a function using
*argsto calculate the sum of all passed values. - Write a function using
**kwargsto print all key-value pairs. - Write a function that checks if a number is perfect.
- Write a function that counts vowels in a string.
- Write a function that validates a password (length > 8).
- Write a function that checks if a number is prime.
- Count lines, words, and characters in a text file.
- Copy the contents of one file into another file.
- Remove all blank lines from a file.
- Append a line of text to a file.
- Read a file and print the longest line.
- Replace a specific word in a file.
- Count how many times a particular word appears in a file.
- Write a list of numbers into a file.
- Convert all text in a file to uppercase.
- Read a CSV-like file and print the sum of numbers.
- Handle division by zero using try-except.
- Use try-except-finally to print a message.
- Create a custom exception for invalid age.
- Catch multiple exceptions in one block.
- Handle invalid integer input using
ValueError. - Raise a
TypeErrormanually. - Use
elseblock after try-except to print success message. - Handle
FileNotFoundError. - Write a function that raises exception when input < 0.
- Nested try-except example.
- Create a Student class that calculates and prints average marks.
- Create an Employee class with a class variable
company = "CTS". - Create a BankAccount class with private balance and deposit/withdraw methods.
- Create Vehicle → Car inheritance and override
start()method. - Use a static method to check if a number is even.
- Use a class method to count how many objects were created.
- Demonstrate encapsulation using getter and setter.
- Override
__str__()to print object information. - Create a Product class that updates price only if > 0.
- Demonstrate method overriding with simple parent-child classes.