filmov
tv
Casting | Python Programming Tutorial in Sinhala

Показать описание
In this video, we discuss about casting. Casting is used when we need to specify a type on to a variable or to perform type conversions.
Casting in python is therefore done using following constructor functions:
* int() - constructs an integer number from an integer literal, a float literal (by removing all decimals), or a string literal (providing the string represents a whole number)
* float() - constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer)
* str() - constructs a string from a wide variety of data types, including strings, integer literals and float literals
Casting in python is therefore done using following constructor functions:
* int() - constructs an integer number from an integer literal, a float literal (by removing all decimals), or a string literal (providing the string represents a whole number)
* float() - constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer)
* str() - constructs a string from a wide variety of data types, including strings, integer literals and float literals