python
TRANSCRIPT
Who am I?
• Ricardo Lapa Dani• Pythonista since 2005•Djangonaut•Developer at Horizonte/Globosat Rio de Janeiro – Brazil• Free software enthusiast
About python• Created by Guido Van Rossum
1991• Free software / Open Source• Widely used worldwide• High-level script programming
language• Multi paradigm (procedural,
functional, object-oriented)• General purpose (web, science,
games, gui, 3d, mobile, etc..)• Multi plataform (windows, linux, etc)
The ZEN of python
• Beautiful is better than ugly• Explicit is better than implict• Simple is better than complex• Complex is better than complicated• Readability counts.
The python interpreter
• Interactive interface to python» python ricardodani@MAC019214Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 1 + 12>>> 3*(7+2)27>>>
TypesIntegers:
10 20 -1 0 7 42 int(30) int(‘2’)
Float:1.2 -4.3 5.2 float(10) 5.
Complex5+7j -2+3j
Strings‘Ricardo’ “Ricardo” ‘’’Ricardo’’’ u’Ricardo’
Lists[1, 2, 4, 5, “Ricardo”, 1.2, [2, 4, 5]]
Dictionaries{‘name’: Ricardo, ‘age’: 25, ‘friends_name’: [“Joaquim”, “Maria”]}
Comparation1 == 2 False
1 == 1 True
1 in [1, 2, 4, 5] True
not 1 in [1, 2, 4, 5] False
“Lapa” in “Ricardo Lapa” True
1 > 2 False
1 <= 2 True
1 is (2 – 1) True
1 is True False
Logical operatorsArithmetic Operators
+
-
*
/
%
**
//
Comparasion Operators==
!=
<>
>
<
>=
<=
Logicaland
or
not
Assignment Operators=
+=
-=
*=
/=
%=
**=
//=
Membership Operatorsin
not in
Identify Operatorsis
is not
Condictional structuresIF / ELSE / ELIF
if <condition>:
do something
elif <another_condition>:
do another something
else:
do something else
Repetition StructuresFor
for <element> in <iterable>:
iterate over each <element> of iterable
While
while <condition_is_true>:
do something
Source• http://www.slideshare.net/amiable_indian/introduction-to-
python• http://en.wikipedia.org/wiki/Python_(programming_language)• http://www.tutorialspoint.com/python/
python_basic_operators.htm