Difference between revisions of "Casting"

From wikieduonline
Jump to navigation Jump to search
 
(4 intermediate revisions by one other user 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 ===
  
[[Python]]
 
 
  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]]
  
[[Variables]]
+
== See also ==
 
+
* {{Python}}
  
{{Python}}
+
[[Category:Python]]

Latest revision as of 11:29, 7 March 2022

Advertising: