Python Casting https://www.w3schools.com/python/python_casting.
asp
THE WORLD'S LARGEST WEB DEVELOPER SITE
HTML CSS JAVASCRIPT MORE
Python Casting
❮ Previous Next ❯
Specify a Variable Type
There may be times when you want to specify a type on to a variable. This can be done
with casting. Python is an object-orientated language, and as such it uses classes to
define data types, including its primitive types.
Casting in python is therefore done using constructor functions:
int() - constructs an integer number from an integer literal, a float literal (by
rounding down to the previous whole number) literal, 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
1 of 5 11-07-2018, 22:46
Python Casting https://www.w3schools.com/python/python_casting.asp
❮ Previous Next ❯
2 of 5 11-07-2018, 22:46
Python Casting https://www.w3schools.com/python/python_casting.asp
COLOR PICKER
HOW TO
Tabs
Dropdowns
Accordions
Convert Weights
Animated Buttons
3 of 5 11-07-2018, 22:46
Python Casting https://www.w3schools.com/python/python_casting.asp
Side Navigation
Top Navigation
Modal Boxes
Progress Bars
Parallax
Login Form
HTML Includes
Google Maps
Range Sliders
Tooltips
Slideshow
Filter List
Sort List
SHARE
CERTIFICATES
HTML, CSS, JavaScript, PHP, jQuery, Bootstrap and XML.
Read More »
4 of 5 11-07-2018, 22:46
Python Casting https://www.w3schools.com/python/python_casting.asp
REPORT ERROR PRINT PAGE FORUM ABOUT
Top 10 Tutorials Top 10 References
HTML Tutorial HTML Reference
CSS Tutorial CSS Reference
JavaScript Tutorial JavaScript Reference
How To Tutorial W3.CSS Reference
W3.CSS Tutorial Bootstrap Reference
Bootstrap Tutorial SQL Reference
SQL Tutorial PHP Reference
PHP Tutorial HTML Colors
jQuery Tutorial jQuery Reference
Angular Tutorial AngularJS Reference
Top 10 Examples Web Certificates
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples jQuery Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples Bootstrap Certificate
PHP Examples XML Certificate
jQuery Examples
Angular Examples
XML Examples
5 of 5 11-07-2018, 22:46