This repository contains a collection of Python programs demonstrating various concepts and solutions. Below is a list of the included programs with links to their respective files:
-
Add Two Numbers: A program to compute the sum of two user-provided numbers.
-
Calculate Square Root: A program to compute the square root of a user-provided number using both manual and library methods.
-
Check Leap Year: A program to determine if a given year is a leap year.
-
Check Prime Number: A program to check if a given number is prime.
-
Quiz Game: A simple quiz game that asks the user a question and evaluates their response.
-
Swap Two Variables: A program to demonstrate two methods for swapping the values of two variables.
-
Two Sum [LeetCode]: A solution to the LeetCode "Two Sum" problem, which returns the indices of two numbers that add up to a target value.
-
Factorial Calculation: Program to calculate the factorial of a number using recursion.
-
Fibonacci Sequence: Program to generate the Fibonacci sequence up to a given number of terms.
-
Palindrome Check: Program to check if a string is a palindrome.
-
Count Vowels in a String: Program to count the number of vowels in a given string.
-
Reverse a String: Program to reverse the characters of a given string.
-
Sum of Digits in a Number: Program to calculate the sum of digits in a number.
-
Check Armstrong Number: Program to check if a number is an Armstrong number.
-
Binary to Decimal Conversion: Program to convert a binary number into its decimal equivalent.
-
Decimal to Binary Conversion: Program to convert a decimal number to binary.
-
GCD of Two Numbers: Program to calculate the greatest common divisor of two numbers.
-
LCM of Two Numbers: Program to calculate the least common multiple of two numbers.
-
Find the Largest Element in a List: Program to find the largest element in a given list.
-
Find the Smallest Element in a List: Program to find the smallest element in a given list.
-
Find the Sum of Elements in a List: Program to calculate the sum of all elements in a list.
-
Count Occurrences of a Character in a String: Program to count how many times a character appears in a string.
-
Find the Length of a List: Program to find the number of elements in a list.
-
Merge Two Lists: Program to merge two lists into one.
-
Find the Second Largest Element in a List: Program to find the second largest element in a list.
-
Check if a String is a Substring: Program to check if one string is a substring of another.
-
Transpose a Matrix: Program to transpose a given matrix (swap rows and columns).
-
Matrix Addition: Program to add two matrices element-wise.
-
Matrix Multiplication: Program to multiply two matrices.
-
Find the Determinant of a Matrix: Program to compute the determinant of a square matrix.
-
Find the Trace of a Matrix: Program to calculate the sum of the elements on the main diagonal of a matrix.
-
Linear Search: Program to implement linear search to find an element in a list.
-
Binary Search: Program to implement binary search to find an element in a sorted list.
-
Bubble Sort: Program to implement the bubble sort algorithm.
-
Insertion Sort: Program to implement the insertion sort algorithm.
-
Selection Sort: Program to implement the selection sort algorithm.
-
Quick Sort: Program to implement the quick sort algorithm.
-
Merge Sort: Program to implement the merge sort algorithm.
-
Check if a Number is Even or Odd: Program to check whether a number is even or odd.
-
Find Factorial Using Iteration: Program to find the factorial of a number using loops (non-recursive method).
-
Sum of Natural Numbers: Program to calculate the sum of the first N natural numbers.
-
Find the Power of a Number: Program to compute the power of a number (using
pow
or custom function). -
Check if a String is an Anagram: Program to check if two strings are anagrams of each other.
-
Check Perfect Number: Program to check whether a given number is a perfect number (equal to the sum of its divisors).
-
Generate Random Numbers: Program to generate random numbers within a specified range using the
random
module. -
Generate Fibonacci Series Using Recursion: Program to generate Fibonacci numbers using recursive function calls.
-
Check if a Number is a Palindrome: Program to check if a number reads the same forwards and backwards.
-
Remove Duplicates from a List: Program to remove duplicate elements from a list.
-
Find the Intersection of Two Lists: Program to find the common elements between two lists.
-
Find the Union of Two Lists: Program to merge two lists, removing duplicates.
-
Find the Sum of the Digits in a String: Program to extract digits from a string and calculate their sum.
-
Check if Two Strings are Rotations of Each Other: Program to check whether one string is a rotation of another string.
-
Find the Maximum and Minimum of a List Without Using Built-In Functions: Program to find the max and min values in a list without using built-in functions like
max()
ormin()
. -
Flatten a Nested List: Program to flatten a list that contains sublists into a single-level list.
-
Find the Most Frequent Element in a List: Program to find the element that appears the most times in a list.
-
Check if a List is Sorted: Program to determine whether a list is already sorted.
-
Find the Median of a List: Program to calculate the median value of a list of numbers.
-
Check if a List Contains All Unique Elements: Program to check if all elements in a list are unique.
-
Generate a Random Password: Program to generate a random password with a specified length using letters, numbers, and special characters.
-
Caesar Cipher Encryption: Program to encrypt a message using Caesar cipher.
-
Caesar Cipher Decryption: Program to decrypt a message encoded with Caesar cipher.
-
Check for Pangram: Program to check if a string contains all letters of the alphabet.
-
Count the Number of Words in a String: Program to count the number of words in a given string.
-
Find the Longest Word in a String: Program to find the longest word in a given string.
-
Find the Shortest Word in a String: Program to find the shortest word in a given string.
-
Count the Number of Sentences in a String: Program to count the number of sentences in a paragraph.
-
Find the Mode of a List: Program to find the mode (most frequent value) in a list.
-
Check if a Number is a Perfect Square: Program to determine if a number is a perfect square.
-
Solve Quadratic Equation: Program to solve a quadratic equation given its coefficients.
-
Check if a Number is a Strong Number: Program to check if a number is a "strong" number (sum of factorials of digits equals the original number).
[75 - 100 ] problems focusing on Object-Oriented Programming (OOP) concepts:
- Create a Class for a Circle: Define a class
Circle
with attributes for radius and methods to calculate area and circumference. - Create a Class for a Rectangle: Define a class
Rectangle
with attributes for length and width, and methods to calculate area and perimeter. - Bank Account Class: Define a class
BankAccount
with methods for deposit, withdrawal, and balance inquiry. - Class Inheritance Example: Create a base class
Person
and a derived classEmployee
with additional attributes for job title and salary. - Car Class with Encapsulation: Implement a
Car
class with private attributes for make, model, and year. Provide methods to access and modify these attributes. - Class for Managing Student Grades: Define a class
Student
with attributes for name and grades, and methods to calculate the average grade and determine pass/fail status. - Polymorphism Example: Create a class
Shape
with a methodarea()
, and derived classesSquare
andCircle
that override this method to calculate the area based on their properties. - Overloading Operators in a Fraction Class: Create a class
Fraction
and overload the addition, subtraction, multiplication, and division operators for fraction objects. - Implement a Stack Using a Class: Define a class
Stack
with methods to push, pop, and display elements in a stack. - Class for Book Management: Create a
Book
class with attributes for title, author, and genre, and methods for lending and returning books. - Class for Complex Numbers: Define a class
ComplexNumber
with methods to add, subtract, and multiply complex numbers. - Abstract Class Example: Create an abstract class
Animal
with an abstract methodsound()
, and derived classesDog
andCat
implementing the method. - Class for Managing Library Inventory: Create a
Library
class with methods to add, remove, and display books in a collection. - Multilevel Inheritance Example: Implement classes
Vehicle
,Car
, andElectricCar
to demonstrate multilevel inheritance. - Multiple Inheritance Example: Create two classes
Teacher
andAuthor
, and a third classPerson
that inherits from both, with a method to show combined information. - Create a Class for a Queue: Define a class
Queue
with methods to enqueue, dequeue, and display elements in a queue. - Singleton Pattern Example: Implement a singleton pattern for a class
DatabaseConnection
to ensure only one instance is created. - Class for Handling Employee Data: Create an
Employee
class with methods to calculate salary, tax, and bonuses based on job role and experience. - File Management Using a Class: Create a class
FileManager
to handle file operations like reading, writing, and appending to files. - Method Overriding Example: Create a base class
Appliance
with a methodstart()
, and override this method in the derived classesWashingMachine
andRefrigerator
. - Class for Managing a To-Do List: Implement a
ToDoList
class with methods to add, remove, and display tasks. - Create a Class for a Shopping Cart: Define a class
ShoppingCart
with methods to add items, remove items, and calculate the total price. - Class for Handling Date and Time: Implement a class
DateTimeManager
with methods to display current date/time, calculate time difference, and format date. - Create a Class for a Game Character: Define a class
GameCharacter
with attributes like health, attack power, and defense, and methods for attacking and defending. - Class for a Calculator: Create a
Calculator
class with methods for basic arithmetic operations (addition, subtraction, multiplication, and division).