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

IX AI Python Programs - PT2

The document contains a series of Python programs that perform various tasks such as calculating simple interest, area and perimeter of a circle, basic arithmetic operations, checking if a number is positive or negative, determining if a year is a leap year, and more. Each program includes user input prompts and example outputs demonstrating the functionality. The programs cover fundamental programming concepts and conditional statements.

Uploaded by

Arnav Muluk
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 views4 pages

IX AI Python Programs - PT2

The document contains a series of Python programs that perform various tasks such as calculating simple interest, area and perimeter of a circle, basic arithmetic operations, checking if a number is positive or negative, determining if a year is a leap year, and more. Each program includes user input prompts and example outputs demonstrating the functionality. The programs cover fundamental programming concepts and conditional statements.

Uploaded by

Arnav Muluk
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

IX AI Python Programs

1. # WAP to find simple interest


P=float(input("Enter Principal value: "))
R=float(input("Enter the rate of interest: "))
T =float(input("Enter duration in year: "))
Simple_interest = (P * R * T) / 100
print("The simple interest is:", Simple_interest)

output:
Enter Principal value: 200000
Enter the rate of interest: 5.4
Enter duration in year: 4
The simple interest is: 43200.0

2. # WAP to calculate area and perimeter of circle

r=float(input("Enter the radius: "))


pi=3.14
area_circle=pi*r*r
p=2*pi*r
print("Area of circle is:",area_circle)
print("perimeter of circle is:",p)

output:
Enter the radius: 5.6
Area of circle is: 98.4704
perimeter of circle is: 35.168

3. # WAP for maths operators.

a=int(input("Enter value of a: "))


b=int(input("Enter value of b: "))
add=a+b
sub=a-b
mul=a*b
div=a/b
print("The addition of a and b is:",add)
print("The subtraction of a and b is:",sub)
print("The addition of a and b is:",mul)
print("The addition of a and b is:",div)
output:
Enter value of a: 23
Enter value of b: 14
The addition of a and b is: 37
The subtraction of a and b is: 9
The addition of a and b is: 322
The addition of a and b is: 1.6428571428571428

4. #WAP to check number is positive or negative

n=int(input("Enter number to check whether it is positive or negative: "))


if n>0:
print("Number is positive integer ")
else:
print("Number is a negative integer")

output:
Enter number to check whether it is positive or negative: -5
Number is a negative integer

5. # WAP to check number is odd or even

n=int(input("Enter number: "))


if n%2==0:
print("Number is even")
else:
print("number is odd")

output:
Enter number: 55
number is odd

6. #WAP to check wheather year is leap year or not?

year = int(input("Enter year to check:"))


if (year%4==0 and year%100!=0) or (year%400==0):
print("Year is a leap year")
else:
print("Year is not a leap year")
output:
Enter year to check:2016
Year is a leap year

7. #WAP to check triangle is formed or not

a=int(input("Enter angle 1. "))


b=int(input("Enter angle 2. "))
c=int(input("Enter angle 3. "))
if a+b+c==180:
print("it can form a triangle..")
else:
print("Can not form a triangle..")

output:
Enter angle 1. 56
Enter angle 2. 44
Enter angle 3. 53
Can not form a triangle..

8. # WAP to check user is eligible to vote or not?

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


if age >=18:
print("Eligible for Voting")
else:
print("Not eligible for voting")

output:
Enter your age 30
Eligible for Voting

9. #WAP to check grade with elif loop.

per=float(input("Enter percentage: "))


if per>90:
print("Congratulation!! You secured A grade..")
elif per<=90 and per>70:
print("Congratulation!! You secured B grade..")
elif per<=70 and per>50:
print("Good! You secured C grade..")
else:
print("Study hard!!You secured D grade..")

output:
Enter percentage: 67
Good! You secured C grade..

10. # WAP to check digits in number

n = int(input("Enter any number:"))


if n>0 and n<10:
print("One digit number")
elif n>10 and n<100:
print("Two digit number")
elif n>100 and n<1000:
print("Three digit number")
else:
print("More than three digit number")

output:
Enter any number:1200
More than three digit number

You might also like