Untitled
unknown
plain_text
2 years ago
1.9 kB
10
Indexable
def emoji_calculator():
print("Emoji Calculator")
print("Supported operations: +, -, *, /")
# Emoji representations of numbers
emoji_numbers = {
'1️⃣': 1,
'2️⃣': 2,
'3️⃣': 3,
'4️⃣': 4,
'5️⃣': 5,
'6️⃣': 6,
'7️⃣': 7,
'8️⃣': 8,
'9️⃣': 9,
'0️⃣': 0,
}
while True:
# Get user input for numbers and operation
num1 = input("Enter first number (emoji): ")
operator = input("Enter operator (+, -, *, /): ")
num2 = input("Enter second number (emoji): ")
# Validate input
if num1 not in emoji_numbers or num2 not in emoji_numbers:
print("Invalid emoji numbers. Please use valid emojis.")
continue
# Perform calculation
result = 0
if operator == '+':
result = emoji_numbers[num1] + emoji_numbers[num2]
elif operator == '-':
result = emoji_numbers[num1] - emoji_numbers[num2]
elif operator == '*':
result = emoji_numbers[num1] * emoji_numbers[num2]
elif operator == '/':
if emoji_numbers[num2] != 0:
result = emoji_numbers[num1] / emoji_numbers[num2]
else:
print("Error: Division by zero.")
continue
else:
print("Invalid operator. Please use +, -, *, or /.")
continue
# Display result
print(f"Result: {result}")
# Ask if the user wants to perform another calculation
another_calculation = input("Do you want to perform another calculation? (yes/no): ").lower()
if another_calculation != 'yes':
break
if __name__ == "__main__":
emoji_calculator()Editor is loading...
Leave a Comment