Python Programming Examples

This page contains Python programming examples that cover the concepts, including basic and simple number programs, string, List, series, 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 programming language with practical examples.

Basic Python Programs

The below 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 Largest of 2 Numbers
  8. Python program to find Largest of 3 Numbers
  9. Python program for Leap Year
  10. Python Program to Print Negative Numbers in a Range
  11. Python Program to Print Positive Numbers in a Range
  12. Python program to find Positive or Negative
  13. Python program to check Number Divisible by 5 and 11
  14. Python Program to Find the Sum and Average Of Three Numbers
  15. Python Program to Find the Average Of Two Numbers
  16. Python Program to Get Current Date and Time

Math Programs

  1. Python program to find the Cube of a Number
  2. Python program to find Profit Or Loss
  3. Python program to find the Square of a Number
  4. Python program to find the Square root of a Number
  5. Python Program to find all divisors of an integer
  6. Python Program to Find Compound Interest
  7. Python Program to Calculate Electricity Bill
  8. Python Program to Find Distance Between Two Points
  9. Python program to find the Power of a Number
  10. Python program for Multiplication Table
  11. Python Program to find Roots of a Quadratic Equation
  12. Python Program to find Student Grade
  13. Python Program to find Simple Interest
  14. Python program to find the Total Average & Percentage of 5 Subjects
  15. Python Program to Make a Simple Calculator

Even, Odd, and Natural Number Programs

The following programs will accept the user inputs and find the Sum and average of even, odd, and natural numbers.

  1. Python Program to find Odd or Even
  2. Python program to Print Natural number 1 to N
  3. Python program to Print Natural Numbers in Reverse Order
  4. Python program to Print Even Numbers from 1 to 100
  5. Python program to print Odd Numbers from 1 to 100
  6. Python Program to Print First 10 Even Natural Numbers
  7. Python Program to Print First 10 Natural Numbers
  8. Python Program to Print First 10 Natural Numbers in Reverse
  9. Python Program to Print First 10 Odd Natural Numbers
  10. Python Program to find the Sum and Average of Natural Numbers
  11. Python Program to Read 10 Numbers and Find their Sum and Average
  12. Python Program to Find the Sum of 10 Numbers and Skip Negative Numbers
  13. Python Program to Find the Sum of 10 Numbers until user enters Positive Numbers
  14. Python Program to find Sum of Natural Numbers
  15. Python Program to find Sum of Even Numbers
  16. Python Program to find the Sum and Average of Natural Numbers
  17. Python Program to find the Sum of Odd Numbers
  18. Python Program to find the sum of Even and Odd Numbers
  19. Python Program to Read 10 Numbers and Find their Sum and Average

Python Programming Examples on Series

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

Advanced Number Programs

The following Python programming examples are helpful for working 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 find Factors of a Number
  4. Python Program to find the Factorial of a Number
  5. Python program to print the First Digit of a Number
  6. Python program to print Last Digit in a Number
  7. Python program to find the GCD of Two Numbers
  8. Python program to find LCM of Two Numbers
  9. Python program to check a Palindrome Number
  10. Python Program to Print Palindrome Numbers from 1 to 100
  11. Python Program to Reverse a Number
  12. Python program to find the Sum of Digits in a Number
  13. Python Program to Swap Two Numbers

Armstrong, Prime, and Perfect Numbers programs

  1. Python Program to Check Armstrong Number
  2. Python program to check Perfect Number
  3. Python program to check Prime Number
  4. Python program to print Prime Numbers from 1 to 100
  5. Python program to find Prime Factors of a Number
  6. Python Program to Check Disarium Number
  7. Python Program to Print Disarium Numbers from 1 to 100
  8. Python Program to Check Happy Number
  9. Python Program to Print Happy Numbers from 1 to 100
  10. Python Program to Check Harshad Number
  11. Python Program to Print Harshad Numbers from 1 to 100
  12. Python Program to Check Krishnamurthy Number
  13. Python Program to Check Neon Number
  14. Python Program to Check Pronic Number
  15. Python Program to Print Pronic Numbers from 1 to 100
  16. Python Program to check Spy Number
  17. Python Program to check Strong Number
  18. Python program to print Strong Numbers from 1 to 100

Python Programming Examples on Characters

The below examples are used to work on characters.

  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 Program 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 check Palindrome or Not
  8. Python Program to Check If Two Strings are Anagram
  9. Python program to Print the First Occurrence of a Character in a String
  10. Python program to Print the Last Occurrence of a Character in a String
  11. Python program to Print Characters in a String
  12. Python program to find String Length
  13. Total Occurrence of a Character in a string
  14. Toggle Characters Case

String Reverse, Replace, Count, and Remove Programs

  1. Python program to Count the Occurrence of a Character in a String
  2. Python Program to Count Character Frequency in a String
  3. Python program to Count Total Characters in a String
  4. Python program to Count the Total Number of Words in a String
  5. Python program to Count Vowels in a String
  6. Python program to Count Vowels and Consonants in a String
  7. Python program to Count Alphabets Digits and Special Characters in a String
  8. Python program to Replace Blank Space with Hyphen in a String
  9. Python program to Replace Characters in a String
  10. Python program to Remove Odd Characters in a String
  11. Python program to Remove Odd Index Characters in a String
  12. Python program to Remove the First Occurrence of a Character in a String
  13. Python program to Remove Last Occurred Character in a String
  14. Python Program to Remove Punctuations from a String
  15. Python program to Reverse a String

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 Program to access List Index and Values
  3. Python Program to add two Lists
  4. Python Program to Change List Items
  5. Python Program for Arithmetic Operations on Lists
  6. Python Program to Calculate the Average of List Items
  7. Python Program to Clear a List
  8. Python Program to check List is Empty or Not
  9. Python Program to Check if the Element Exists in a List
  10. Python Program to Clone or Copy a List
  11. Python Program to Count Occurrence of an element in a List
  12. Python program to Count Even and Odd Numbers in a List
  13. Python program to Count Positive and Negative Numbers in a List
  14. Python program to find Length of a List
  15. Python program to find the List Difference
  16. Python Program to Find the Average of a List
  17. Python Program to Merge Two Lists
  18. Python List Multiplication Program
  19. Python program to find the Sum of All List Elements
  20. Sum and Average of a List
  21. Sum of Even and Odd List Numbers
  22. Left Rotate a List by n
  23. Right Rotate a List by n
  24. Remove an item from a List
  25. Remove the First element from a List
  26. Remove the Last Element from a List
  27. Iterate Over List Items
  28. Interchange First and Last Elements in a List
  29. Swap two items in a List

List Sort, Remove, Reverse, Print Items Programs

  1. Python program to Print Elements in a List
  2. Python Program to Print List Items in Reverse Order
  3. Python Program to Print List Items Greater Than Average
  4. Python Program to Print List Items at Even Position
  5. Python Program to Print List Items at Odd Position
  6. Python Program to Print Even Numbers in a List
  7. Python program to Print Odd List Numbers
  8. Python program to Put Even and odd Numbers in Separate List
  9. Python program to Print Positive Numbers
  10. Python program to Print Negative Numbers
  11. Python program to Put Positive and Negative Numbers in Separate List
  12. Python program to Print the Largest Number in a List
  13. Python program to Print the Second Largest Number in a List
  14. Python program to Print the Largest and Smallest Number
  15. Python program to Print the Smallest Element in a List
  16. Python program to Remove Duplicates from List
  17. Python program to Remove Even Numbers in a List
  18. Python program to Reverse List Items
  19. Python program to Sort List Items in Ascending Order
  20. Python Program to Sort List Items in Descending Order

Python Programming Examples on Tuples

  1. Python Program to add an Item to a tuple
  2. Python Program to create a Tuplea
  3. Python Program to create Tuple of Different Types
  4. Python Program to Find Tuple Length
  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 Sum of Even and Odd Numbers in Tuple
  11. Python Program to Find Sum of Tuple Items
  12. Python Program to Reverse Tuple
  13. Count Positive and Negative Numbers in a Tuple
  14. Count Even and Odd Numbers in Tuple

Tuple Items printing programs

  1. Get Tuple Items
  2. Python Program to Print Tuple using string formatting
  3. Python Program to Print Even Numbers in Tuple
  4. Python Program to Print Negative Numbers in Tuple
  5. Python Program to Print Positive Numbers in Tuple
  6. Python Program to Print Odd Numbers in Tuple
  7. Python Program to Print Smallest Item in a Tuple
  8. Python Program to Print Largest Item in a Tuple
  9. Python Program to Find Largest and Smallest Item in a Tuple
  10. Python Program to Print Tuple Items

Python Dictionary Programs

  1. Python Program 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. Merge Two Dictionaries
  8. Multiply All Items in a Dictionary
  9. Remove Given Key from a Dictionary
  10. Sum of Items in a Dictionary

Python Programming Examples on Sets

The sets are the collection of unordered items, and they don’t allow duplicates. The following 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

Numpy Array Programs in Python

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

In these 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 Program to Copy an Array
  3. Python Program 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 Program 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 Reverse the Numpy Array
  11. Python program to find Second Largest in an Array
  12. Python program to Print Smallest Number in an Array
  13. Python program to Sort Array in Ascending Order
  14. Python program to Sort Array in Descending Order
  15. Python program to find Sum of Numpy Array Items
  16. Python program to find Sum of Even and Odd Numbers in an Array
  17. Python Program to Left Rotate a Numpy Array by n
  18. Python Program to Right Rotate a Numpy Array by n

Print Array Items

  1. Python program to Print Even Numbers in an Array
  2. Python program to Print Odd Numbers in an Array
  3. Python program to Print Negative Numbers in an Array
  4. Python program to Print Array Items
  5. Python Program to Print Array Elements in Reverse Order
  6. Python Program to Print Array Elements Present on Even Position
  7. Python Program to Print Array Elements Present on Odd Position
  8. Python program to Print Positive Numbers in an Array
  9. Python program to Print Unique Items in an Array

Python Programming Examples on Area

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

  1. Python Program 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 Programs

  1. Volume and Surface Area of a Sphere
  2. Volume and Surface Area of a Cylinder
  3. Volume and Surface Area of a Cube
  4. Volume and Surface Area of a Cone
  5. Volume and Surface Area of a Cuboid

Python Conversions Programs

Some of the popular conversion examples.

  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 Program to convert Decimal to Binary, octal, and Hexadecimal
  5. Python Program to convert Kilometers to Miles
  6. Python Program 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 Program 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,alphabets, and 0, 1 number patterns.

Some of the important programs are as follows

  1. Python Program to Print Pascal Triangle
  2. Python Program to Print Bubble Sort
  3. Python Program to Print Diamond Star Pattern
  4. Python Program to print Floyd’s Triangle

Comments are closed.