Python solved programs with output and explanation

Python is a general-purpose, high-level, simple but effective object-oriented programming approach based, and an interpreted programming language. It’s very easy to learn (due to emphasized code readability) and powerful programming language.

This is the best way to learn Python programming by practicing the Python programs. This section contains Python solved programs on various topics such as basic programs, conditional & control statement-based programs, arrays programs, matrices programs, string programs, lists programs, dictionaries, file handling, data structure programs, etc.

Python basic programs

  1. How to print spaces in Python?
  2. Python | Printing different messages by using different variations of print() method.
  3. Python program to print given text using a user-defined method
  4. Python | Printing different values (integer, float, string, Boolean).
  5. Python | Declare different types of variables, print their values, types and Ids.
  6. Python program to demonstrate variables scope
  7. Determine the type of an object in Python
  8. Create number variables (int, float and complex) and print their types and values in Python
  9. Create integer variable by assigning binary value in Python
  10. Create integer variable by assigning octal value in Python
  11. Create integer variable by assigning hexadecimal value in Python
  12. Python | Typecasting Input to Integer, Float.
  13. How to check multiple variables against a value in Python?
  14. Python | Program to define an integer value and print it.
  15. Python | Input two integers and find their addition.
  16. Python program to find sum of two numbers
  17. Python program to find addition of two numbers (4 different ways)
  18. Python Arithmetic Operators Example
  19. Python program to print ASCII value of a character
  20. Python program for simple interest
  21. Python program for compound interest
  22. Python program to check the given year is a leap year or not
  23. Simple pattern printing programs in Python
  24. Create a function to check EVEN or ODD in Python
  25. Create a function to return the absolute the given value in Python
  26. Python program to check whether a given number is a Fibonacci number or not
  27. Python program to find power of a number using exponential operator
  28. Python program to find the power of a number using loop
  29. Python program to find the power of a number using recursion
  30. Python program to extract and print digits in reverse order of a number
  31. Python program to reverse a given number (2 different ways)
  32. Python program to find floor division
  33. Python | Some of the examples of simple if else.
  34. Python | Input age and check eligibility for voting.
  35. Python | Find largest of three number using nested if else.
  36. Python | Calculate discount based on the sale amount.
  37. Python | Calculate discount based on the sale amount using Nested if else.
  38. Python | Example of Ternary Operator
  39. Python | Design a simple calculator using if elif (just like switch case)
  40. Python | Demonstrate an example of for loop
  41. Python | Demonstrate an example of for each loop
  42. Python | Examples of loops (based on their control)
  43. Python | Some of the Examples of loops
  44. Python | Demonstrate an Example of break statement
  45. Python | Demonstrate an Example of continue statement
  46. Python | Demonstrate an Example of pass statement
  47. Python | Program to print numbers from N to 1 (use range() with reverse order).
  48. Python | Print all numbers between 1 to 1000 which are divisible by 7 and must not be divisible by 5.
  49. Python | Calculate square of a given number (3 different ways).
  50. Python | Find factorial of a given number (2 different ways).
  51. Python | Find the factorial of a number using recursion
  52. Python | Write functions to find square and cube of a given number.
  53. Python | Declare any variable without assigning any value.
  54. Python | BMI (Body Mass Index) calculator.
  55. Python | Program to print Odd and Even numbers from the list of integers.
  56. Python | Program to print Palindrome numbers from the given list.
  57. Python | Compute the net amount of a bank account based on the transactions.
  58. Python | Count total number of bits in a number.
  59. Python | Generate random number using numpy library.
  60. Generate random integers between 0 and 9 in Python
  61. Python | Program to calculate n-th term of a Fibonacci Series
  62. Python program to check prime number
  63. Python program to calculate prime numbers (using different algorithms) upto n
  64. Python program for not None test
  65. Python program for pass statement
  66. Python program to define an empty function using pass statement
  67. Python program for Zip, Zap and Zoom game
  68. Python program to convert temperature from Celsius to Fahrenheit and vice-versa
  69. Python program to find the number of required bits to represent a number in O(1) complexity
  70. Python program to count number of trailing zeros in Factorial of number N
  71. Python program for swapping the value of two integers
  72. Python program for swapping the value of two integers without third variable
  73. Python program to find winner of the day
  74. Python program for Tower of Hanoi
  75. Python program to find standard deviation
  76. Python program to find the variance
  77. Python program Tower of Hanoi (modified)
  78. Python program to convert Centimeter to Inches
  79. Python program to convert meters into yards
  80. Python program to convert yards into meters
  81. Python program to capitalize the character without using a function
  82. Python program to lowercase the character without using a function
  83. Python program to find perfect number
  84. Python program to print perfect numbers from the given list of integers
  85. Python program to design a dice throw function
  86. Python program to design a biased dice throw function
  87. Python program to design a biased coin flip function
  88. Python program to design a coin flip function
  89. Python program to find greatest integer using floor() method
  90. Python program to find the maximum EVEN number
  91. Python program to find the maximum ODD number
  92. Python program to find the solution of a special sum series
  93. Python | Convert the binary number to decimal without using library function
  94. Python | Convert the decimal number to binary without using library function
  95. Create a stopwatch using Python
  96. Python program to find the maximum multiple from given N numbers
  97. Python program to find the least multiple from given N numbers
  98. Find the root of the quadratic equation in Python
  99. Python program to check the given Date is valid or not
  100. Python program to print the calendar of any year
  101. Find all Prime numbers less than or equal to N using the Sieve of Eratosthenes algorithm in Python
  102. Find the sum of all prime numbers in Python
  103. Print the all uppercase and lowercase alphabets in Python
  104. Find the N-th number which is both square and a cube of a number in Python
  105. Program to find the execution time of a program in Python
  106. Program to find the x-intercept and y-intercept of a line passing through the given point in Python
  107. Find the day of the week for a given date in the past or future in Python
  108. Find the number of integers from 1 to n which contains digits 0's in Python
  109. Check whether a number is a power of another number or not in Python
  110. Check whether the binary representation of a given number is a palindrome or not in Python
  111. Draw a pie chart that shows our daily activity in Python
  112. Find the sum of all numbers below 1000 which are multiples of 3 or 5 in Python
  113. Python | How can I force division to be floating point? Division keeps rounding down to 0?
  114. Python program to print the list of all keywords
  115. Python program to print the version information
  116. Python program to find sum of all digits of a number
  117. Print number with commas as thousands separators in Python
  118. Python program to print table of number entered by user
  119. Python program to calculate currency notes required to get the amount
  120. Python program to calculate discount based on selling price
  121. Python program to calculate gross pay (Hourly paid employee)
  122. Python program to get employee details and search for record by ID, surName or Designation
  123. Python program for Basic Shop Management System
  124. More ...

Python array programs

  1. Python program to find the sum of all elements of an array
  2. Python program to find a series in an array consisting of characters
  3. Python program to find the occurrence of a particular number in an array
  4. Find the union and intersection of two arrays in Python
  5. Python program to create matrix in Python
  6. More ...

Python string programs

  1. Python | Declare, assign and print the string (Different ways).
  2. Python | Access and print characters from the string.
  3. Python program to print a string, extract characters from the string.
  4. Python | Program to print words with their length of a string.
  5. Python | Print EVEN length words.
  6. More ...

Python Class and Object programs

  1. Python example to define a class
  2. Python | Demonstrate an example of Class and Object
  3. Python | Simple program of a class (Input and print a number)
  4. Public variables in Python
  5. Python | Create Employee class with some attributes and methods
  6. More ...

File handling programs

  1. Append content to a file in Python
  2. Read contents of the file using readline() method in Python
  3. Read contents of a file using readline() method and manipulating it in Python
  4. Copy odd lines of one file to another file in Python
  5. Setting file offsets in Python
  6. More ...

Python Data Structures Programs

  1. Python program for Bubble Sort
  2. Python program for Insertion Sort
  3. Python program for Selection Sort
  4. Python program for Linear Search
  5. Breadth First Search for a Graph in Python
  6. More ...

Python exception handling programs

  1. Python exception handling program (Handling divide by zero exception)
  2. Python exception handling program (Handling Type exception)
  3. Python program to illustrate importing exception from another file
  4. Python program to illustrate the import exception defined in another file and defining a new one
  5. More ...

Python database (SQL/MySQL) programs

  1. Python program to create an SQL table
  2. Python program to display SQL table content
  3. Insertion of Records to Database in Python
  4. Fetch employee details from the database whose salary lies within a certain range in Python
  5. Delete a Record from the Database in Python
  6. More ...

Python Threading Programs

  1. Python program to illustrate naming of threads
  2. Python Program to illustrate parameterized threads
  3. Python program to illustrate multithreading
  4. Python program to create and delete threads using sleep method
  5. Python program for multithreading with class
  6. More ...

Python List Programs

  1. Python | Program to declare and print a list.
  2. Python program to print list elements in different ways.
  3. Python | Program for Adding, removing elements in the list.
  4. Python | Program to print a list using ‘FOR and IN’ loop.
  5. Python | Program to add an element at specified index in a list.
  6. Python | Program to remove first occurrence of a given element in the list.
  7. Python | Remove all occurrences a given element from the list.
  8. Python | Program to remove all elements in a range from the List.
  9. Python | Program to sort the elements of given list in Ascending and Descending Order.
  10. Python | Program to find the differences of two lists.
  11. More Python List Programs ...

Python Dictionary Programs

  1. Python program to create an empty dictionary
  2. Python program to create a dictionary using dict() function
  3. Python program to create a dictionary from a sequence
  4. Python program to create a dictionary with integer keys, and print the keys, values & key-value pairs
  5. Python program to create a dictionary with mixed keys, and print the keys, values & key-value pairs
  6. Python | Generate dictionary of numbers and their squares (i, i*i) from 1 to N
  7. Python program to search student record stored using Dictionary
  8. Python program for accessing elements from a dictionary
  9. Python program for adding elements to a dictionary
  10. How to compare two dictionaries in Python?
  11. More Python Dictionary Programs ....

Python Tuple Programs

  1. Python program to find the size of a tuple
  2. Python program for adding a Tuple to List and Vice-Versa
  3. Python program to find the maximum and minimum K elements in a tuple
  4. Python program to create a list of tuples from given list having number and its cube in each tuple
  5. Python program to remove all tuples of length K
  6. More Python Tuple Programs ...

Python Regular Expression Programs

  1. Python Regex | program to Remove leading zeros from an IP address
  2. Python program to understand difference between match() and search() methods
  3. Python program to check the presence of substring in given string - Regex Example
  4. Python program to check whether a regular expression is present in string or not
  5. Python program to extract phone number from string using sub() method
  6. More...

Python Lambda Function Programs

  1. Python program to filter even values from list using lambda function
  2. Python program to find the sum of elements of a list using lambda function
  3. Map() Function and Lambda Expression in Python to Replace Characters
  4. Intersection of two arrays using Lambda expression and filter() function in Python
  5. Find small number between two numbers using Lambda function in Python
  6. More Python Lambda Function Programs ...

Python Pandas Programs

  1. Python Pandas | How to create a MultiIndex with names of each of the index levels?
  2. Python Pandas | How to get the levels in MultiIndex?
  3. Python Pandas | How to get the name of levels in MultiIndex?
  4. Python Pandas | Set levels on a MultiIndex
  5. Python Pandas | Swap levels of a MultiIndex
  6. Python Pandas | Rearrange levels using level name in MultiIndex
  7. More Python Pandas Programs ...

Python NumPy Programs

  1. Convert pandas dataframe to NumPy array
  2. What does -1 mean in numpy reshape?
  3. How can the Euclidean distance be calculated with NumPy?
  4. Convert a NumPy array into a CSV file
  5. More Python NumPy Programs ...

Python Date & Time Programs

  1. Python program to get current date
  2. Python program to get current time
  3. Python program to print today's year, month and day
  4. Python program to print current hour, minute, second and microsecond
  5. Python program to print all timezones using pytz module

Python game programs

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

Python miscellaneous programs

  1. Python program to find number of bits necessary to represent an integer in binary
  2. Python program to print number of bits to store an integer and also print number in Binary format
  3. Python program to print an array of bytes representing an integer
  4. Python program to print the binary value of the numbers from 1 to N
  5. Design Traditional and Magic Calculator in Python3
  6. Python | Create a line plot using matplotlib.pyplot
  7. Python | Create a bar chart using matplotlib.pyplot
  8. Python | Create a bar graph with using matplotlib.pyplot
  9. Python | Create a stacked bar using matplotlib.pyplot
  10. Python | Create a scatter plot using matplotlib.pyplot
  11. Python | Create pie-chat using matplotlib.pyplot
  12. Python | Create stack plot using matplotlib.pyplot
  13. Python program for plotting in same and different graph
  14. Histogram using Pylab in Python
  15. Python program for single dice simulation
  16. Python program for single biased dice simulation
  17. Python program for biased coin flipping simulation
  18. Python program for double biased dice simulation
  19. Python program for double dice (one biased one normal) simulation
  20. Python program to generate the QR code in Python
  21. Greedy algorithm for a knapsack problem with the example of Robbery in Python
  22. Corona Virus Live Updates for India (District Wise) – Using Python
  23. English dictionary application using Python
  24. Emotional and Sentiment Analysis with the help of Python
  25. Control Mouse in Python
  26. Edge Detection of Image using OpenCV (CV2) in Python
  27. Cropping an Image using OpenCV in Python
  28. Converting an OpenCV Image to Black and White in Python
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.