Conditional Programs

Python programs focused on decision making using if, elif, else, and nested conditions.

20 program solutions

Back to Topics

Program Solutions

1

Grade Calculator

Calculate letter grade (A, B, C, D, F) from percentage using conditional statements.

Beginner
View Solution
2

Vowel or Consonant

Check whether an alphabetic character is a vowel or a consonant.

Beginner
View Solution
3

Character Classification (Digit / Alpha / Special)

Classify a single character as a digit, alphabet, or special character.

Beginner
View Solution
4

Check Eligibility to Vote

Check if a person is eligible to vote based on age (18 or older).

Beginner
View Solution
5

Check Divisible by 5 and 11

Check whether a given integer is divisible by both 5 and 11.

Beginner
View Solution
6

Check Armstrong Number

Check whether a given integer is an Armstrong (narcissistic) number.

Beginner
View Solution
7

Check Perfect Square

Check whether a number is a perfect square.

Beginner
View Solution
8

Triangle Type Check

Determine if three sides form a valid triangle and its type (equilateral, isosceles, scalene).

Beginner
View Solution
9

Check Strong Number

Check whether a number is a strong number (sum of factorials of digits).

Beginner
View Solution
10

Check Perfect Number

Check whether a number is a perfect number (sum of proper divisors equals the number).

Beginner
View Solution
11

Check Automorphic Number

Check whether a number is automorphic (its square ends with the same digits).

Beginner
View Solution
12

Check Harshad Number

Check whether a number is a Harshad (Niven) number (divisible by sum of its digits).

Beginner
View Solution
13

Check Abundant Number

Check whether a number is abundant (sum of proper divisors is greater than the number).

Beginner
View Solution
14

Check Friendly Pair

Check whether two numbers form a friendly pair (same abundancy index).

Intermediate
View Solution
15

Compare Floating Numbers

Compare two floating-point numbers with a tolerance to avoid precision issues.

Intermediate
View Solution
16

Menu-Driven Calculator

A simple text-based calculator using a menu and conditional logic.

Beginner
View Solution
17

Bill Discount System

Apply different discount slabs based on total bill amount.

Beginner
View Solution
18

Login Authentication

Simulate a simple login system by comparing username and password with stored values.

Beginner
View Solution
19

Validate Password Strength

Check if a password is strong based on length and character type rules.

Intermediate
View Solution
20

Validate Email Format

Validate whether a string matches a basic email address pattern.

Intermediate
View Solution

Topic Strategy: Conditional Programs

This topic is best practiced through repetition with variation. Solve each program, then modify constraints and test alternate approaches so you understand why one solution performs better than another.

During interviews, explain the approach before coding: input assumptions, core logic, complexity, and edge cases. Clear reasoning often matters as much as final code correctness.

Once comfortable, time-box each question and target clean, readable code with meaningful variable names and a quick dry run explanation.