0% found this document useful (0 votes)
5 views15 pages

Ip Project

The document contains a series of Python code snippets that perform various tasks such as calculating grades based on marks, computing selling prices after discounts, calculating the area and perimeter of rectangles, and determining simple interest. It also includes functionalities for identifying perfect numbers, finding the smallest and largest numbers in a list, and counting occurrences of a number in a list. Additionally, there are examples of collecting state and capital pairs and student data with their respective marks.

Uploaded by

Swetha Karthik
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)
5 views15 pages

Ip Project

The document contains a series of Python code snippets that perform various tasks such as calculating grades based on marks, computing selling prices after discounts, calculating the area and perimeter of rectangles, and determining simple interest. It also includes functionalities for identifying perfect numbers, finding the smallest and largest numbers in a list, and counting occurrences of a number in a list. Additionally, there are examples of collecting state and capital pairs and student data with their respective marks.

Uploaded by

Swetha Karthik
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/ 15

1) Input :

sub1 = float(input("Enter marks for subject 1: "))


sub2 = float(input("Enter marks for subject 2: "))
sub3 = float(input("Enter marks for subject 3: "))
sub4 = float(input("Enter marks for subject 4: "))
sub5 = float(input("Enter marks for subject 5: "))

total= sub1 + sub2 + sub3 + sub4 + sub5


avg= total / 5
if avg >= 90:
print ('Your grade is : A')
elif avg >= 80 and avg <90:
print ('Your grade is : B')
elif avg >= 70 and avg<80:
print ('Your grade is : C')
elif avg >= 60 and avg<70:
print ('Your grade is : D')
else:
print ('Your grade is : E')

print ('Your total is :',total )


print ('Your average is :',avg)

Output :
2) Input
cost = float(input("Enter the cost price: "))
perc = float(input("Enter the discount percentage: "))

amount = (perc / 100) * cost

sell = cost - amount

print("Cost Price: " ,cost)


print("Discount Amount: ",amount)
print("Selling Price: ",sell)

Output :
3) Input :
l = float(input("Enter the length of the rectangle: "))
b = float(input("Enter the breadth of the rectangle: "))

area = l * b
peri = 2 * (l + b)

print("\nResults:")
print("Area of the rectangle: ", area)
print("Perimeter of the rectangle: ", peri)

Output :
4) Input :
amount = float(input("Enter the principal amount: "))
time = float(input("Enter the time : "))
rate = float(input("Enter the rate of interest : "))

SI = amount * time * rate / 100

print("Principal Amount: " , amount)


print("Time: ",time, "years")
print("Rate of Interest: " , rate)
print("Simple Interest: " ,SI)

Output :
5) Input :
cost = float(input("Enter the cost price: "))
selling= float(input("Enter the selling price: "))

if selling > cost:


profit = selling - cost
print("\nProfit: ", profit)
elif cost > selling:
loss = cost - selling
print("\nLoss: ", loss)
else:
print("\nNo Profit, No Loss")

Output :
6) Input :

selling = float(input("Enter the selling price: "))


gstrate = float(input("Enter the GST rate (in %): "))

gst = (gstrate / 100) * selling

cgst = gst / 2

print("Selling Price: ",selling)


print("GST: ", gst)
print("CGST: ", cgst)

Output :
7) Input :
num = int(input("Enter a number: "))

sum1 = 0

for i in range(1, num):


if num % i == 0:
sum1 += i

if sum1 == num:
print(num," is a perfect number.")
else:
print(num," is not a perfect number.")

Output :
8) Input :

numbers = input("Enter a list of integers separated by spaces: ").split()


numbers = [int(num) for num in numbers]

small = min(numbers)
large = max(numbers)

print("Smallest number: ",small)


print("Largest number: ", large)

Output :
9) Input :

num =list(map(int, input("Enter integers separated by spaces: ").split()))

if len(num) < 3:
print("The list must contain at least three numbers.")
else:
num.sort(reverse=True)

thirdlarge = num[2]

print("The third largest number is: ", thirdlarge)

Output :
10) Input :
sums = 0

for num in range(1, 101):


sums += num ** 2

print("The sum of squares of the first 100 natural numbers is: ",sums)

Output :
11) Input :

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

n = int(input("Enter how many multiples you want: "))

print("\nThe first",n," multiples of ",num, "are:")


for i in range(1, n + 1):
print(num, "x ",i," = ",num * i)

Output :
12) Input :

numb = input("Enter a list of integers separated by spaces: ").split()


numb = [int(num) for num in numb]

n = int(input("Enter the number to count: "))

count = numb.count(n)

print("The number ",n," occurs ",count," time(s) in the list.")

Output :

13) Input :
statecap = {}
print("Enter the names of 10 states and their capitals:")

for i in range(10):
state = input(f"Enter the name of state {i + 1}: ")
capital = input(f"Enter the capital of {state}: ")
statecap[state] = capital

print("\nState and Capitals:")


for state, capital in statecap.items():
print(state,':' ,capital)

Output :
14) Input :

students = {}
num = int(input("Enter the number of students: "))

for i in range(num):
print(f"\nEntering data for student {i + 1}:")
name = input("Enter the name of the student: ")
marks = {}

for j in range(1, 6):


subject = input(f"Enter the name of subject {j}: ")
mark = float(input(f"Enter marks for {subject}: "))
marks[subject] = mark

students[name] = marks

print("\nStudent Data:")
for name, marks in students.items():
print(name,':' ,marks)

Output :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy