Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsPython

Basic Python Programs

print, input, if, a bit of math. Week-one stuff. If this feels slow, skip ahead.

25 programs · open one, then the next

The matching chapter is Day 1: Introduction to Python in the Python course. For a short check, try the Python quiz (300 questions). Every topic is listed on Python exercises.

Start with Print "Hello, World!"
  1. 01Print "Hello, World!"BeginnerOne line is enough for your first Python script. Print Hello, World!, check that Python runs, and learn what quotes and a terminal newline actually do.Open example →
  2. 02Add Two NumbersBeginnerWhy does adding two Python inputs sometimes give 1020? This beginner addition program converts text with float before calculating and printing a numeric sum.Open example →
  3. 03Swap Two VariablesBeginnerTrace two Python swaps side by side: a temporary variable and tuple unpacking. New programmers can see exactly when each original value is read and replaced.Open example →
  4. 04Find ASCII Value of a CharacterBeginnerWhat number represents A? Use Python ord to inspect a character, reject empty or longer responses, and understand the Unicode detail behind this ASCII exercise.Open example →
  5. 05Check Even or OddBeginnerDecide whether an integer is even or odd with one Python remainder test. This first conditional exercise includes zero, negatives, and readable comparisons.Open example →
  6. 06Find Largest of Two NumbersBeginnerChoose the larger of two Python numbers without forgetting equal inputs. A beginner three-branch walkthrough explains comparisons and the 12.0 output format.Open example →
  7. 07Find Largest of Three NumbersBeginnerTwo equal maxima can break a careless Python comparison. Follow this beginner three-number program and see why >= and and belong in the winning conditions.Open example →
  8. 08Check Positive, Negative, or ZeroBeginnerGive positive numbers, negative numbers, and zero their own Python branches. Practice strict comparisons with decimal input in this beginner sign classifier.Open example →
  9. 09Convert Kilometers to MilesBeginnerTurn a kilometer measurement into miles with Python float input and a named factor. A first conversion exercise explains units, multiplication, and rounding.Open example →
  10. 10Convert Celsius to FahrenheitBeginnerCheck 25°C against 77°F while building a Python temperature converter. See why new programmers need both the 9/5 scale factor and the extra 32 in the formula.Open example →
  11. 11Calculate Area of a TriangleBeginnerCalculate a triangle’s area from base and perpendicular height in Python. This beginner formula exercise keeps units straight and explains why 1//2 is wrong.Open example →
  12. 12Calculate Simple InterestBeginnerEnter 5, not 0.05, for a 5% annual rate in this Python simple-interest exercise. Follow the formula as a beginner and separate earned interest from principal.Open example →
  13. 13Calculate Compound InterestBeginnerWatch quarterly interest grow a balance with Python **. A beginner formula walkthrough explains period rates, compounding counts, and total versus interest.Open example →
  14. 14Calculate Square RootBeginnerCall Python math.sqrt only after checking the real-number domain. A beginner lesson connects square roots, float results, negative input, and ValueError.Open example →
  15. 15Convert Seconds to Hours, Minutes, and SecondsBeginnerSplit 3665 seconds into one hour, one minute, and five seconds with Python // and %. A beginner dry run shows exactly where each quotient and remainder goes.Open example →
  16. 16Calculate Body Mass Index (BMI)BeginnerSquare the height, check the units, then calculate BMI in Python. First-year practice covers safe division, ordered cutoffs, display rounding, and model limits.Open example →
  17. 17Check Leap YearBeginner1900 is not a leap year; 2000 is. Build the full Gregorian test in Python and practice the 400, 100, and 4 exceptions with beginner-friendly Boolean logic.Open example →
  18. 18Find Absolute ValueBeginnerSee what Python abs normally hides by writing the sign decision yourself. This beginner lesson keeps the original input and explains a signed-zero wrinkle.Open example →
  19. 19Calculate Age from Birth YearBeginnerEstimate an age with Python date.today rather than a stale year constant. For beginners, the main lesson is why a birth year alone cannot establish exact age.Open example →
  20. 20Sum of First N Natural NumbersBeginnerReplace a long addition with N(N+1)/2 in Python. A first-year exercise explains the pairing idea, exact integer division, and the positive-input requirement.Open example →
  21. 21Calculate Power Without Using pow()BeginnerBuild 2³ one multiplication at a time in Python, without pow or **. Beginner traces cover the accumulator, zero exponents, reciprocals, and a zero-base trap.Open example →
  22. 22Print Multiplication TableBeginnerMake a Python times table that stops at the requested row. Learn range’s exclusive stop, a blank-input default, and readable f-strings in a beginner loop.Open example →
  23. 23Convert Decimal to BinaryBeginnerCollect remainders to turn decimal 10 into binary 1010 with Python. New programmers trace the shrinking quotient, reversed bits, and the separate zero case.Open example →
  24. 24Convert Binary to DecimalBeginnerRead binary 1010 as repeated double-and-add steps in Python. This beginner conversion checks for actual digits, rejects blank input, and rebuilds place value.Open example →
  25. 25Calculate Electricity BillBeginnerBill each block of electricity at its own rate in Python. A beginner slab calculation shows why 250 units cost 1700, not 2500, under the stated example rates.Open example →