+ 6

What's the difference between print ("5")and print (5)

Does it change anything or its the same

22nd Jun 2019, 7:31 PM
Noah Djer
Noah Djer - avatar
7 Respuestas
+ 9
Technically nothing. print automatically converts non-strings to strings before printing them. print("5") #5 is already string. print(5) #Program converted 5 to string. This can be proved with OOP by creating objects with either of these 2 magic methods: __str__ and __repr__. It will be called like any other function, when you print the object.
22nd Jun 2019, 8:54 PM
Seb TheS
Seb TheS - avatar
+ 4
5 is a integer whereas "5" Is a string literal as it can be identified by double inverted commas, but the answer will be same though
23rd Jun 2019, 6:48 PM
Piyush Srivastava
Piyush Srivastava - avatar
+ 3
("5") prints a string while (5) prints an integer, can matter if dealing with operations.
22nd Jun 2019, 7:43 PM
Mo Hani
Mo Hani - avatar
+ 3
Thanks guys!!
22nd Jun 2019, 7:44 PM
Noah Djer
Noah Djer - avatar
+ 2
Print("5") is for a string and print(5) is a number such that you can do operation like 5+5 =10 ,
23rd Jun 2019, 7:03 AM
vincent mzungu
+ 2
Print("5") // means you are printing a string print (5) // means you are printing an integer
23rd Jun 2019, 9:28 AM
Candice Dick
Candice Dick - avatar
+ 2
Only the data type.
24th Jun 2019, 7:55 AM
Sonic
Sonic - avatar