0% found this document useful (0 votes)
14 views23 pages

IP Jigyashu Patel

The document contains a series of Python programs submitted by a student for the subject 'Informatics Practices'. Each program addresses different computational tasks such as calculating simple interest, the perimeter and area of a triangle, and checking divisibility, among others. The document includes code snippets, expected outputs, and user prompts for input.

Uploaded by

ashugamerz1988
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)
14 views23 pages

IP Jigyashu Patel

The document contains a series of Python programs submitted by a student for the subject 'Informatics Practices'. Each program addresses different computational tasks such as calculating simple interest, the perimeter and area of a triangle, and checking divisibility, among others. The document includes code snippets, expected outputs, and user prompts for input.

Uploaded by

ashugamerz1988
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/ 23

PYTHON PROGRAMS

Submitted For
Subject “Informatics Practices”
Subject Code: 065

Session 2024-25

Submitted By:
Students Name: Jigyashu.A.Patel

Class: XI Science

CBSE Roll no: _

Submitted To:
Ms,Shruti ma’am
Program 1

Que. Write a Python program to calculate the amount payable if money has

been lent on simple interest .Principal or money lent = P, Rate of interest =

R% per annum and Time = T years. Then simple interest (SI ) = (P X R X T)

/100. Amount payable = Principal + SI .

P , R and T are given as input to the program.

#Code:-

P=float(input(“Enter money lent:”))

R=float(input(“Enter rate of interest:”))

T=float(input(“Enter time in years:”))

SI=(P*R*T)/100

Amount_payable=P+SI

Print(“Amount payable is:Rs.”,amount payable)

#Output

Enter money lent:7000

Enter a rate of interest:8.5

Enter tume in years:3.5

Amount_payable is:Rs.9082.5
Program 2

Que. Write a program to calculate the perimeter , area of a triangle.

#Code:-

#To calculate perimeter& area of triangle

print(“Menu”)

print(“1.Perimeter of triangle”)

print(“2.Area of triangle”)

choice=int(input(“Enter a choice:”))

if choice==1:

a=int(input(“Enter a side 1:”)

b=int(input(“Enter a side 2:”)

c=int(input(“Enter a side 3:”)

print(“Perimeter of triangle=”,a+b+c)

if choice==2:

h=int(input(“Enter height of triangle:”))

b=int(input(“Enter base of triangle:”))

print(“Area of triangle=”,1/2*b*h)

else:

print(“Enter a valid choice“)


#Output

Menu

1.Perimeter of triangle

2. Area of triangle

Enter a choice:1

Enter a side 1:3

Enter a side 2: 4

Enter a side 3:5

Perimeter of the Triangle=12

Enter a choice: 2

Enter height of triangle: 2

Enter base of triangle: 5

Area of triangle= 5

Enter a choice: 3

Enter a valid choice

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 3

Write a program to find sale price of an item with given price and discount

#Code:-

p= float(input(“Enter a prince:”))

dp= float(input(“Enter discount %:”))

discount=p*dp/100

sp=p-discount

print(“Cost_price=”,p)

print(“Discount=”,discount)

print(“Selling_price”,sp)

#Output

Enter price:7200

Enter discount%:12

Cost price=7200.0

Discount: 864.0

Selling price 6336.0

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 4

Write a program to Calculate Compound interest


#Code:-

Import math

prin= float(input(“Principal Amount:”))

rate= float(input(“Rate of interest:”))

time= float)input(“Time (in years):”))

smt=prin*(math.pow((1+rate/100),time))

ci= amt-prin

print(“Compound interest is”,ci

#Output

Principal Amount: 12500

Rate of Interest: 8

Time (in years): 3

Compund interest is 3246.4000000000015

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 5

Write a program to test the divisibility of a number with another number

(ie. If a number is divisible by another number)

#Code:-

No_1=int(input(“Enter first number:”))

No_2=int(input(“Enter second number”))

Remainder= No_1%No_2

If remainder ==0:

print(No_1,”is divisible by”,No_2)

else:

print(No_1”is not divisible by”,No_2)

#Output

Enter first number: 115

Enter second number:3

115.0 is not divisible by3.0

Enter first number:119

Enter second number: 17

117.0 is divisible by 17.0


Enter first number:1234.30

Enter second number: 5.5

1234.3 is not divisible by 5.5

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 6

Write a python program to display a menu for calculating area of a circle


or perimeter of a circle
#Code:-

R= float(input(“Enter radius of the circle:”))

print(“1. Calculate Area”)

print(“2.Calculate perimeter”)

ch=int(input(“Enter a choice(1 or 2):”))

if ch==1:

area=3.14*R**2

print(“Area of circle with radius,”,radius,’is’,area)

else:

perm=2*3.14*R

print(“Perimeter of the circle with radius”’,R ,’is’perm)

#Output

Enter radius of the circle:2.5

1. Calulate Area
2. Calculate Perimeter

Enter your choice(1 or2): 1

Area of circle with radius 2.5 is 19.6349375


Enter radius of the circle:2.5

1. Calulate Area
2. Calculate Perimeter

Enter your choice(1 or2): 2

Perimeter of circle with radius 2.5 is 15.707595

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 7

Write a program to input two integers x and n, compute x n using a loop.

#Code:-

x= int(input(“Enter a positive number(x):”))

n= int(input(“Enter the power (n):”))

for a in range(n):

power =power*x

print(x,”to the power”, n ,”is”,power)

#Output

Enter a positive number(x):7

Enter the power (n): 3

7 to the power 3 is 343

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 8

Write a program that takes the name and age of the user as input and

displays a message whether the user is eligible to apply for a diving license

or not( the eligible age is 18 years )

#Code:-

name=input(“Enter name:”)

age= int(input(“Enter age:”)

if age>=18:

print(name, “is eligible for driving license.”)

else:

print(name, “is not eligible for driving license.”)

#Output

Enter name: Jigyashu

Enter age:18

Jigyashu is eligible for driving license.

Enter name :Ashutosh

Enter age: 17

Ashutosh is not eligible for driving license.

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 9

Write a program to find the largest / smallest value of asset in a given list

of assets of a company.

#Code:-

val =eval(input(“Enter list of assests”))

print(“This list is :”val)

mx=max(val)

mn=min(val)

print(“Biggest Asset:”,max)

print(“Biggest Asset:”,min)

#Output

Enter list of assets:[23,11,56,7,12,45]

The list is: 23,11,56,7,12,45]

Biggest Asset : 56

Smallest Asset: 7

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 10

Write a program to read Roll numbers and marks of four students and

create a dictionary from it having Roll numbers as keys. Also check if roll

number 2 has scored more than 75 marks.

#Code:-

rno =[ ]

mks = [ ]

for a in range(4):

r,m =eval(input(“Enter Roll no.,Marks”))

rno.append(r)

mks.append(m)

d={ rno[0]:mks[0], rno[1]:mks[1], rno[2]:mks[2], rno[3]:mks[3] }

print(“Created dictionary”)

print(d)

if d[2]>75:

print(“Roll number 2 scored”, d[2], “(>75)”)

else:

print(“Roll number 2 scored”, d[2], “(<75)”)


#Output

Enter Roll no. , Marks : 1,67.5

Enter Roll no. , Marks : 2,45.6

Enter Roll no. , Marks : 3,78.3

Enter Roll no. , Marks : 4,70

Creates dictionary

{1 : 67.5 , 2 : 45.6 , 3 : 78.3 , 4 : 70.5}

Roll number 2 scored 45.6 (<75)

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 11

Write a program to create a dictionary to store names of states and

their capitals.

#Code:-

stCap= { }

n = int(input(“How many capitals you want to store?”))

for i in range(n):

st =input(“Enter state:”)

cap =input(“Enter capital:”)

stCap[st] = cap

print(“States and their capitals are:”)

print(stCap)

#Output

How many capitals you want to store? 3

Enter state: Maharashtra

Enter capital: Mumbai

Enter state: Gujarat

Enter capital: Gandhinagar

Enter state: Karnataka

Enter capital: Bengluru

States and their capital are:

{‘Mahrashtra’: ‘Mumbai’ , ‘Gujarat’: ‘Gandhinagar’ , ‘Karnataka’ , ‘Bengluru’}


Program 12

Write a python program to find the highest 2 values in a dictionary.

#Code:-

nos = {31:111, 22:222 ,43:333, 14:444, 25:555}

print(“Given dictionary is:”,numbers)

print(“Highest two values of given dictionary are:”,s[-1], s[-2])

#Output

Given dictionary is: {31:111 ,22:222, 43:333 , 14:444, 25:555}

Highest two values of the given dictionary are : 555 444

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 13

#Code:-

Consider already created dictionary M that stores roll numbers and marks.
Write a program to input a roll number and delete it from the dictionary.
Display error and delete it from the dictionary, display error message if the roll
number does not exist in the dictionary.

L1 =[17,24,15,30,34,27]

L2=L1.copy( )

print(“Original list :”,L1)

print(“Created copy of the list :”,L2)

L2[0]+=10

L2[-1]+=10

print(“copy of the list after changes:”,L2)

print(“Original list:”,L1)

#Output

Original list: [17, 24, 15, 30, 34, 27]

Created copy of the list : [17, 24, 15, 30, 34, 27]

Copy of the list after changes: [27, 24,15 ,30, 34, 37]

Original list : [17, 24, 15, 30, 34, 27]

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 14

Program to find the minimum element from a list of element along with its
index in the list.

lst = eval(input(“Enter list:”))

length =len(lst)

min_ele =lst[0]

min_index=0

for I in range(1, length):

if lst[i] < min_ele:

min_ele = lst[i]

min_index = i

print(“Given list is:”, lst)

print(“The minimum element of the given list is:”)

print(“min_ele, “at index” , min_index)

#Output

Enter a list : [2, 3, 4, -2, 6, -7, 8, 11, -9 ,11]

Given list is : [2, 3, 4, -2, 6, -7, 8, 11, -9 ,11]

The minimum element of the given list is:

-9 at index 8
Program 15

Write a program that inputs a list, replicates it twice and the prints the sorted
list in ascending and descending orders.

val = eval(input(“Enter a list:”))

print(“Original list :”,val)

val =val*2

print(“Replicated list:”, val)

val.sort( )

print(“Sorted in ascending order :”, val)

val.sort(reverse=True)

print(“Sorted in descending order :”, val)

#Output

Enter a list: [23, 11, 29]

Original list : [23, 11, 29]

Replicated list : [23, 11, 29, 23, 11, 29]

Sorted in Ascending order : [11, 11, 23, 23, 29, 29]

Sorted in Descending order: [29, 29, 23, 23, 11, 11]

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Program 16

Write a program to input a roll number and delete it from the dictionary.
Display error message if the roll number does not exist the dictionary.

#Code:-

rno =[ ]

mks = [ ]

for a in range(4):

r,m =eval(input(“Enter Roll no.,Marks”))

rno.append(r)

mks.append(m)

d={ rno[0]:mks[0], rno[1]:mks[1], rno[2]:mks[2], rno[3]:mks[3], rno[4]:mks[4] }

print(“Created dictionary”)

print(d)

rno=int(input(“Roll No. to deleted ?:”))

if rno in d:

del d[rno]

print(“Roll no .”, rno, “deleted from the dictionary.”)

else:

print(“Roll no.”, rno, “does not exist in dictionary.”)

print(“Final dictionary”)

print(d)
#Output

Enter Roll no. , Marks : 1,67.5

Enter Roll no. , Marks : 2,45.6

Enter Roll no. , Marks : 3,78.3

Enter Roll no. , Marks : 4,70

Enter Roll no., Marks : 5,89.9

Created dictionary

{1 : 67.5, 2 : 45.6, 3 : 78.3, 4: 70, 5: 89.9}

Roll No. to be deleted? :5

Roll No. 5 deleted from dictionary

Final Dictionary

{1 : 67.5, 2 : 45.6, 3 : 78.3, 4: 70}

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

You might also like