-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment.py
More file actions
37 lines (32 loc) ยท 1.18 KB
/
Assignment.py
File metadata and controls
37 lines (32 loc) ยท 1.18 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
# ๐ฎ Welcome to the Interactive Fun Calculator! ๐ฎ
# Choose your operation and let's get calculating like pros! ๐งฎ๐
# Step 1: Ask the user to input two numbers
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
# Step 2: Present a menu of operations to the user
print("\nSelect an operation:")
print("1 โ Addition")
print("2 โ Subtraction")
print("3 โ๏ธ Multiplication")
print("4 โ Division")
# Step 3: Get user's choice
choice = input("Enter the number of the operation you want to perform (1/2/3/4): ")
# Step 4: Perform the selected operation
if choice == '1':
result = num1 + num2
print(f"\nResult: {num1} + {num2} = {result}")
elif choice == '2':
result = num1 - num2
print(f"\nResult: {num1} - {num2} = {result}")
elif choice == '3':
result = num1 * num2
print(f"\nResult: {num1} * {num2} = {result}")
elif choice == '4':
if num2 != 0:
result = num1 / num2
print(f"\nResult: {num1} / {num2} = {result}")
else:
print("\n๐ซ Error: You can't divide by zero!")
else:
print("\n๐ Invalid choice. Please enter 1, 2, 3, or 4.")
# ๐ Thanks for using the Fun Calculator! ๐