Python Learning


here are my direct notes from the course I am taking on python (I actually already know a bit of python but I don’t want to jump into the middle of the course and get confused)

Talk about Sublime text Editor
5 Sections –
Python Basics
Developer Environment, how to use Terrminal and command lineCode editorsPycharm fully functional IDEJupityr Notebooks
Advanced Python
Careers
Scripting
Datascraping
Automation
SeleniumGet browser to do different tasks like its a user
Web Development and ML and Data Science
What is a programming lanugage?
Programming is simply a way to give instructions to a computer, without code computer programs couldn’t do anything, you wouldn’t be able to google things, or play pokemon, I can’t just tell my computer what to do, they don’t understand language.  THey speak in 0 and 1s,, on and off, but that is gibberish to us, so computer programs were developed to communicate between the two.  There are lower levels, closer to computer language
Assembly like machine codepython and javascript close to english
Translator, takes source code taken in programming language, given the code translates to machine code.  What is a translator, it is another program, written by a human, either an interpreter or a compiler, it goes line by line through the code an executes the code on the machine, compiles are a bit different take the code all at once and then translates that machine code.
 Download from python.org
End of the day all programs languages do the same, the beauty is they all do things similar.   Each programming language gets easier and easier.  
Jython in javapypy written in pythoncpython writen in cironpython written in something
we write python goes through interpretor and makes byte code
0 LOAD_GLOBAL         0(print)2 LOAD_CONST         1(‘Hello, World!’)4 CALL_FUNCTION         16 POP_TOP8 LOAD_CONST         0 (None)10 RETURN_VALUE
then cypthon vm
repl.it  create an account allows you to save python files online
Python 2 vs Python 3
Python was created by Guido Van Rossum
in 2008 he decided was used for a very long time and how some changes that him and community wanted, so in 2008 they made python 3.  Some features python 2 had, python 3 had some breaking changes, if you updated to python 3 (the interpreter/compile) would break python version 2.  So most companies that already used 2 stayed with 2, meaning they would have to make some changes.  For example in python 2, the print didn’t use brackets.  The differences are not that big overall, typically you can learn in a day so we will be using Python 3.  You may see python 2, it is now called legacy, come 2020 it will stop receiving security python updates, so everyone should be switching to python 3.
  Only 4 popular packages that do not support python 3, it is the way of the future it is the way we are going to go.
Why are there so many programming languages, why can’t we just have one langage that does everything and everyone is happy. In your career, you do not need to no multiple languages, and languages like java javascript python, you don’t have to know all of them.IF you go to wiki and look at them you will see there are 100s are languages and different languages are good for different things, like building a house each is a different tools.   Python is ususally slower than languages like C, C++, Java, you don’t really want to write low level application although slower than other languages, it is good at developer productivity.   It is close to the English language, and good for developers to build something fast.  Maybe a web server, data manipulation.

First exercise 
We will learn termsData types Actions and finally best practices there are good ways of writing code and bad ways.
Fundameental Python Data typesint  stands for integerfloat boolstr  stands for stringlisttuplesetdict# Classes -> Custom types
#Specialized Data Typesthey are not built into python but they are special modules that we can use.  Whenever we don’t have a datatype we don’t have already, and don’t want to create our own, there are modules or extension we can use
None   means nothing, absence of value, we will see later on why this is important

int  stands for integer, it is a number
float a youtube video explains it in more details but it has a floating point number meaning, like 3.14

YouTube Video, Floating Point Numbers – Computerphile

bool can only be true or false, 0 or 1, on or off.  They are going to be useful for controlling the logic of our program, if this then do this, conditional logic will use htis a lot more.str  stands for string, these are characters like “hellow world”listtuplesetdict
Math functions are build into pythonhttps://www.programiz.com/python-programming/modules/math


print functions and type functions round is an example of math functionround(3.1)  you get 2 you also need to tell it to printso print(round(3.1)) you will get 3 if it’s 3.9 you will get 4 print(abs)(-20)) returns absolute value, so it returns 20
There is a doc page for this and you do not need to mesmerize all the math functions.  

Lets talk about an important operator precedencemeans diffrent operators have precendence over different once, the python interpreter is going to follow specific rules.this works the same in all programing languages from first to last:bracketspower of exponentsMultiplication and divisionaddition and subtraction
extra data type called complex. complex number is a third type instead of int and float, the reason not teaching, you only use it if you are doing very complex math, you can read about complex numbers if you want but will not use 99% of the time.  
function called bin returns binary representation of something, like the binary represenation of 5 bin(5), 0b also means binary number.  101 is bin for 5.

print(int('0b101',2))    

convert that binary number to a decimal, what we are use to.
Variables, Variables store information that can be used in program.  
iq = 190^ is a variable, something made up.   Once we assign a variable, we can now use in the program whereever we want.
assigning a value is also known as binding
best practices:snake_case  spaces don’t existVariables start with lowercase or underscoreLetters, numbers, underscoresCase sensitiveDon’t overwrite keywordshttps://www.w3schools.com/python/python_ref_keywords.asp
for example_user_iq = underscore in python signifies a private variable.You can use numbers as well.  

expressions and statements
an expression is the piece of code that produces a value a statement is an entire line of code that does some action.  
Augmented assignment operatorsome_value= 5 +2some_value = some_value +2print(some_value) either way will print 7but instead you could just do some_value += 2  the += is the augmented assignment operator,  -= also works.the variable most have a previous value.

str
stands for stringit is a piece of text, for example ‘ hi hello there’  the color will change in the editor, you can also make strings with double quotes, just a piece of text.If you do a type, you will get back str back.  
long_string = ”’0 0– -”’if you print the long string the whole thing will print
it expands multiple lines
first_name = ” jamison”last_name=”border”full_name = first_name + ‘ ‘+last_nameprint(full_name)
this will print my full name

string concatenationsimple adding strings together
‘hello’ + ‘jamison’so if I print that, it will print both words.
what will happen if I do ‘hello’ + 5
you will get an error, string concatenation only works with strings
string is written as str, it is a special word
what if you do str(100)
print(str(100))you will get 100the string version of the intyou can test with print(type(str(100)))
if we keep going the one on the end is what type it isso for example print(type(int(str(100))))will return int the left most cause we lastely converted it.This is all called type conversion.
Escape Sequence in Pythonwhat if wanteda  string that told the weatherweather = ‘it’s sunny’
you will see the single quote caused an issue, you can fix this with a double quote string instead  It is simple adding a  slash right before the single quote to escape the character”it\s \”kind of \” sunny”  will print out correctly.   \\ for how to print out the escape character\t it will add a tab\n will make a new line

First exercise 
We will learn termsData types Actions and finally best practices there are good ways of writing code and bad ways.
Fundameental Python Data typesint  stands for integerfloat boolstr  stands for stringlisttuplesetdict# Classes -> Custom types
#Specialized Data Typesthey are not built into python but they are special modules that we can use.  Whenever we don’t have a datatype we don’t have already, and don’t want to create our own, there are modules or extension we can use
None   means nothing, absence of value, we will see later on why this is important

int  stands for integerfloat boolstr  stands for stringlisttuplesetdict
Math functions are build into pythonprint functions and type functions round is an example of math functionround(3.1)  you get 2you also need to tell it to printso print(round(3.1)) you will get 3if it’s 3.9 you will get 4print(abs)(-20)) returns absolute value, so it returns 20
There is a doc page for this and you do not need to mesmerize all the math functions.  

Lets talk about an important operator precedencemeans diffrent operators have precendence over different once, the python interpreter is going to follow specific rules.this works the same in all programing languages from first to last:bracketspower of exponentsMultiplication and divisionaddition and subtraction
extra data type called complexa complex number is a third type instead of int and float, the reason not teaching, you only use it if you are doing very complex math, you can read about complex numbers if you want but will not use 99% of the time.  
function called bin returns binary representation of something, like the binary represenation of 5 bin(5), 0b also means binary number.  101 is bin for 5.

print(int(‘0b101’,2))    
convert that binary number to a decimal, what we are use to.
Variables, Variables store information that can be used in program.  
iq = 190^ is a variable, something made up.   Once we assign a variable, we can now use in the program whereever we want.
assigning a value is also known as binding
best practices:snake_case  spaces don’t existVariables start with lowercase or underscoreLetters, numbers, underscoresCase sensitiveDon’t overwrite keywords
for example_user_iq = underscore in python signifies a private variable.You can use numbers as well.  

expressions and statements
an expression is the piece of code that produces a value a statement is an entire line of code that does some action.  
Augmented assignment operatorsome_value= 5 +2some_value = some_value +2print(some_value) either way will print 7but instead you could just do some_value += 2  the += is the augmented assignment operator,  -= also works.the variable most have a previous value.

str
stands for stringit is a piece of text, for example ‘ hi hello there’  the color will change in the editor, you can also make strings with double quotes, just a piece of text.If you do a type, you will get back str back.  
long_string = ”’0 0– -”’if you print the long string the whole thing will print
it expands multiple lines
first_name = ” jamison”last_name=”border”full_name = first_name + ‘ ‘+last_nameprint(full_name)
this will print my full name

string concatenationsimple adding strings together
‘hello’ + ‘jamison’so if I print that, it will print both words.
what will happen if I do ‘hello’ + 5
you will get an error, string concatenation only works with strings
string is written as str, it is a special word
what if you do str(100)
print(str(100))you will get 100the string version of the intyou can test with print(type(str(100)))
if we keep going the one on the end is what type it isso for example print(type(int(str(100))))will return int the left most cause we lastely converted it.This is all called type conversion.
Escape Sequence in Pythonwhat if wanteda  string that told the weatherweather = ‘it’s sunny’
you will see the single quote caused an issue, you can fix this with a double quote string instead  It is simple adding a  slash right before the single quote to escape the character”it\s \”kind of \” sunny”  will print out correctly.   \\ for how to print out the escape character\t it will add a tab\n will make a new line

That gets me up to the 30th video of the series


Leave a Reply

Test Your email address will not be published. Required fields are marked *