0% found this document useful (0 votes)
8 views3 pages

School Program

The document contains multiple Python programs that perform various calculations and tasks. These include calculating costs for gold ornaments, swapping numbers, finding the smallest of three numbers, calculating final velocity, comparing compound and simple interest, converting days to years/months/days, finding the area of a scalene triangle, summing digits of a three-digit number, and displaying rational numbers between two consecutive natural numbers. Each program prompts the user for input and outputs the result of the calculation.
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)
8 views3 pages

School Program

The document contains multiple Python programs that perform various calculations and tasks. These include calculating costs for gold ornaments, swapping numbers, finding the smallest of three numbers, calculating final velocity, comparing compound and simple interest, converting days to years/months/days, finding the area of a scalene triangle, summing digits of a three-digit number, and displaying rational numbers between two consecutive natural numbers. Each program prompts the user for input and outputs the result of the calculation.
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

# A program to calculate the actual cost, making charges, discount and amount to be paid (4th

Program)

p = int(input("Enter Gold price/gm: "))


w = float(input("Enter weight of the ornament: "))
acost = p * w
charge = acost * 20 / 100
dis = charge * 30 / 100
amt = acost + charge - dis
print("Actual cost:", acost)
○ print("Actual making charge:", charge)
print("Discount on making charge:", dis)
print("Amount to be paid:", amt)

# A program to swap two numbers (5th Program)

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


b = int(input("Enter second number: "))
a=a+b
b=a-b
a=a-b
print("After swapping a =", a)
print("After swapping b =", b)

# A program to display the smallest number among three numbers (6th Program)

n1 = int(input("Enter first number: "))


n2 = int(input("Enter second number: "))
n3 = int(input("Enter third number: "))
c = min(n1, n2)
p = min(n3, c)
print("Smallest Number =", p)

# A program to calculate final velocity (7th Program)

import math
u = int(input("Enter initial velocity: "))
a = int(input("Enter acceleration: "))
s = int(input("Enter distance covered: "))
v = math.sqrt(pow(u, 2) + 2 * a * s)
print("Final Velocity =", v)
# A program to find the difference between Compound Interest and Simple Interest (8th
Program)

p = int(input("Enter Principal: "))


r = int(input("Enter Rate: "))
t = int(input("Enter Time: "))
si = (p * r * t) / 100
amt = p * (pow((1 + r / 100), t))
ci = amt - p
diff = ci - si
print("The Compound Interest =", ci)
print("The Simple Interest =", si)
print("The difference between C.I and S.I =", diff)

# A program to convert days into years, months and the number of days (9th Program)

d = int(input("Enter number of days: "))


y = d // 365
b = d % 365
m = b // 30
d = b % 30
print("The number of years =", y)
print("The number of months =", m)
print("The number of days =", d)

# A program to find the area of a scalene triangle (10th Program)

import math
a = int(input("Enter first side: "))
b = int(input("Enter second side: "))
c = int(input("Enter third side: "))
s = (a + b + c) / 2
ar = math.sqrt(s * (s - a) * (s - b) * (s - c))
print("The area of scalene triangle =", ar)

# A program to find the sum of the first and third digit of a three digit number (11th Program)

n = int(input("Enter a three digit number: "))


n1 = n // 100
n2 = n % 100
n3 = n2 % 10
s = n1 + n3
print("The sum of first and third digit =", s)

# A program to display three rational numbers between any two consecutive natural numbers
(12th Program)

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


n = int(input("Enter next consecutive number: "))
a = (m + n) / 2
b = (m + a) / 2
c = (a + n) / 2
print("Three rational numbers are:")
print(b)
print(a)
print(c)

You might also like