Conversions - Python

From TRCCompSci - AQA Computer Science
Revision as of 09:23, 20 June 2018 by Admin (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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