Over a million developers have joined DZone.

Tip: Python Variables and Typing

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

Never forget, Python uses duck typing and has typed objects but untyped variable names.

lfc = "Liverpool" # this is a string
manc = "Manchester City"
l_score = 3 # this is a integer
m_score = 0
print "Result",lfc,l_score,"-",m_score,manc
Result Liverpool 1 - 0 Manchester City

How to know the type of variables:

type(lfc)
<type 'str'="">
type(l_score)
<type 'int'="">

Source:  http://glowingpython.blogspot.com/2011/04/variables-and-typing.html


Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}