0% found this document useful (0 votes)
113 views2 pages

Python If Programs Class 9

This document contains Python programs designed for Class 9 AI, focusing on basic conditional statements. It includes examples for checking if a number is positive, negative, or zero; determining if a number is even or odd; verifying voting eligibility; finding the largest of two numbers; and calculating grades based on marks. Each program is accompanied by code snippets demonstrating the logic and structure of the conditions.

Uploaded by

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

Python If Programs Class 9

This document contains Python programs designed for Class 9 AI, focusing on basic conditional statements. It includes examples for checking if a number is positive, negative, or zero; determining if a number is even or odd; verifying voting eligibility; finding the largest of two numbers; and calculating grades based on marks. Each program is accompanied by code snippets demonstrating the logic and structure of the conditions.

Uploaded by

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

Python if Programs for Class 9 AI (Subject Code 417)

1. Check if a Number is Positive, Negative, or Zero

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


if num > 0:
print("The number is positive.")
elif num < 0:
print("The number is negative.")
else:
print("The number is zero.")

2. Check if a Number is Even or Odd

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


if num % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")

3. Check if a Person is Eligible to Vote

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


if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

4. Find the Largest of Two Numbers

num1 = int(input("Enter the first number: "))


num2 = int(input("Enter the second number: "))

if num1 > num2:


print("The first number is larger.")
elif num1 < num2:
print("The second number is larger.")
else:
print("Both numbers are equal.")

5. Grade Calculation Based on Marks

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

if marks >= 90:


print("Grade: A")
elif marks >= 75:
print("Grade: B")
elif marks >= 50:
print("Grade: C")
else:
print("Grade: D")

You might also like