Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (16.4k points)
I just want to know the difference between casting and coercion in python.

1 Answer

0 votes
by (26.4k points)

I figure "casting" shouldn't be utilized for Python; there are just sort change, yet no casts (in the C sense). A sort transformation is done for example through int(o) where the object o is changed over into an integer (really, a number item is built out of o). Coercion occurs on account of paired activities(Binary operations):in the event that you do x+y, and x and y have various sorts, they are coerced into a solitary kind prior to performing out the activity. In 2.x, an uncommon technique __coerce__ permits object to control the coercion.

Want to learn python concepts? Come, Join the python training course and get certified.

Watch this video tutorial on how to become a professional in python

Related questions

0 votes
1 answer
asked Jul 15, 2019 in Java by Nigam (4k points)
0 votes
1 answer
asked Jan 21, 2020 in Java by angadmishra (6.5k points)

Browse Categories