-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.py
More file actions
34 lines (25 loc) Β· 1.42 KB
/
Calculator.py
File metadata and controls
34 lines (25 loc) Β· 1.42 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
# π Welcome to the Fun Calculator! π
# We're going to add, subtract, multiply, and divide two numbers like a boss! π
# Step 1: Ask the user to input the first number
# We're using 'float()' to make sure our numbers can have decimals too. Fancy, right? β¨
num1 = float(input("Enter the first number: "))
# Step 2: Ask the user to input the second number
# Same trick hereβusing 'float()' for decimal magic! π§ββοΈ
num2 = float(input("Enter the second number: "))
# Step 3: Time to do some math! π§ Let's compute the sum, difference, product, and quotient.
# Add the two numbers (Yay! Addition is the first step to fun!) β
sum_result = num1 + num2
# Subtract the second number from the first (Negative vibes, but necessary! π) β
difference_result = num1 - num2
# Multiply the two numbers (More bang for your buck! π₯) βοΈ
product_result = num1 * num2
# Divide the first number by the second (Be careful with zero here, no math disasters! π
) β
# We'll assume the user is being responsible and not dividing by zero for now!
quotient_result = num1 / num2
# Step 4: Show the user what we got! π₯³ Time for the big reveal! π
print(f"Results of your two numbers:")
print(f"Sum: {sum_result}") # β
print(f"Difference: {difference_result}") # β
print(f"Product: {product_result}") # βοΈ
print(f"Quotient: {quotient_result}") # β
# π And that's it! You've just made a mini-calculator! ππ»