← Back

Home › Python Programs

Python Programs

Beginner-friendly explanations with multiple approaches, output, dry runs and debugging practice.

Why start with these 22 programs

These are the programs every Python course, school syllabus and beginner interview reuses — all 22 of them, from the classic factorial and Fibonacci to leap years, sorting and unit conversion. The point is not to memorise them: each page solves the same problem three times — first with a plain loop, then as a reusable function, and finally with the compact Python idiom — so you can see which part is the logic and which part is only syntax.

Every page also includes a dry run: a short table of what each variable holds after each iteration. That habit becomes debugging later on. When the output is wrong, you already know which line to stop at and which value to print. The common errors section at the bottom of each page lists the mistakes these programs actually produce — an off-by-one range, a missing base case, or an int silently treated as a string.

Reading is only half of it. Each program page links to free browser exercises, and the whole site is indexed in one place in the Explore PyDebug directory.

All programs

  1. Armstrong Number Program in Python — code, output and dry run
  2. Celsius to Fahrenheit Program in Python — code, output and dry run
  3. Count Digits of a Number in Python — code, output and dry run
  4. Count Vowels in a String in Python — code, output and dry run
  5. Even or Odd Program in Python — code, output and dry run
  6. Factorial Program in Python — code, output and dry run
  7. Fibonacci Series Program in Python — code, output and dry run
  8. GCD Program in Python — code, output and dry run
  9. Largest of Three Numbers in Python — code, output and dry run
  10. Leap Year Program in Python — code, output and dry run
  11. Multiplication Table Program in Python — code, output and dry run
  12. Palindrome Program in Python — code, output and dry run
  13. Prime Number Program in Python — code, output and dry run
  14. Reverse a Number Program in Python — code, output and dry run
  15. Reverse a String Program in Python — code, output and dry run
  16. Second Largest Number in a List in Python — code, output and dry run
  17. Simple Interest Program in Python — code, output and dry run
  18. Sort a List in Python (With and Without sort()) — code, output and dry run
  19. Star Pattern Programs in Python — code, output and dry run
  20. Sum of Digits Program in Python — code, output and dry run
  21. Sum of N Natural Numbers in Python — code, output and dry run
  22. Swap Two Numbers Program in Python — code, output and dry run

Where to go next

Once a program makes sense, the next skill is reading failures. The Python error explainer decodes each exception from its own message, the debugging guide turns that into a repeatable method, and the learning paths sequence the practice catalog from first syntax error to interview traps. Learning in Hindi? The same 22 programs are at Python programs (Hindi).