Difference between revisions of "Conversions - Python"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(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...")
(No difference)

Revision as of 10: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:

<syntaxhiglight lang=python> number = int( textEntered) </syntaxhighlight>

or if you wanted to get the input direct from the user you could do this instead:

<syntaxhiglight lang=python> name = int( input(“enter a number”) ) </syntaxhighlight>

Other conversion functions are available:

Conversions in python.png