print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = raw_input(“Add, Subtract, Multiply or Divide?”)

if choice = (“add”):

print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = raw_input(“Add, Subtract, Multiply or Divide?”)

if choice = (“add”):

Remember the difference between the asigment operator and comparison operators.

1 Like

I still dont get what you mean? could you give me the correct code?

print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = input(str(“Add, Subtract, Multiply or Divide?”))

if choice == (“add”):

addition1 = input(int(“Enter a number you would like to use”))

addition2 = input(int(“Enter the number you would like to add”))

print (addition1 + addition2)

now it is saying this : Traceback (most recent call last): File “python”, line 6, in <module> ValueError: invalid literal for int() with base 10: ‘Enter a number you would like to use’

You need to properly indent your code, because this is Python.

Also, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`

) will also add backticks around text.

**Note:** Backticks are not single quotes.

You must get the input first, then you convert it to int. Otherwise you’re trying to convert the string “Enter a number you would like to use” to int.

```
int(input("Enter a number you would like to use"))
```

2 Likes

I bossed it!!!

print(“Hello my friend”)

print (“I will be your Calculator”)

print (“Firstly, What would you like to do?”)

choice = input(str(“Add, Subtract, Multiply or Divide?”))

if choice == (“add”):

addition1 = input("Enter a number you would like to use: ")

addition2 = input("Enter the number you would like to add: ")

print (int(addition1) + int(addition2))

elif choice == (“subtract”):

subtract1 = input("Enter a number you would like to use: ")

subtract2 = input("Enter a number you would like to subtract: ")

print (int(subtract1) - int(subtract2))

elif choice == (“multiply”):

multiply1 = input("Enter a number you would like to use: ")

multiply2 = input("Enter a number you would like to Multiply by: ")

print (int(multiply1) * int(multiply2))

elif choice == input(“divide”):

divide1 = input("Enter a number you would like to use: ")

divide2 = input("Enter a number you would like to divide by: ")

print (int(divide1) / int(divide2))

print (“Thank you for using me today, have a nice week!”)

also, does anyone know how I could prehaps make it a loop to see if they wanted to do another math task

Why don’t you try to write the code first yourself and then we can guide you?

Also, please use the backticks (as I showed you earlier) when posting on the forum.