Ask Question
6 August, 23:03

What would you expect as the result of the code print (1+4)

+2
Answers (1)
  1. 7 August, 00:26
    0
    I would expect it to output 5 to the screen. The plus sign is overloaded in most languages, put simpler it behaves in more than one way. This looks like Python 3. x. When given strings, the plus sign concatenates them:

    print ("Hello " + "World")

    "Hello World"

    When given numbers, the plus sign performs addition. When numbers and strings are mixed, an error occurs. The number needs to be converted to a string like:

    print (str (4) + "foo")
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What would you expect as the result of the code print (1+4) ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers