0% found this document useful (0 votes)
3 views12 pages

Artificial Intelligence

The document contains a series of Python programs that demonstrate basic arithmetic operations, calculating simple interest, and determining eligibility for voting. It also includes programs for geometric calculations such as area and perimeter of rectangles and squares, as well as checking if numbers are odd or even, positive or negative, and comparing two numbers. Each program includes user input and prints the results to the console.

Uploaded by

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

Artificial Intelligence

The document contains a series of Python programs that demonstrate basic arithmetic operations, calculating simple interest, and determining eligibility for voting. It also includes programs for geometric calculations such as area and perimeter of rectangles and squares, as well as checking if numbers are odd or even, positive or negative, and comparing two numbers. Each program includes user input and prints the results to the console.

Uploaded by

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

Artificial

Intelligence
PYTHON
PROGRAMS
1) Program to perform all arythematic
operations
o a=int(input("Enter first number :"))
o b=int(input("Enter second number :"))
o sum=a+b
o dif=a-b
o mul=a*b
o quo=a/b
o rem=a%b
o exp=a**b
o print("Sum is : ",sum)
o print("Difference is : ",dif)
o print("Product is : ",mul)
o print("Quotient is : ",quo)
o print("Remainder is : ",rem)
o print("Exponent is : ",exp)
2) Program to power entering two numbers

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


o b=int(input("Enter second number :"))
o pow = a**b
o print("Power is : ",pow)
3) Program to find Simple Interest
• p=int(input("Enter principle :"))
• r=int(input("Enter rate of interest :"))
• t=int(input("Enter time : "))
• si= (p*r*t)/100
• print("Simple Interest is : ",si)
4) Program to find area and perimeter of
rectangle
• l = float(input("Enter length : "))
• b = float(input("Enter breadth :"))
• area = l * b
• perimeter = 2*(l+b)
• print("Area of rectangle is : ",area)
• print("Perimeter of rectangle is :",perimeter)
5) Program to find area and perimeter of
square

• s = float(input("Enter side : "))


• area = s * s
• perimeter = 4 * s
• print("Area of square is : ",area)
• print("Perimeter of square is :",perimeter)
6) Program to enter and print your name
and age

• n= input("Enter name : ")


• age = input("Enter age :")
• print ("Hello ! " , n , " your age is
",age)
7) Program to find if person is Eligible to
Vote or not

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


• if (age) >= 18 :
• print ("Eligible to vote ")
• else :
• print("Not eligible to vote ")
8) Program to find whether number is
odd or even

• n= int(input("Enter a number :
"))
• if (n%2)==0:
• print(n , " is Even number")
• else:
• print(n , " is Odd number“)
9) Program to subtract smaller number
from larger
number

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


• b= int(input("Enter second number :
"))
• if a>b :
• dif=a-b
• else :
• dif = b -a
• print("Difference is : " , dif)
10) Program to find if number is Positive,
Negative
or Zero

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


• if (n)> 0:
• print(n , " is Positive number")
• elif (n)==0:
• print(n , " is zero")
• else :
• print(n , " is negative")
11) Program to find larger , smaller or
equal
out of two number

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


• b= int(input("Enter second number :
"))
• if a>b :
• print(a ," is larger than b. ")
• elif a==b :
• print(a ," is equal to b. ")
• else:
• print(a ," is smaller than b. ")

You might also like