The best way to learn Python is by practicing examples. The page contains examples on basic concepts of Python. You are advised to take the references from these examples and try them on your own.

All the programs on this page are tested and should work on all platforms.

  1. Python Program to Print Hello world!
  2. Python Program to Add Two Numbers
  3. Python Program to Find the Square Root
  4. Python Program to Calculate the Area of a Triangle
  5. Python Program to Solve Quadratic Equation
  6. Python Program to Swap Two Variables
  7. Python Program to Generate a Random Number
  8. Python Program to Convert Kilometers to Miles
  9. Python Program to Convert Celsius To Fahrenheit
  10. Python Program to Check if a Number is Positive, Negative or 0
  11. Python Program to Check if a Number is Odd or Even
  12. Python Program to Check Leap Year
  13. Python Program to Find the Largest Among Three Numbers
  14. Python Program to Check Prime Number
  15. Python Program to Print all Prime Numbers in an Interval
  16. Python Program to Find the Factorial of a Number
  17. Python Program to Display the multiplication Table
  18. Python Program to Print the Fibonacci sequence
  19. Python Program to Check Armstrong Number
  20. Python Program to Find Armstrong Number in an Interval
  21. Python Program to Find the Sum of Natural Numbers
  22. Python Program To Display Powers of 2 Using Anonymous Function
  23. Python Program to Find Numbers Divisible by Another Number
  24. Python Program to Convert Decimal to Binary, Octal and Hexadecimal
  25. Python Program to Find ASCII Value of Character
  26. Python Program to Find HCF or GCD
  27. Python Program to Find LCM
  28. Python Program to Find the Factors of a Number
  29. Python Program to Make a Simple Calculator
  30. Python Program to Shuffle Deck of Cards
  31. Python Program to Display Calendar
  32. Python Program to Display Fibonacci Sequence Using Recursion
  33. Python Program to Find Sum of Natural Numbers Using Recursion
  34. Python Program to Find Factorial of Number Using Recursion
  35. Python Program to Convert Decimal to Binary Using Recursion
  36. Python Program to Add Two Matrices
  37. Python Program to Transpose a Matrix
  38. Python Program to Multiply Two Matrices
  39. Python Program to Check Whether a String is Palindrome or Not
  40. Python Program to Remove Punctuations From a String
  41. Python Program to Sort Words in Alphabetic Order
  42. Python Program to Illustrate Different Set Operations
  43. Python Program to Count the Number of Each Vowel
  44. Python Program to Merge Mails
  45. Python Program to Find the Size (Resolution) of a Image
  46. Python Program to Find Hash of File
  47. Python Program to Create Pyramid Patterns
  48. Python Program to Merge Two Dictionaries
  49. Python Program to Safely Create a Nested Directory
  50. Python Program to Access Index of a List Using for Loop
  51. Python Program to Make a Flattened List from Nested List
  52. List Slicing in Python
  53. Python Program to Iterate Over Dictionaries Using for Loop
  54. Python Program to Sort a Dictionary by Value
  55. Python Program to Check If a List is Empty
  56. Python Program to Catch Multiple Exceptions in One Line
  57. Python Program To Copy a File
  58. Python Program Concatenate Two Lists
  59. Python Program to Check if a Key is Already Present in a Dictionary
  60. Python Program to Split a List Into Evenly Sized Chunks
  61. Python Program to Parse a String to a Float or Int
  62. Python Program to Print Colored Text to the Terminal
  63. Python Program to Convert String to Datetime
  64. Python Program to Get the Last Element of the List
  65. Python Program to Get a Substring of a String
  66. Python Program to Print Output Without a Newline
  67. Python Program Read a File Line by Line Into a List
  68. Python Program to Randomly Select an Element From the List
  69. Python Program to Check If a String Is a Number (Float)
  70. Python Program to Count the Occurrence of an Item in a List
  71. Python Program to Append to a File
  72. Python Program to Delete an Element From a Dictionary
  73. Python Program to Create a Long Multiline String
  74. Python Program to Extract Extension From the File Name
  75. Python Program to Measure the Elapsed Time in Python
  76. Python Program to Get the Class Name of an Instance
  77. Python Program to Convert Two Lists Into a Dictionary
  78. Python Program to Differentiate Between type() and isinstance()
  79. Python Program to Trim Whitespace From a String
  80. Python Program to Get the File Name From the File Path
  81. Python Program to Represent enum
  82. Python Program to Return Multiple Values From a Function
  83. Python Program to Get Line Count of a File
  84. Python Program to Differentiate Between del, remove, and pop on a List
  85. Python Program to Find All File with .txt Extension Present Inside a Directory
  86. Python Program to Get File Creation and Modification Date
  87. Python Program to Get the Full Path of the Current Working Directory
  88. Python Program to Iterate Through Two Lists in Parallel
  89. Python Program to Check the File Size
  90. Python Program to Reverse a Number
  91. Python Program to Compute the Power of a Number
  92. Python Program to Count the Number of Digits Present In a Number
  93. Python Program to Check If Two Strings are Anagram
  94. Python Program to Capitalize the First Character of a String
  95. Python Program to Compute all the Permutation of the String
  96. Python Program to Create a Countdown Timer
  97. Python Program to Count the Number of Occurrence of a Character in String
  98. Python Program to Remove Duplicate Element From a List
  99. Python Program to Convert Bytes to a String