ProgramsPython

Conditional Programs

if / elif / else. Grades, vowels, triangle types. The bugs usually hide in the equal-to case.

20 programs · open one, then the next

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

Start with Grade Calculator
  1. 01Grade CalculatorBeginner90 A, 80 B, ... else F. Check 0–100 first or a 107 becomes an A.Open example →
  2. 02Vowel or ConsonantBeginnerch in 'aeiou'. lower() first or 'A' looks like a consonant.Open example →
  3. 03Character Classification (Digit / Alpha / Special)Beginnerisdigit, isalpha, else special. Space counts as special. That bothers people.Open example →
  4. 04Check Eligibility to VoteBeginner18 or older. Negative age is garbage, not "not eligible".Open example →
  5. 05Check Divisible by 5 and 11BeginnerBoth remainders 0. 55 yes, 10 no. `and` not `or`.Open example →
  6. 06Check Armstrong NumberBeginnerCheck whether a given integer is an Armstrong (narcissistic) number.Open example →
  7. 07Check Perfect SquareBeginnerCheck whether a number is a perfect square.Open example →
  8. 08Triangle Type CheckBeginnerDetermine if three sides form a valid triangle and its type (equilateral, isosceles, scalene).Open example →
  9. 09Check Strong NumberBeginnerCheck whether a number is a strong number (sum of factorials of digits).Open example →
  10. 10Check Perfect NumberBeginnerCheck whether a number is a perfect number (sum of proper divisors equals the number).Open example →
  11. 11Check Automorphic NumberBeginnerCheck whether a number is automorphic (its square ends with the same digits).Open example →
  12. 12Check Harshad NumberBeginnerCheck whether a number is a Harshad (Niven) number (divisible by sum of its digits).Open example →
  13. 13Check Abundant NumberBeginnerCheck whether a number is abundant (sum of proper divisors is greater than the number).Open example →
  14. 14Check Friendly PairIntermediateCheck whether two numbers form a friendly pair (same abundancy index).Open example →
  15. 15Compare Floating NumbersIntermediateCompare two floating-point numbers with a tolerance to avoid precision issues.Open example →
  16. 16Menu-Driven CalculatorBeginnerPrint a menu, read 1-4, then two numbers. Anything else is Invalid choice.Open example →
  17. 17Bill Discount SystemBeginnerApply different discount slabs based on total bill amount.Open example →
  18. 18Login AuthenticationBeginnerSimulate a simple login system by comparing username and password with stored values.Open example →
  19. 19Validate Password StrengthIntermediateCheck if a password is strong based on length and character type rules.Open example →
  20. 20Validate Email FormatIntermediateValidate whether a string matches a basic email address pattern.Open example →