Ask Question

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

+1
Answers (1)
  1. 5 November, 01:59
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers