4. What is Python
oWidely used high-level programming language
oCreated in Netherlands by Guido van Rossum at the end of the 80s
oNamed after Monthy Python
oStrong emphasizes on code readability and simplicity
oSupports multiple programming paradigms
oNOT A SNAKE!
5. What is Python
oWidely used high-level programming language
oCreated in Netherlands by Guido van Rossum at the end of the 80s
oNamed after Monthy Python
oStrong emphasizes on code readability and simplicity
oSupports multiple programming paradigms
oNOT A SNAKE!
6. Why use Python
oSimplicity
oFewer lines => less buggy code and reduce development time
o3rd party resources
oAvailable on multiple OS
oOpen source and mature
oUsed by: Google, Dropbox, Eventbrite, Quora, SlideShare, Reedit
7. Python 101
oTwo main versions: 2.x and 3.x
oIDE: IDLE, PyDev, PyCharm, Visual Studio
oOnline jupyter.org
oINDENTATION COUNTS!
8. Python 101
VARIABLES
◦ Must have an initial value
◦ We can define multiple variables at once
◦ Case sensitive
◦ Can contain letter, number or underscore
◦ Some reserved word cannot be used
10. Python 101
DATA TYPES
◦ Integers
◦ 23, -4, 99934
◦ Float
◦ 0.333, -8.8, 883.009
◦ String
◦ “Hola Buenes", ‘Arturo Maran’
◦ Value of index cannot be changed!
11. Python 101
DATA TYPES
◦ Lists
◦ Compound data types
◦ Normally related but can have different types into them
◦ Alist = [1, 3, 4, 5]
◦ Blist = [1, "a", 3]
◦ Starts from index 0
◦ Operations: append, add, delete, index
12. Python 101
DATA TYPES
◦ Tuples
◦ Same structure like a list
◦ Difference is that values cannot be change
◦ Ex: Months = ("Jan", "Feb", …, "Dec")
13. Python 101
DATA TYPES
◦ Dictionaries
◦ Look-up tables
◦ Maps a value to a key
◦ Duplicate keys are not allowed, instead we can have duplicate values
◦ User_Ages = {"Sabu":30, "Radel":78, "Sighi":18}
◦ Keys are immutable strings, values, tuples
14. Python 101
CHOICES AND DECISIONS
◦ Conditional statements
◦ !=, <, <=, >, >=, ==
◦ Logical operators: and, or, not
◦ If statement
If condition_true:
do A
elseif:
do B
elseif:
do C
else
do SomethingElse
15. Python 101
CHOICES AND DECISIONS
◦ For loops
◦ Looping through an iterable
◦ Iterabile: everything we can loop over: collection, string, tuples
◦ We can loop through a sequence of numbers
food = ["ciorba de fasole", "ceafa", "cartofi prajiti", "clatite"]
for theFood in food:
print (food)
for x in range (5):
print (x)
16. Python 101
CHOICES AND DECISIONS
◦ While loop
◦ Repeatedly executes instruction inside a loop until a condition is met
◦ While conditions is true, execute things
◦ We can loop inside using break or continue
◦ Try Except
◦ Controls how the program behave when an error occurs
17. Python 101
FUNCTION
◦ Pre-written code that performs a certain task
◦ Calling it by typing the function name (non OOP) or by dot notation when is part of a
class (OOP)
◦ Can have parameters
◦ Can return a value