Basics of Python Programming Rohan Koodli
Hello World l First program in Python
Variables l Variables can change
l Can be number, string, list
l Individual variables can change types(unlike other languages)
Comparisons l The “=“ assigns variable names
l The “==“ checks for equality
l !=, >, <, >=, <=
If/Else Statements l Controls flow of the program
l If, Elif (else if), else
Loops l While Loops
l Executes a task while something is true
l For Loops l Iterates over elements
Prints ‘hi’ forever (1 is always less than 5
Lists l Sequence of data
l You can iterate over a list
l Indexing(indexes start at zero)
Tuples l Similar to lists
l Cannot change tuples
Strings l Can iterate over strings
l Many funcYons for strings
FuncYons l Use “def”
l One funcYon can be used mulYple Ymes
l Lambdas
Import l Used to load up a library
Classes l Contains data
l Contains instance variables
l ‘self’ allows you to modify variable later on
l ‘__init__’ called when you use make an instance of the class