0
Why not 2+3 instead of int(“2”)+int(“3”)
5 odpowiedzi
+ 5
I checked your profile and saw that you just started learning python so I'm assuming this question is about python. In python, the input() function always takes a string. That is why you need to cast it to int if you want to add two numbers. Otherwise, python will just concatenate them as strings as opposed to adding them as numbers. (you will get "23" instead of 5)
+ 1
It is generally safer to specify the type, otherwise it could interpret 2+3 as a string or as a concatenation of two strings, whereby 2+3 = 23 instead of int("2") + int("3") = int("5").
I hope this helps! 😊
+ 1
Could you provide more detail and context?
Also mention the programming language in your tags (python?), use relevant tags
Seems like an example for type casting, so just an educational purpose.
0
I don't understand about what language do you write but I see that numbers in brackets are strings and we must convert it to int before sum/div/multy and others
0
because if you write "2"+"3" you get "23"