Difference between revisions of "Casting"
Jump to navigation
Jump to search
(Created page with " Python x = str(3) # x will be '3' y = int(3) # y will be 3 z = float(3) # z will be 3.0 Variables") |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | https://www.w3schools.com/python/python_casting.asp | ||
+ | |||
+ | There may be times when you want to specify a type on to a variable. This can be done with casting. | ||
+ | |||
+ | === Example === | ||
− | |||
x = str(3) # x will be '3' | x = str(3) # x will be '3' | ||
y = int(3) # y will be 3 | y = int(3) # y will be 3 | ||
z = float(3) # z will be 3.0 | z = float(3) # z will be 3.0 | ||
+ | == Related == | ||
+ | * [[Variables]] | ||
+ | * [[Python: variables]] | ||
+ | |||
+ | == See also == | ||
+ | * {{Python}} | ||
− | [[ | + | [[Category:Python]] |
Latest revision as of 11:29, 7 March 2022
https://www.w3schools.com/python/python_casting.asp
There may be times when you want to specify a type on to a variable. This can be done with casting.
Example[edit]
x = str(3) # x will be '3' y = int(3) # y will be 3 z = float(3) # z will be 3.0
Related[edit]
See also[edit]
- Python, PIP, GIL, Flask, Django, Marshmallow,
def
, logging, Pandas, Numpy, AWS Chalice,import
,from
,tuple
,list
, Python exceptions,virtualenv
,.append
,pytz
,TZ
,print
,python3 -c
,os
, PEP, Python Institute, Methods: Dunder methods, Flake8, Python collections, Function decorators in Python, Click python library, Python module, Flower,kwargs
, Black (Python), Python list structure, Mypy,variables
, Casting,try:
, pydoc, argparse, Anaconda,pyenv, setup.py, python3 --version, python3 --help
, Data Classes, raise
Advertising: