Difference between revisions of "Conversions - Python"
(Created page with "=Data Type Conversions= Python has built in functions to convert between different data types. To convert something to an integer you would enter: <syntaxhiglight lang=pytho...") |
|||
Line 3: | Line 3: | ||
Python has built in functions to convert between different data types. To convert something to an integer you would enter: | Python has built in functions to convert between different data types. To convert something to an integer you would enter: | ||
− | < | + | <syntaxhighlight lang=python> |
number = int( textEntered) | number = int( textEntered) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 9: | Line 9: | ||
or if you wanted to get the input direct from the user you could do this instead: | or if you wanted to get the input direct from the user you could do this instead: | ||
− | < | + | <syntaxhighlight lang=python> |
name = int( input(“enter a number”) ) | name = int( input(“enter a number”) ) | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 09:23, 20 June 2018
Data Type Conversions
Python has built in functions to convert between different data types. To convert something to an integer you would enter:
number = int( textEntered)
or if you wanted to get the input direct from the user you could do this instead:
name = int( input(“enter a number”) )
Other conversion functions are available: