-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometricAndArithmeticOperations.py
More file actions
68 lines (57 loc) · 2.06 KB
/
Copy pathGeometricAndArithmeticOperations.py
File metadata and controls
68 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import math
def calculateShapesArea():
side = float(input("Enter side of the square: "))
print(f"Area of Square: {side**2}")
length = float(input("Enter length of rectangle: "))
width = float(input("Enter width of rectangle: "))
print(f"Area of Rectangle: {length * width}")
def calculateCircleProperties():
radius = float(input("Enter radius of circle: "))
print(f"Area: {math.pi * radius**2}")
print(f"Circumference: {2 * math.pi * radius}")
def swapWithTemp():
a = input("Enter first number: ")
b = input("Enter second number: ")
temp = a
a = b
b = temp
print(f"Swapped: a={a}, b={b}")
def swapWithoutTemp():
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
a, b = b, a
print(f"Swapped: a={a}, b={b}")
def convertDaysToTime():
total_days = int(input("Enter total days: "))
years = total_days // 365
months = (total_days % 365) // 30
days = (total_days % 365) % 30
print(f"{years} Years, {months} Months, {days} Days")
def calculateSalary():
basic = float(input("Enter Basic Salary: "))
da = 0.20 * basic
ta = 0.05 * basic
hra = 0.10 * basic
print(f"Cash in hand: {basic + da + ta + hra}")
def calculateCylinderVolume():
r = float(input("Radius: "))
h = float(input("Height: "))
print(f"Volume: {math.pi * (r**2) * h}")
def convertHeight():
cm = float(input("Height in cm: "))
inches = cm / 2.54
feet = inches // 12
remaining_inches = inches % 12
print(f"{int(feet)} feet and {round(remaining_inches, 2)} inches")
def reverseTwoDigits():
num = int(input("Enter a 2-digit number: "))
print(f"Reversed: {(num % 10) * 10 + (num // 10)}")
def calculateCompoundInterest():
p = float(input("Principal: "))
t = float(input("Time (years): "))
r = float(input("Rate: "))
amount = p * (pow((1 + r / 100), t))
print(f"Amount: {amount}, Interest: {amount - p}")
def calculateMean():
vals = [float(x) for x in input("Enter numbers separated by space: ").split()]
print(f"Mean: {sum(vals) / len(vals)}")