0% found this document useful (0 votes)
4 views3 pages

Python Programs of Conditional Statements

The document contains a series of Python programs designed for Class 9 students, focusing on conditional statements. Each program addresses a specific problem, such as determining voting eligibility, checking odd/even numbers, comparing values, calculating electricity bills, and verifying login credentials. Students are instructed to document their work on A4 sheets, including screenshots of outputs and personal details on a cover page.

Uploaded by

chesskid4700
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Python Programs of Conditional Statements

The document contains a series of Python programs designed for Class 9 students, focusing on conditional statements. Each program addresses a specific problem, such as determining voting eligibility, checking odd/even numbers, comparing values, calculating electricity bills, and verifying login credentials. Students are instructed to document their work on A4 sheets, including screenshots of outputs and personal details on a cover page.

Uploaded by

chesskid4700
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

07/08/2025, 20:01 Class-9-Python Programs of Conditional statements 2025-26 .

ipynb - Colab

General Instructions:

1. Students will write question and the programs neatly on A4 sheet


2. Paste the screenshot of the output after each program.
3. Start all programs from new page.
4. Include a cover page with Title -"Python Programs of Conditional Statements" and your details-Name, Admission Number, Roll No. &
Class & Sec.

The link of this Colab file is as follows, students can excute the programs and get the output:

https://colab.research.google.com/drive/1V5D9j70pAfrmSQTQSgjmV2jgF8e5ufiM?usp=sharing

Program-1 #WAP to decide the person is eligible for vote or not.

age = int(input("Enter your age: "))


if age >= 18:
print("Eligible to vote")
else:
print("Not eligible to vote")

Program-2 #WAP to find given number is odd or even.

num = int(input("Enter a number: "))


if num % 2 == 0:
print("Even number")
else:
print("Odd number")

Program-3 #WAP to compare 2 numbers.

n1=int(input("Enter first number: "))


n2=int(input("Enter second number: "))
if n1>n2:
print(n1,"is greater than",n2)
elif n1<n2:
print(n1,"is less than",n2)
else:
print(n1,"is equal to",n2)

Program-4 #WAP to find the greatest of 3 numbers.

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a >= b and a >= c:


print("Greatest number is:", a)
elif b >= a and b >= c:
print("Greatest number is:", b)
else:
print("Greatest number is:", c)

Program-5 #WAP to calculate the electricity bill based on the number of units consumed, using the following rate structure:

If the consumption is up to 100 units, the rate is Rs. 3 per unit.

If the consumption is between 101 and 200 units, the first 100 units are charged at Rs. 3 per unit, and the remaining units (up to 200) are
charged at Rs. 5 per unit.

If the consumption exceeds 200 units, the first 100 units are charged at Rs. 3 per unit, the next 100 units (101–200) at Rs. 5 per unit, and all
units above 200 are charged at Rs. 10 per unit.

units = int(input("Enter electricity units consumed: "))

if units <= 100:


bill = units * 3
elif units <= 200:
bill = (100 * 3) + (units - 100) * 5
else:
bill = (100 * 3) + (100 * 5) + (units - 200) * 10

print("Electricity bill: ₹", bill)

https://colab.research.google.com/drive/1V5D9j70pAfrmSQTQSgjmV2jgF8e5ufiM#scrollTo=O5gPHcM20doz&printMode=true 1/3
07/08/2025, 20:01 Class-9-Python Programs of Conditional statements 2025-26 .ipynb - Colab

Program-6 #WAP to determine the type of triangle based on the lengths of its three sides. The program should classify the triangle as one of
the following:

Equilateral Triangle: All three sides are equal.

Isosceles Triangle: Any two sides are equal.

Scalene Triangle: All three sides are different.

a = int(input("Enter first side: "))


b = int(input("Enter second side: "))
c = int(input("Enter third side: "))

if a == b == c:
print("Equilateral triangle")
elif a == b or b == c or a == c:
print("Isosceles triangle")
else:
print("Scalene triangle")

Program-7 #WAP to check whether the given year is a leap year or not.

year = int(input("Enter a year: "))


if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("Leap year")
else:
print("Not a leap year")

Program-8 # WAP to create a menu driven program for the following arithmetic operations

a = float(input("Enter first number: "))


b = float(input("Enter second number: "))
print("Select the appropriate operation: ")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
choice = int(input("Enter your choice (1/2/3/4/5): "))

if choice <0 or choice >4:


print("Invalid choice")
elif choice == 1:
print("Result:", a + b)
elif choice == 2:
print("Result:", a - b)
elif choice == 3:
print("Result:", a * b)
else:
print("Result:", a / b)

Program-9 #WAP to calculate the bonus earned by a salesperson based on their total sales amount, using the following criteria:

If the sales amount is less than Rs. 50,000, no bonus is awarded.

If the sales amount is Rs. 50,000 or more but less than Rs. 1,00,000, the bonus is 5% of the sales amount.

If the sales amount is Rs. 1,00,000 or more but less than Rs. 2,00,000, the bonus is 10% of the sales amount.

If the sales amount is Rs. 2,00,000 or more but less than Rs. 3,00,000, the bonus is 15% of the sales amount.

If the sales amount is Rs. 3,00,000 or more, the bonus is 20% of the sales amount.

saleamt=float(input("Enter the sale amount: "))


if saleamt<50000:
print("No bonus")
elif saleamt>=50000 and saleamt<100000:
print("Bonus is",saleamt*5/100)
elif saleamt>=100000 and saleamt<200000:
print("Bonus is",saleamt*10/100)
elif saleamt>=200000 and saleamt<300000:
print("Bonus is",saleamt*15/100)
else:
print("Bonus is",saleamt*20/100)

https://colab.research.google.com/drive/1V5D9j70pAfrmSQTQSgjmV2jgF8e5ufiM#scrollTo=O5gPHcM20doz&printMode=true 2/3
07/08/2025, 20:01 Class-9-Python Programs of Conditional statements 2025-26 .ipynb - Colab

Enter the sale amount: 500000


Bonus is 100000.0

Program-10 #WAP to verify the login & password. Assume Login is 'admin' and password is '1234'.

username = input("Enter username: ")


password = input("Enter password: ")

if username == "admin":
if password == "1234":
print("Login successful")
else:
print("Incorrect password")
else:
print("Invalid username")

https://colab.research.google.com/drive/1V5D9j70pAfrmSQTQSgjmV2jgF8e5ufiM#scrollTo=O5gPHcM20doz&printMode=true 3/3

You might also like