0% found this document useful (0 votes)
25 views21 pages

AI Project File

The document contains a series of Python programs demonstrating various programming concepts such as data structures, arithmetic operations, user input, conditional statements, and loops. Each program is followed by its output, showcasing functionalities like calculating simple interest, finding areas, and determining grades based on marks. The programs serve as practical examples for learning Python programming.

Uploaded by

aryan.z51700
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)
25 views21 pages

AI Project File

The document contains a series of Python programs demonstrating various programming concepts such as data structures, arithmetic operations, user input, conditional statements, and loops. Each program is followed by its output, showcasing functionalities like calculating simple interest, finding areas, and determining grades based on marks. The programs serve as practical examples for learning Python programming.

Uploaded by

aryan.z51700
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

PROGRAM 1

Dict = (1:'Aniket', 2:'India', 3:'LAEMS')


print(Dict)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Dict = 1:'Aniket', 2:'India', 3:'LAEMS'
PROGRAM 2
number=100
height=157
name="Aniket"
print(number)
print(height)
print(name)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
100
157
Aniket
PROGRAM 3
#Program to calculate simple interest
principal= 20000000
rate= 6
time= 4
simple_interest=(principal*rate*time)/100
print(simple_interest)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
simple_interest = 4800000.0
PROGRAM 4
#Program to calculate perimeter of square
side=45
perimeter=4*side
print(perimeter)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
perimeter = 180
PROGRAM 5
# Input a number and find its cube

Num = float(input("Enter the number:"))

cube = Num ** 3

print(f"The cube of {Num} is {cube}")

OUTPUT
%runfile C:/Users/Aniket/[Link] --wdir
Enter the number:5
The cube of 5.0 is 125.0
PROGRAM 6
#Accept the number and then print a table for that number

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

print("Multiplication table for",num)

print(num,"x 1 =",num * 1)
print(num,"x 2 =",num * 2)
print(num,"x 3 =",num * 3)
print(num,"x 4 =",num * 4)
print(num,"x 5 =",num * 5)
print(num,"x 6 =",num * 6)
print(num,"x 7 =",num * 7)
print(num,"x 8 =",num * 8)
print(num,"x 9 =",num * 9)
print(num,"x 10 =",num * 10)

OUTPUT
%runfile C:/Users/Aniket/[Link] --wdir
Enter the number:15
Multiplication table for 15
15 x 1 = 15
15 x 2 = 30
15 x 3 = 45
15 x 4 = 60
15 x 5 = 75
15 x 6 = 90
15 x 7 = 105
15 x 8 = 120
15 x 9 = 135
15 x 10 = 150
PROGRAM 7
#ask for the user's name and greet

name=input("What is your name?")


print("Hello," + name + "!Nice to meet you.")

OUTPUT
%runfile C:/Users/Aniket/[Link] --wdir
What is your name?Aniket
Hello,Aniket. Nice to meet you.
PROGRAM 8
#ask the user his name, and class and greet and also mention class

name=input("What is your name?")


student_class=input("Which class are you in?")

print("Hello,"+name+"!Welcome to class,"+student_class+"!")

OUTPUT
%runfile 'Y:/Aniket Amin Python program/[Link]' --wdir
What is your name?Aniket
Which class are you in? 10
Hello,Aniket!Welcome to class,10!
PROGRAM 9
#ask user for the length of side of square to find its area

length_of_square=float(input("What is the length of side of square"))


area_of_square=length_of_square**2

print("The area of square is",area_of_square)

OUTPUT
%runfile 'Y:/Aniket Amin Python program/[Link]' --wdir
What is the length of side of square 8
The area of square is 64.0
PROGRAM 10
#ask user radius of circle and print its area

radius=float(input("Enter the radius of circle="))


area_of_circle=22/7*radius**2

print("area of circle=",area_of_circle)

OUTPUT
%runfile 'Y:/Aniket Amin Python program/[Link]' --wdir
Enter the radius of circle=7
area of circle= 154.0
PROGRAM 11
#accept distance in miles and convert it into km

miles=float(input("Enter the distance in miles="))


km=miles*1.069

print("Distance in km is=",km)

OUTPUT
%runfile 'Y:/Aniket Amin Python program/[Link]' --wdir
Enter the distance in miles=10
Distance in km is= 10.
PROGRAM 12
#read height in centimeter and convert it into feet and inches

centimeter=float(input("Enter height in centimeter="))


inches=centimeter/2.54
feet=centimeter/2.54/12
feet=inches/12

print("Height in inches=",inches)
print("Height in feet=",feet)

OUTPUT
%runfile 'Y:/Aniket Amin Python program/[Link]' --wdir
Enter height in centimeter=254
Height in inches= 100.0
Height in feet= 8.333333333333
PROGRAM 13
#Accept the length and breadth of a rectangle and display the area and
perimeter
length = float(input("Enter the length of rectangle"))
breadth = float(input("Enter the breadth of rectangle"))

area = length*breadth
print("The area of rectangle is=",area)

Perimeter = 2*length+2*breadth
Perimeter1 = 2*(length+breadth)
print("The Perimeter of rectangle is=",Perimeter)
print("The Perimeter1 of rectangle is=",Perimeter1)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the length of rectangle79
Enter the breadth of rectangle69
The area of rectangle is= 5451.0
The Perimeter of rectangle is= 296.0
The Perimeter1 of rectangle is= 296.0
PROGRAM 14
#Accept two numbers and display the remainders

num1 = float(input("Enter the first number="))


num2 = float(input("Enter the second number="))
remainder = num1 % num2

print("The remainder is=",remainder)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the first number= 23.5
Enter the second number= 68.9
The remainder is= 23.5
PROGRAM 15
#Check if number is equal to 500

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

if number == 500:
print("You got a Five hundred")

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter a number=500
You got a Five hundred
PROGRAM 16
#Print the largest of three numbers using if

num1 = float(input("Enter the first number="))


num2 = float(input("Enter the second number="))
num3 = float(input("Enter the third munber="))

largest = num1

if num2 > largest:


largest = num2

if num3 > largest:


largest = num3

print("The largest number is",largest)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the first number=54
Enter the second number=67
Enter the third number=57
The largest number is 67.0
PROGRAM 17
#Check if the age is greater than 18,print you are eligible to vote else
print you are not 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")

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter your age=45
You are eligible to vote

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter your age=14
You are not eligible to vote
PROGRAM 18
# Accept number to check if it is even or odd
number = int(input("Enter the number="))

if number % 2 == 0:
print("The number is even")

else:
print("The number is odd")

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the number=96
The number is even

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter the number=987
The number is odd
PROGRAM 19
# Check if number is greater to or equal to another number

number1 = float(input("Enter the first number ="))


number2 = float(input("Enter the second number ="))

if number1 > number2:


print("The first number is greater than the second number")

elif number1 < number2:


print("The first number is smaller than the second number")

else:
print("The first number is equal to the second number")

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the first number =65
Enter the second number =45
The first number is greater than the second number

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter the first number =67
Enter the second number =89
The first number is smaller than the second number

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter the first number =89
Enter the second number =89
The first number is equal to the second number
PROGRAM 20
# Accept marks in three subjects and assign marks accordingly

subject1 = float(input("Enter the marks of subject1 ="))


subject2 = float(input("Enter the marks of subject2 ="))
subject3 = float(input("Enter the marks of subject3 ="))

Total_marks = 300
Marks_obtained = subject1 + subject2 + subject3
percentage = Marks_obtained/Total_marks*100

if percentage >= 90:


grade = "A"

elif percentage >= 80:


grade = "B"

elif percentage >= 70:


grade = "C"

else:
grade = "D"

print("Percentage =",percentage)
print("Grade =",grade)

OUTPUT
%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir
Enter the marks of subject1 =70
Enter the marks of subject2 =67
Enter the marks of subject3 =89
Percentage = 75.33333333333333
Grade = C

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter the marks of subject1 =90
Enter the marks of subject2 =97
Enter the marks of subject3 =99
Percentage = 95.33333333333334
Grade = A

%runfile C:/Users/Aniket/.spyder-py3/[Link] --wdir


Enter the marks of subject1 =86
Enter the marks of subject2 =97
Enter the marks of subject3 =65
Percentage = 82.66666666666667
Grade = B

You might also like