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