Python Programming Examples

Python Programs : This page contains Python programming examples that cover the concepts, including basic and simple python programs, number programs, string programs, List Programs, series programs, etc. Apart from them, we also included the numpy array and matrix programs, area programs, and the pattern programs.

All these Python programs are explained with multiple examples, and we also did the code analysis. Please visit the python tutorial to learn python programming language with practical examples.

Basic Python Programs

This programs section covers the basic programs and simple python programming examples.

  1. Python program for Hello World
  2. Python program to add Two Numbers
  3. Python program to subtract two numbers
  4. Python Program to Multiply Two numbers
  5. Python program for Arithmetic Operations
  6. Python program to print Calendar
  7. Python program to find Cube of a Number
  8. Python program to find Largest of 2 Numbers
  9. Python program to find Largest of 3 Numbers
  10. Python program to Print Natural number 1 to N
  11. Python program for Leap Year
  12. Python program to find Odd or Even
  13. Python program to print Even Numbers from 1 to 100
  14. Python program to print Odd Numbers from 1 to 100
  15. Python Program to Print Negative Numbers in a Range
  16. Python Program to Print Positive Numbers in a Range
  17. Python program to find Positive or Negative
  18. Python program to find Profit Or Loss
  19. Python program to find Square of a Number
  20. Python program to find Square root of a Number
  21. Python Program to find all divisors of an integer
  22. Python Program to find Compound Interest
  23. Python program to check Number Divisible by 5 and 11
  24. Python program to find Power of a Number
  25. Python program for Multiplication Table
  26. Python example to find Roots of a Quadratic Equation
  27. Python example to find Student Grade
  28. Python example to find Simple Interest
  29. Python Program to Read 10 Numbers and Find their Sum and Average
  30. Python Program to Print First 10 Even Natural Numbers
  31. Python Program to Print First 10 Natural Numbers
  32. Python Program to Print First 10 Natural Numbers in Reverse
  33. Python Program to Print First 10 Odd Natural Numbers
  34. Python program to Print Natural number 1 to N
  35. Python program to print Natural Numbers in Reverse Order
  36. Python Program to Find the Sum and Average Of Three Numbers
  37. Python Program to Find the Average Of Two Numbers
  38. Python example to find Sum and Average of Natural Numbers
  39. Python Program to Find Sum of 10 Numbers and Skip Negative Numbers
  40. Python Program to Find Sum of 10 Numbers until user enters Positive Numbers
  41. Python example to Calculate Electricity Bill
  42. Python Program to Find Distance Between Two Points
  43. Python program to find Total Average & Percentage of 5 Subjects
  44. Python Program to Get Current Date and Time
  45. Python Program to Make a Simple Calculator

Python Sum Programs

The following Python programs will accept the user inputs and find the Sum

  1. Python Program to find Sum of Natural Numbers
  2. Python Program to find Sum of Even Numbers
  3. Python example to find Sum and Average of Natural Numbers
  4. Python example to find Sum of Odd Numbers
  5. Python example to find sum of Even and Odd Numbers

Advanced Python Number Programs

The following python programming examples are helpful to work with Numbers

  1. Python Program to do Arithmetic Calculations using Functions
  2. Python Program to Count Number of Digits in a Number
  3. Python Program to Print Fibonacci Series
  4. Python example to find Factors of a Number
  5. Python example to find Factorial of a Number
  6. Python program to print First Digit of a Number
  7. Python program to print Last Digit in a Number
  8. Python program to find GCD of Two Numbers
  9. Python program to find LCM of Two Numbers
  10. Python Program to Check Armstrong Number
  11. Python Program to Check Disarium Number
  12. Python Program to Print Disarium Numbers from 1 to 100
  13. Python Program to Check Happy Number
  14. Python Program to Print Happy Numbers from 1 to 100
  15. Python Program to Check Harshad Number
  16. Python Program to Print Harshad Numbers from 1 to 100
  17. Python Program to Check Krishnamurthy Number
  18. Python Program to Check Neon Number
  19. Python program to check Palindrome Number
  20. Python program to check Perfect Number
  21. Python program to check Prime Number
  22. Python program to print Prime Numbers from 1 to 100
  23. Python Program to Check Pronic Number
  24. Python Program to Print Pronic Numbers from 1 to 100
  25. Python Program to check Spy Number
  26. Python program to find Prime Factors of a Number
  27. Python Program to Reverse a Number
  28. Python Program to check Strong Number
  29. Python program to print Strong Numbers from 1 to 100
  30. Python program to find Sum of Digits in a Number
  31. Python Program to Swap Two Numbers

Python Programming examples on Characters

Below python examples are used to work on characters. Please refer Python Tutorials to learn this programming language.

  1. Python program to check Alphabet or not
  2. Python program to check Alphabet or Digit
  3. Python program to check Character is an Alphabet, Digit or Special Character
  4. Python program to check Digit or Not
  5. Python program to check Lowercase or not
  6. Python program to check Lowercase or Uppercase
  7. Python Program to check Uppercase or not
  8. Python program to check Vowel or Consonant

Python String Programs

The following are the list of python programming examples on strings.

  1. Python example for ASCII Value of a Single Character
  2. Python program to print ASCII Value of Total Characters in a String
  3. Python program to Concatenate Strings
  4. Python program to Convert String to Uppercase
  5. Python program to Convert String to Lowercase
  6. Python program to Copy a String
  7. Python program to Count Occurrence of a Character in a String
  8. Python Program to Count Characters Frequency in a String
  9. Python program to Count Total Characters in a String
  10. Python program to Count Total Number of Words in a String
  11. Python program to Count Vowels in a String
  12. Python program to Count Vowels and Consonants in a String
  13. Python program to Count Alphabets Digits and Special Characters in a String
  14. Python program to check Palindrome or Not
  15. Python Program to Check If Two Strings are Anagram
  16. Python program to Print First Occurrence of a Character in a String
  17. Python program to Print Last Occurrence of a Character in a String
  18. Python program to Print Characters in a String
  19. Python program to Replace Blank Space with Hyphen in a String
  20. Python program to Replace Characters in a String
  21. Python program to Remove Odd Characters in a String
  22. Python program to Remove Odd Index Characters in a String
  23. Python program to Remove First Occurrence of a Character in a String
  24. Python program to Remove Last Occurred Character in a String
  25. Python Program to Remove Punctuations from a String
  26. Python program to Reverse a String
  27. Python program to find String Length
  28. Python program to find Total Occurrence of a Character in a String
  29. Python string programs to Toggle Characters Case

Python List Programs

The following are the List of Python Programming Examples on Lists.

  1. Python Program to Append an Item to a List
  2. Python example to access List Index and Values
  3. Python example to add two Lists
  4. Python example for Arithmetic Operations on Lists
  5. Python Program to Calculate the Average of List Items
  6. Python example to check List is Empty or Not
  7. Python example to Clone or Copy a List
  8. Python program to Count Even and Odd Numbers in a List
  9. Python program to Count Positive and Negative Numbers in a List
  10. Python program to Print Largest Number in a List
  11. Python program to Print Largest and Smallest Number
  12. Python program to find Length of a List
  13. Python program to find List Difference
  14. Python List Multiplication Program
  15. Python program to Print Elements in a List
  16. Python Program to Print List Items in Reverse Order
  17. Python Program to Print List Items Greater Than Average
  18. Python Program to Print List Items at Even Position
  19. Python Program to Print List Items at Odd Position
  20. Python program to Even Numbers in a List
  21. Python program to Print Odd List Numbers
  22. Python program to Print Positive Numbers
  23. Python program to Print Negative Numbers
  24. Python program to Put Even and odd Numbers in Separate List
  25. Python program to Put Positive and Negative Numbers in Separate List
  26. Python program to Remove Duplicates from List
  27. Python program to Remove Even Numbers in a List
  28. Python program to Reverse List Items
  29. Python program to Print Second Largest Number in a List
  30. Python program to Sort List Items in Ascending Order
  31. Python Program to Sort List Items in Descending Order
  32. Python program to Print Smallest Element in a List
  33. Python program to find Sum of All Elements
  34. List programs to find Sum of Even and Odd Numbers
  35. Python List program to Left Rotate by n
  36. Python program to Right Rotate a List by n

Python Programming Examples on Tuples

  1. Python example to add an Item to tuple
  2. Python example to create a Tuple
  3. Python example to create Tuple of Different Types
  4. Python Program to Print Tuple using string formatting
  5. Python Program to Remove an Item from Tuple
  6. Python Program to Slice a Tuple
  7. Python Program to Unpack Tuple Items
  8. Python Program to Create a Tuple with Numbers
  9. Python Program to Check Item exists in Tuple
  10. Python Program to Find Largest and Smallest Item in a Tuple
  11. Python Program to Find Sum of Even and Odd Numbers in Tuple
  12. Python Program to Find Sum of Tuple Items
  13. Python Program to Reverse Tuple
  14. Count Positive and Negative Numbers in Tuple
  15. Count Even and Odd Numbers in Tuple
  16. Python Program to Print Even Numbers in Tuple
  17. Python Program to Print Negative Numbers in Tuple
  18. Python Program to Get Tuple Items
  19. Python Program to Print Positive Numbers in Tuple
  20. Python Program to Print Odd Numbers in Tuple
  21. Python Program to Find Smallest Item in a Tuple
  22. Python Program to Find Largest Item in a Tuple
  23. Python Program to Print Tuple Items
  24. Python Program to Find Tuple Length

Python Dictionary Programs

  1. Python example to add Key-Value Pair to a Dictionary
  2. Python program to Check if a Given key exists in a Dictionary
  3. Python program to Count words in a String using Dictionary
  4. Python program to Create Dictionary of keys from 1 to n and values are square of keys
  5. Python program to Create Dictionary of Numbers 1 to n in (x, x*x) form
  6. Python program to Map two lists into a Dictionary
  7. Python program to Merge Two Dictionaries
  8. Python program to Multiply All Items in a Dictionary
  9. Python program to Remove Given Key from a Dictionary
  10. Python program to find Sum of Items in a Dictionary

Python Set Programs

The Python sets are the collection of unordered items, and they don’t allow duplicates. The following Python programs help you understand the sets in detail.

  1. Python Program to create a Set
  2. Python program to Count Even and Odd Numbers in Set
  3. Python program to Count Positive and Negative Numbers in Set
  4. Python program to Iterate Set Items
  5. Python program to Print Largest Set Item
  6. Python program to find Length of a set
  7. Python program to Print Even Numbers in Set
  8. Python program to Print Negative Numbers in Set
  9. Python program to Print Odd Numbers in Set
  10. Python program to Print Positive Numbers in Set
  11. Python program to find Sum of Even and Odd Numbers in Set
  12. Python program to find Smallest Set Item

Python Programs on Numpy Array

Like other programming languages, Python doesn’t support arrays. However, Python has a Numpy module that supports arrays.

In these Python programs, we use this numpy module to write array and matrix programs. The following are list of Python programs on numpy array and the matrix.

  1. Python Program to Perform Arithmetic Operations on Array
  2. Python example to Copy an Array
  3. Python example to Count Even and Odd Numbers in an Array
  4. Python Program to Calculate the Average of an Array
  5. Python Program to Find Array Elements Greater Than Average
  6. Python example to find Largest Number in an Array
  7. Python program to Count Positive and Negative Numbers in an Array
  8. Python program to find Length of a Numpy Array
  9. Python program to find Minimum and Maximum Value in an Array
  10. Python program to Print Even Numbers in an Array
  11. Python program to Print Odd Numbers in an Array
  12. Python program to Print Negative Numbers in an Array
  13. Python program to Print Array Items
  14. Python Program to Print Array Elements in Reverse Order
  15. Python Program to Print Array Elements Present on Even Position
  16. Python Program to Print Array Elements Present on Odd Position
  17. Python program to Print Positive Numbers in an Array
  18. Python program to Reverse the Numpy Array
  19. Python program to find Second Largest in an Array
  20. Python program to Print Smallest Number in an Array
  21. Python program to Sort Array in Ascending Order
  22. Python program to Sort Array in Descending Order
  23. Python program to find Sum of Numpy Array Items
  24. Python program to find Sum of Even and Odd Numbers in an Array
  25. Python program to Print Unique Items in an Array
  26. Python Program to Left Rotate a Numpy Array by n
  27. Python Program to Right Rotate a Numpy Array by n

Python Examples on Area and Volume

This sections covers python programs on Areas, Volume and Surface Area with examples

Python Area Programs

  1. Python example to find the Area of a Circle
  2. Python Program to find Diameter, Circumference, and Area Of a Circle
  3. Python Program to find Equilateral Triangle Area
  4. Python Program to check Triangle is Valid or Not
  5. Python Program to Find angle of a Triangle if two angles are given
  6. Python Program for Isosceles Triangle Area
  7. Python Program for Triangle Area
  8. Python program to find Triangle area using base and height
  9. Python program to find Area of a Trapezoid
  10. Python Program for Parallelogram Area
  11. Python program to find Rectangle Area using length and width
  12. Python program to find Rectangle Perimeter using length and width
  13. Python program to find Area of a Rectangle
  14. Python program to find Area of a Right Angled Triangle
  15. Python program for Rhombus Area
  16. Python program for Rhombus Perimeter

Python Volume and Surface Area Examples

  1. Python Program to Find the Volume and Surface Area of a Sphere
  2. Python Program to Find the Volume and Surface Area of a Cylinder
  3. Python Program to Find the Volume and Surface Area of a Cube
  4. Python Program to Find the Volume and Surface Area of a Cone
  5. Python Program to Find the Volume and Surface Area of a Cuboid

Python Programs on Series

  1. Python program to find Sum of Arithmetic Progression Series
  2. Python program to find Sum of Geometric Progression Series
  3. Python program to find Find Sum of Series 1²+2²+3²+….+n²
  4. Python program to find Sum of Series 1³+2³+3³+….+n³

Python Conversions Programs

Some of the popular conversion examples in Python programs.

  1. Python Program to Convert Integer to String
  2. Python program to Convert Celsius to Fahrenheit
  3. Python program to convert Centimeters to Meters and Kilometers
  4. Python example to convert Decimal to Binary, octal, and Hexadecimal
  5. Python Program to convert Kilometers to Miles
  6. Python example to convert Kilometers to Meters, Centimeters, and Millimeters
  7. Python Program to Convert List To String
  8. Python Program to Convert List to Tuple
  9. Python example to convert Miles to Kilometers
  10. Python Program to Convert Tuple to String
  11. Python Program to Convert Tuple to Dictionary

Python Star Pattern Programs

The following Python Programming examples show you the pattern programs. This section uses various patterns on stars and 0, 1 patterns. For all Star Pattern programs >> Click Here.

  1. Python Programs to Print Bubble Sort
  2. Python Programs to Print Christmas Tree Star Pattern
  3. Python example to Print Diamond Star Pattern
  4. Python example to print Hollow Diamond Star Pattern
  5. Python example to print Exponentially Increasing Star Pattern
  6. Python example to print Floyd’s Triangle
  7. Python example to Print Half Diamond Star Pattern
  8. Python example to print Hollow Half Diamond Star Pattern
  9. Python example to print Mirrored Half Diamond Star Pattern
  10. Python example to Print Plus Star Pattern
  11. Python example to print Pyramid Star Pattern
  12. Python example to print Inverted Pyramid Star Pattern
  13. Python example to print Rectangle Star Pattern
  14. Python example to print Hollow Rectangle Star Pattern
  15. Python example to Print Right Angled Triangle Star Pattern
  16. Python example to print Hollow Right Triangle Star Pattern
  17. Python example to print Inverted Right Triangle Star Pattern
  18. Python example to print Hollow Inverted Right Triangle
  19. Python example to print Mirrored Right Triangle Star Pattern
  20. Python example to print Reverse Mirrored Right Triangle Star Pattern
  21. Python example to print Rhombus Star Pattern
  22. Python example to print Hollow Rhombus Star Pattern
  23. Python example to print Mirrored Rhombus Star Pattern
  24. Python example to print Hollow Mirrored Rhombus Star Pattern
  25. Python example to print Square Star Pattern
  26. Python example to print Square Star Hollow Pattern
  27. Python example to print Hollow Square Star With Diagonals
  28. Python Program to Print Downward Triangle Star Pattern
  29. Python Programs to Print Left Pascals Star Triangle
  30. Python Program to Print Hollow Left Pascals Star Triangle
  31. Python Program to Print Right Pascals Star Triangle
  32. Python Program to Print Hollow Right Pascals Star Triangle
  33. Python Program to Print Sandglass Star Pattern
  34. Python Program to Print Hollow Sandglass Star Pattern
  35. Python Program to Print H Star Pattern
  36. Python Program to Print V Star Pattern
  37. Python Program to Print Inverted V Star Pattern
  38. Python Program to Print W Star Pattern
  39. Python Program to Print X Star Pattern
  40. Python Program to Print 8 Star Pattern

Python Number Pattern Programs

For all Number Pattern programs >> Click Here.

  1. Python Programs to Print 1 and 0 in Alternative Columns
  2. Python Programs to Print 1 and 0 in Alternative Rows
  3. Python example to Print Box Number Pattern of 1 and 0
  4. Python example to print Hollow Box Pattern of Numbers of 1 and 0
  5. Python Program to Print Pyramid Numbers Pattern
  6. Python example to print Right Triangle Number Pattern
  7. Python Program to Print Right Triangle of 1 and 0
  8. Python Program to Print Right Triangle of Incremented Numbers
  9. Python Program to Print Right Triangle of Numbers in Reverse
  10. Python Program to Print Right Triangle of Numbers in Sine Wave Pattern
  11. Python Program to Print Right Triangle of Mirrored Numbers Pattern
  12. Python example to Print Right Triangle of Consecutive Column Numbers
  13. Python example to Print Right Triangle of Consecutive Rows Numbers
  14. Python example to print Inverted Right Triangle of Numbers
  15. Python example to Print Inverted Right Triangle of Consecutive Numbers
  16. Python Program to Print Inverted Right Triangle of Decreasing Order Numbers
  17. Python Program to Print Inverted Right Triangle Numbers in Reverse
  18. Python Program to Print Downward Triangle Mirrored Numbers Pattern
  19. Python Program to Print Square Number Pattern
  20. Python Program to Print Square with Same Numbers on all Sides
  21. Python Program to Print Square with Same Numbers Rows and Columns
  22. Python Program to Print Square With Diagonal Numbers Pattern
  23. Python Program to Print Square of Left Decrement Numbers Pattern
  24. Python Program to Print Square of Right Increment Numbers Pattern
  25. Python Program to Print Diamond Number Pattern
  26. Python Program to Print Simple Number Pattern
  27. Python Program to Print Sandglass Number Pattern
  28. Python Program to Print Triangle Numbers Pattern
  29. Python Program to Print Triangle of Numbers in Reverse Pattern
  30. Python Program to Print Inverted Triangle Numbers Pattern
  31. Python Program to Print Triangle of Mirrored Numbers Pattern
  32. Python Program to Print K Shape Number Pattern
  33. Python Program to Print Pascal Triangle
  34. Python Program to Print Left Pascals Number Triangle
  35. Python Program to Print Right Pascals Number Triangle
  36. Python Programs to Print Right Pascals Triangle of Multiplication Numbers Pattern
  37. Python Programs to Print Left Arrow Numbers Pattern
  38. Python Programs to Print Right Arrow Number Pattern
  39. Python Programs to Print Right Triangle of Fibonacci Series Numbers Pattern
  40. Python Programs to Print Right Pascals Triangle of Mirrored Numbers Pattern
  41. Python Programs to Print Square Pattern of Left Shift Numbers
  42. Python Programs to Print Square Pattern of Left Rotating Odd Numbers
  43. Python Programs to Print Square Numbers in Sine Wave Pattern
  44. Python exercise to Print Square of Right Decrement Numbers Pattern
  45. Python exercise to Print V Numbers Pattern

Python Alphabets Pattern Programs

  1. Python Programs to Print Diamond Alphabets Pattern
  2. Python Programs to Print Downward Triangle Alphabets Pattern
  3. Python Programs to Print Downward Triangle Mirrored Alphabets Pattern
  4. Python Programs to Print K Shape Alphabets Pattern
  5. Python Programs to Print Left Arrow Alphabets Pattern
  6. Python Programs to Print Pyramid Alphabets Pattern
  7. Python Programs to Print Repeated Character Pattern
  8. Python Programs to Print Right Arrow Alphabets Pattern
  9. Python Programs to Print Right Pascals Triangle Alphabets Pattern
  10. Python Programs to Print Right Triangle Alphabets Pattern
  11. Python Programs to Print Right Triangle Character Pattern
  12. Python Programs to Print Right Triangle of Alphabets in Reverse
  13. Python Programs to Print Right Triangle of Consecutive Alphabets Pattern
  14. Python Programs to Print Right Triangle of Consecutive Row Alphabets Pattern
  15. Python Programs to Print Right Triangle of Incremental Alphabets Pattern
  16. Python Programs to Print Right Triangle of Mirrored Alphabets Pattern
  17. Python Programs to Print Mirrored Right Triangle Alphabets Pattern
  18. Python Programs to Print Sandglass Alphabets Pattern
  19. Python Programs to Print Square of Right Increment Alphabets Pattern
  20. Python Programs to Print Triangle Alphabets Pattern
  21. Python Programs to Print Triangle of Alphabets in Reverse Pattern
  22. Python Programs to Print Triangle of Mirrored Alphabets Pattern
  23. Python Programs to Print Triangle of Same Alphabets Pattern
  24. Python Programs to Print Inverted Triangle Alphabets Pattern

Comments are closed.