Difference between revisions of "Casting"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
[[Python]]
+
There may be times when you want to specify a type on to a variable. This can be done with casting.
  
 
  x = str(3)    # x will be '3'
 
  x = str(3)    # x will be '3'
Line 7: Line 7:
 
== Related ==
 
== Related ==
 
* [[Variables]]
 
* [[Variables]]
 +
* [[Python]]
  
 
== See also ==
 
== See also ==

Revision as of 03:34, 3 March 2022

There may be times when you want to specify a type on to a variable. This can be done with casting.

x = str(3)    # x will be '3'
y = int(3)    # y will be 3
z = float(3)  # z will be 3.0

Related

See also

Advertising: