PYTHON
Python Practical Questions
🔹 Basic Python
- Print "Hello, World!" in Python.
- Add two numbers using Python.
- Swap two variables.
- Check if a number is even or odd.
- Check if a number is prime.
- Find the largest of three numbers.
- Calculate the factorial of a number.
- Print Fibonacci series up to n terms.
- Find the sum of all digits in a number.
- Check if a string is a palindrome.
- Count occurrences of a character in a string.
- Reverse a string without using slicing.
- Convert Celsius to Fahrenheit.
- Find the square root of a number.
- Check whether a given number is an Armstrong number.
🔹 If-Else Based Questions (Intermediate to Advanced)
- Check if a number is prime or composite.
- Determine whether a string is an anagram of another string.
- Implement a program to validate a password based on complexity rules.
- Check if a given year is a leap year.
- Write a program to categorize a person's BMI.
- Determine whether a number is a palindrome.
- Classify a triangle based on its sides.
- Check whether a character is an uppercase letter, lowercase letter, digit, or special symbol.
- Implement a grading system based on marks.
- Develop a simple login system with username and password validation.
- Check if a number is an Armstrong number.
- Write a program to classify age groups (child, teen, adult, senior).
- Check if a given number is a perfect square.
- Determine the type of day (weekday or weekend) based on user input.
- Develop a program to check voting eligibility.
- Implement a traffic light simulation using if-else statements.
- Simulate an ATM withdrawal system with balance validation.
- Check if a number is divisible by both 3 and 7.
- Determine if a string is a valid email format.
- Write a program to determine whether a given time falls in AM or PM.
- Develop a medical diagnosis system based on symptom input.
- Check if a given username follows length and character constraints.
- Write a program to validate a credit card number.
- Determine the quadrant of a given coordinate point.
- Check if a given number is a Fibonacci number.
- Simulate a movie ticket booking system with age-based discounts.
- Determine if a number is part of a geometric series.
- Write a program to classify a letter grade based on a numerical score.
- Simulate an online shopping cart with discount rules.
- Check if two numbers are co-prime.
- Determine if a given number is an abundant number.
- Develop a loan eligibility checker based on income and credit score.
- Write a program to determine the winner in a rock-paper-scissors game.
- Check if a word contains all vowels at least once.
- Determine the shipping cost based on weight and distance.
- Implement a student attendance tracker and classify them as regular or irregular.
- Write a program to determine salary increments based on performance rating.
- Check if a given mobile number follows a valid format.
- Simulate a temperature converter with unit validation.
- Write a program to validate a strong password (length, uppercase, lowercase, digits, special characters).
- Determine the tax slab based on income.
- Check if a date falls on a public holiday.
- Develop a system to classify books based on genre and author.
- Implement an email spam filter based on keyword detection.
- Check if a vehicle's registration number follows standard rules.
- Write a program to determine the most frequent character in a string.
- Simulate a bank account transaction with deposit and withdrawal conditions.
- Determine whether a given list is sorted in ascending or descending order.
- Write a program to check if an IP address follows valid format rules.
🔹 Lists & Tuples
- Find the largest number in a list.
- Find the second largest number in a list.
- Count occurrences of an element in a list.
- Find the sum of all elements in a list.
- Remove duplicates from a list.
- Check if a list is sorted in ascending order.
- Merge two lists and sort them.
- Find the common elements in two lists.
- Remove all even numbers from a list.
- Find the length of a tuple.
- Find the maximum and minimum elements in a tuple.
- Reverse a tuple.
- Convert a tuple into a list.
- Create a nested tuple and access elements from it.
- Count the occurrences of an element in a tuple.
🔹 List-Based Questions
- Create a list of integers and find the sum of all its elements.
- Find the largest and smallest numbers in a list.
- Reverse a given list without using the
reverse()
method.
- Count the occurrences of a specific element in a list.
- Find the second largest number in a list.
- Remove duplicates from a list without using a set.
- Merge two lists into one without using built-in functions.
- Create a list comprehension that generates all even numbers between 1 and 100.
- Sort a list of strings in alphabetical order.
- Find the common elements between two lists.
- Remove all occurrences of a specific element from a list.
- Rotate a list by n positions.
- Convert a list of strings into a single string, separated by commas.
- Check if a list is a palindrome.
- Flatten a nested list (e.g., [[1, 2], [3, 4]] → [1, 2, 3, 4]).
- Find the difference between the largest and smallest elements in a list.
- Find all subsets of a list.
- Create a list of the first n Fibonacci numbers.
- Filter all prime numbers from a list.
- Split a list into chunks of size n.
🔹 Dictionaries & Sets
- Create a dictionary and print its keys and values.
- Update a dictionary with another dictionary.
- Remove a key from a dictionary.
- Check if a key exists in a dictionary.
- Find the maximum and minimum value in a dictionary.
- Find the sum of all values in a dictionary.
- Merge two dictionaries.
- Create a set and perform union and intersection operations.
- Remove an element from a set.
- Check if a set is a subset of another set.
🔹 Dictionary-Based Questions
- Create a dictionary from two lists: one for keys and one for values.
- Merge two dictionaries into one.
- Count the frequency of characters in a string using a dictionary.
- Find the key with the maximum value in a dictionary.
- Check if a specific key exists in a dictionary.
- Invert a dictionary (keys become values and vice versa).
- Remove a key-value pair from a dictionary by key.
- Sort a dictionary by its keys.
- Sort a dictionary by its values.
- Create a nested dictionary to store student data (name, age, grade).
- Update the value of a specific key in a dictionary.
- Combine two dictionaries, adding values for common keys.
- Create a dictionary of squares for numbers from 1 to 10.
- Remove duplicates from a dictionary.
- Access and modify a value in a nested dictionary.
- Check if two dictionaries are identical.
- Convert a dictionary into two lists: one for keys and one for values.
- Create a dictionary comprehension to map numbers to their cubes.
- Find the sum of all values in a dictionary.
- Delete keys with a specific value from a dictionary.
🔹 Loops & Functions
- Write a function to calculate the sum of numbers from 1 to n.
- Write a function to find the factorial of a number.
- Write a function to check if a number is even or odd.
- Write a function to count the number of vowels in a string.
- Write a function to find the greatest common divisor (GCD) of two numbers.
- Write a function to find the least common multiple (LCM) of two numbers.
- Write a function to calculate the power of a number without using **.
- Write a function to check if a number is a perfect square.
- Write a function to check if a number is a perfect cube.
- Generate a multiplication table of a number using loops.
- Print the reverse of a number using loops.
- Print all prime numbers in a given range using loops.
- Calculate the sum of digits of a number using loops.
- Find the sum of even numbers between 1 and n using loops.
- Find the product of all odd numbers between 1 and n using loops.
0 Comments