# Python solved programs with Output and Explanation

This section contains **solved programs in Python** with Logic to implement, output and expiations.

## List of Python solved programs

**Python basic programs**

- Python | Printing different messages by using different variations of print() method.
- Python program to print given text using a user-defined method
- Python | Printing different values (integer, float, string, Boolean).
- Python | Declare different types of variables, print their values, types and Ids.
- Python program to demonstrate variables scope
- Determine the type of an object in Python
- Create number variables (int, float and complex) and print their types and values in Python
- Create integer variable by assigning binary value in Python
- Create integer variable by assigning octal value in Python
- Create integer variable by assigning hexadecimal value in Python
- Python | Typecasting Input to Integer, Float.
- Python | Program to define an integer value and print it.
- Python | Input two integers and find their addition.
- Python program to find sum of two numbers
- Python program to find addition of two numbers (4 different ways)
- Python program to print ASCII value of a character
- Python program for simple interest
- Python program for compound interest
- Simple pattern printing programs in Python
- Python program to check whether a given number is a Fibonacci number or not
- Python program to find power of a number using exponential operator
- Python program to find the power of a number using loop
- Python program to find the power of a number using recursion
- Python program to extract and print digits in reverse order of a number
- Python program to reverse a given number (2 different ways)
- Python program to find floor division
- Python | Some of the examples of simple if else.
- Python | Input age and check eligibility for voting.
- Python | Find largest of three number using nested if else.
- Python | Calculate discount based on the sale amount.
- Python | Calculate discount based on the sale amount using Nested if else.
- Python | Example of Ternary Operator
- Python | Design a simple calculator using if elif (just like switch case)
- Python | Demonstrate an example of for loop
- Python | Demonstrate an example of for each loop
- Python | Examples of loops (based on their control)
- Python | Some of the Examples of loops
- Python | Demonstrate an Example of break statement
- Python | Demonstrate an Example of continue statement
- Python | Demonstrate an Example of pass statement
- Python | Program to print numbers from N to 1 (use range() with reverse order).
- Python | Print all numbers between 1 to 1000 which are divisible by 7 and must not be divisible by 5.
- Python | Calculate square of a given number (3 different ways).
- Python | Find factorial of a given number (2 different ways).
- Python | Find the factorial of a number using recursion
- Python | Write functions to find square and cube of a given number.
- Python | Declare any variable without assigning any value.
- Python | BMI (Body Mass Index) calculator.
- Python | Program to print Odd and Even numbers from the list of integers.
- Python | Program to print Palindrome numbers from the given list.
- Python | Compute the net amount of a bank account based on the transactions.
- Python | Count total number of bits in a number.
- Python | Generate random number using numpy library.
- Generate random integers between 0 and 9 in Python
- Python | Program to calculate n-th term of a Fibonacci Series
- Python program to calculate prime numbers (using different algorithms) upto n
- Python program for not None test
- Python program for pass statement
- Python program to define an empty function using pass statement
- Python program for Zip, Zap and Zoom game
- Python program to convert temperature from Celsius to Fahrenheit and vice-versa
- Python program to find the number of required bits to represent a number in O(1) complexity
- Python program to count number of trailing zeros in Factorial of number N
- Python program for swapping the value of two integers
- Python program for swapping the value of two integers without third variable
- Python program to find winner of the day
- Python program for Tower of Hanoi
- Python program to find standard deviation
- Python program to find the variance
- Python program Tower of Hanoi (modified)
- Python program to convert Centimeter to Inches
- Python program to convert meters into yards
- Python program to convert yards into meters
- Python program to capitalize the character without using a function
- Python program to lowercase the character without using a function
- Python program to find perfect number
- Python program to print perfect numbers from the given list of integers
- Python program to design a dice throw function
- Python program to design a biased dice throw function
- Python program to design a biased coin flip function
- Python program to design a coin flip function
- Python program to find greatest integer using floor() method
- Python program to find the maximum EVEN number
- Python program to find the maximum ODD number
- Python program to find the solution of a special sum series
- Python | Convert the binary number to decimal without using library function
- Python | Convert the decimal number to binary without using library function
- Create a stopwatch using Python
- Python program to find the maximum multiple from given N numbers
- Python program to find the least multiple from given N numbers
- Find the root of the quadratic equation in Python
- Python program to check the given Date is valid or not
- Python program to print the calendar of any year
- Find all Prime numbers less than or equal to N using the Sieve of Eratosthenes algorithm in Python
- Find the sum of all prime numbers in Python
- Print the all uppercase and lowercase alphabets in Python
- Find the N-th number which is both square and a cube of a number in Python
- Program to find the execution time of a program in Python
- Program to find the x-intercept and y-intercept of a line passing through the given point in Python
- Find the day of the week for a given date in the past or future in Python
- Python program to find the GCD of the array
- Python program to find the LCM of the array elements
- Find the number of integers from 1 to n which contains digits 0's in Python
- Check whether a number is a power of another number or not in Python
- Check whether the binary representation of a given number is a palindrome or not in Python
- Draw a pie chart that shows our daily activity in Python

**Python array programs**

- Python program to find the sum of all elements of an array
- Python program to find a series in an array consisting of characters
- Python program to find the occurrence of a particular number in an array
- Find the union and intersection of two arrays in Python

**Python programs on int class**

- Python program to find number of bits necessary to represent an integer in binary
- Python program to print number of bits to store an integer and also print number in Binary format
- Python program to print an array of bytes representing an integer
- Python program to print the binary value of the numbers from 1 to N

**Stack**

**Lists**

- Python | Program to declare and print a list.
- Python program to print list elements in different ways.
- Python | Program for Adding, removing elements in the list.
- Python | Program to print a list using ‘FOR and IN’ loop.
- Python | Program to add an element at specified index in a list.
- Python | Program to remove first occurrence of a given element in the list.
- Python | Remove all occurrences a given element from the list.
- Python | Program to remove all elements in a range from the List.
- Python | Program to sort the elements of given list in Ascending and Descending Order.
- Python | Program to find the differences of two lists.
- Python | Program to Print the index of first matched element of a list.
- Python | Program to find the position of minimum and maximum elements of a list.
- Python | Program to input, append and print the list elements.
- Python | Program to remove duplicate elements from the list.
- Python | Program to Create two lists with EVEN numbers and ODD numbers from a list.
- Python | Program to print all numbers which are divisible by M and N in the List.
- Python | Create a list from the specified start to end index of another list.
- Python | Create three lists of numbers, their squares and cubes.
- Python | Create two lists with first half and second half elements of a list.
- Python | Iterate a list in reverse order.
- Python | print list after removing EVEN numbers.
- Python | print list after removing ODD numbers.
- Python | Input comma separated elements, convert into list and print.
- Python | Convert a string to integers list.
- Using List as Stack in Python.
- Python | Extend a list using + Operator.
- Python program to find N largest and smallest elements from the list
- Python program for various list operations
- Find the index of an item given a list containing it in Python
- Extract Even and odd number from a given list in Python

**Python string programs**

- Python | Declare, assign and print the string (Different ways).
- Python | Access and print characters from the string.
- Python program to print a string, extract characters from the string.
- Python | Program to print words with their length of a string.
- Python | Print EVEN length words.
- Python | Count vowels in a string.
- Python | Passing string value to the function.
- Python | Create multiple copies of a string by using multiplication operator.
- Python | Appending text at the end of the string using += Operator.
- Python | Concatenate two strings and assign in another string by using + operator.
- Python | Check if a substring presents in a string using 'in' operator
- Python | Assign Hexadecimal values in the string and print it in the string format
- Python | How to print double quotes with the string variable?
- Python | Ignoring escape sequences in the string
- Python program to calculate the number of all possible substrings of a string
- Python program to reverse a given string (5 different ways)
- Python program to reverse a string using stack and reversed method
- Split a string into array of characters in Python
- Python program for slicing a string
- Python program to repeat M characters of a string N times
- Python program to swap characters of a given string
- Python program to remove a character from a specified index in a string
- Python program for adding given string with a fixed message
- Find all permutations of a given string in Python
- Python | Write a function to find sum of two integral numbers in string format.
- Python program to check whether a string contains a number or not
- Python program to find the matched characters in a given string
- Python | Find the frequency of each character in a string
- Extract the mobile number from the given string in Python
- Replace a special string from a given paragraph with another string in Python

**Python dictionary programs**

**Python Class and Object programs**

- Python example to define a class
- Python | Demonstrate an example of Class and Object
- Python | Simple program of a class (Input and print a number)
- Public variables in Python
- Python | Create Employee class with some attributes and methods
- Python program to calculate student grade
- Python | Example to implement destructor and constructors using __del__() and __init__()
- Python | Example to implement Getters and Setters in a class
- Python | Implementing setters and getters with the help of properties
- Python | Implement Abstraction using Abstract class
- Python | Implement Interface using class
- Python | Create Employee Class
- Python | Create Employee Class with Constructor and Destructor
- Example of single inheritance in Python
- Example of inheritance with two child (derived) classes in Python
- Example of multiple inheritance in Python
- Example of multilevel inheritance in Python
- Example of hierarchical inheritance in Python
- Python program to check prime number using object oriented approach
- Python program to count number of objects created
- Python program to check Armstrong number using object oriented approach
- Python program to check Palindrome number using object oriented approach

**Python Regex programs**

**Searching programs**

**Python game programs**

- Python program for rolling the dice (2-player dice game)
- Snakes and ladder (Single player) in Python

**Misc.**

- Design Traditional and Magic Calculator in Python3
- Python | Create a line plot using matplotlib.pyplot
- Python | Create a bar chart using matplotlib.pyplot
- Python | Create a bar graph with using matplotlib.pyplot
- Python | Create a stacked bar using matplotlib.pyplot
- Python | Create a scatter plot using matplotlib.pyplot
- Python | Create pie-chat using matplotlib.pyplot
- Python | Create stack plot using matplotlib.pyplot
- Python program for plotting in same and different graph
- Histogram using Pylab in Python
- Python program for single dice simulation
- Python program for single biased dice simulation
- Python program for biased coin flipping simulation
- Python program for double biased dice simulation
- Python program for double dice (one biased one normal) simulation

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.