Ask Question
21 May, 21:54

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

+2
Answers (1)
  1. 22 May, 00:43
    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?
Find an answer to your question ✅ “What would you expect as the result of the code print (1+4) ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers