Hello, what am i doing wrong, it

Hello, what am i doing wrong, it
0

#1

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”):

it is saying that my last line has an invalid syntax? what have i done wrong


#2

Remember the difference between the asigment operator and comparison operators.


#3

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


#4

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’


#5

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.


#6

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"))

#7

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


#8

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.