Skip to content

Instantly share code, notes, and snippets.

@scott-lydon
Last active March 29, 2020 00:24
Show Gist options
  • Save scott-lydon/74ece728bfe362020b32bd913ce370b7 to your computer and use it in GitHub Desktop.
Save scott-lydon/74ece728bfe362020b32bd913ce370b7 to your computer and use it in GitHub Desktop.
Python
first = float(input("first number"))
operand = input("Your operand (accepting addition, multiplication, division, subtraction)")
second = float(input("second number"))
if operand == "x" or operand == "multiplication" or operand == "multiply" or operand == "*":
print(first * second)
elif operand == "+" or operand == "addition" or operand == "add":
print(first + second)
elif operand == "-" or operand == "subtraction" or operand == "subtract":
print(first - second)
elif operand == "/" or operand == "division" or operand == "divide":
print(first / second)
count = [1, 3, 4]
count += 3, 4, 5
print(count)
'''
(base) scottlydon@Scotts-MacBook-Air python % Python calculator.py
first number39
Your operand (accepting addition, multiplication, division, subtraction)addition
Traceback (most recent call last):
File "calculator.py", line 2, in <module>
operand = input("Your operand (accepting addition, multiplication, division, subtraction)")
File "<string>", line 1, in <module>
NameError: name 'addition' is not defined
'''
@scott-lydon
Copy link
Author

I know that "addition" is not defined. It is a user inputted value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment