Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tip: Python Variables and Typing

DZone's Guide to

Tip: Python Variables and Typing

· Web Dev Zone
Free Resource

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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}