0% found this document useful (0 votes)
6 views5 pages

Python Programs

Uploaded by

janavpatel13
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)
6 views5 pages

Python Programs

Uploaded by

janavpatel13
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/ 5

import math

# Input: Radius of the circle


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

# Calculating the area of the circle


area = (22/7) * radius ** 2

# Calculating the circumference of the circle


circumference = 2 * (22/7) * radius

# Displaying the results


print(f"The area of the circle is: {area:.2f}")
print(f"The circumference of the circle is:
{circumference:.2f}")

# Input: Principal, Rate of Interest, and Time


principal = float(input("Enter the principal amount:
"))
rate = float(input("Enter the rate of interest (in %): "))
time = float(input("Enter the time period (in years):
"))

# Calculating Simple Interest (SI)


simple_interest = (principal * rate * time) / 100

# Calculating Compound Interest (CI)


# Compound Interest formula: A = P * (1 + r/n)^(nt),
where n is the number of times interest is
compounded per year
# Assuming interest is compounded annually (n=1)
compound_interest = principal * (1 + rate / 100) **
time - principal

# Displaying the results


print(f"\nSimple Interest (SI) = {simple_interest:.2f}")
print(f"Compound Interest (CI) =
{compound_interest:.2f}")
# Input: Student's name and marks for 5 subjects
name = input("Enter the student's name: ")

marks = []
total_marks = 0
max_marks = 50

# Input marks for 5 subjects


for i in range(1, 6):
mark = float(input(f"Enter marks for subject {i} (out
of {max_marks}): "))
if mark < 0 or mark > max_marks:
print("Invalid marks! Marks should be between 0
and 50.")
mark = float(input(f"Re-enter marks for subject
{i} (out of {max_marks}): "))
marks.append(mark)
total_marks += mark
# Calculate the percentage
total_max_marks = max_marks * 5 # Maximum
possible marks (5 subjects, each of max 50)
percentage = (total_marks / total_max_marks) * 100

# Display the result


print(f"\nStudent's Name: {name}")
print(f"Marks obtained: {total_marks} /
{total_max_marks}")
print(f"Percentage: {percentage:.2f}%")

# Input: Length and Breadth of the rectangle


length = float(input("Enter the length of the
rectangle: "))
breadth = float(input("Enter the breadth of the
rectangle: "))

# Calculate the area of the rectangle


area = length * breadth
# Display the result
print(f"The area of the rectangle is: {area:.2f}")

You might also like