Python Course Zero to Mastery Started at Udemy

Python usually uses an interpreter. The compiler are a little bit different.

Interpret translates line by line.

Compiler takes all lines to machine code.

What is programming language? We give some instruction to translator. They tell the machine what to do. Translator can be interpreter or compiler.

Interpreter:

Compiler:

Python basics till numbers:

Double Slash in Python:


/ -> float division
//-> integer division

don’t memorize which available on the documentation

String type conversation.

Formatted String:

String Index

selfish[start:stop:stepover]

Immutabilty

Built in functions
Booleans

Software to find your current age with python:

#1 “old style” string formatting(% operator)

Source: https://realpython.com/python-string-formatting/

Template string ta pore kokhono hoyto dekhbo, ei ar ki

password length printing code from the course:

List

Matrix

list operations:

we can see the function from online documentation from the official site or other sites

 

 

 

 

Dictionary

Tuple:

Set:

set is an unordered collection of unique objects.

conditional.

 

Truthy and Falsy:

 

Exercise: Logical Operators

Equality

is vs == 
with using ‘is’ it needs to be refers to the same object

with == it needs to be equally same valued

for example:

 

 

Exercise: Counter will print item in list

Range

Enumerate:

while

 

break, pass, continue

Exercise:

Exercise:

Parameters and Arguments:

Return in python:

How it works:

without return it prints none:

 

with return it prints something that I insisted for:

Nested Return:

#issues with print and return

Exercise:

 

Exercise: To find even and max value from a list

 

Abstraction: private vs Public

 

Inheritance:

Polymorphism:

 

no amount of video is enough you have to learn by your way of development projects.

4 pillars in oop Encapsulation, Abstraction, Inherítance, Polymorphism

 

Now i am looking for another video from youtube to earn something about it.

Now the exercise from the udemy course:

Super,Object Introspection, Dunder/Magic method

1st example:

 

2nd example:

 

#Multiple Inheritance

#Method Resolution Order(MRO)

Pure Function

 

Map()

filter()

zip()

output: [(1, 10, 5), (2, 20, 4), (3, 30, 3)]

reduce() function and how it works in python:

I have seen two videos here from udemy and youtube to clear this concept for me

code from udemy:

reduce()

Output:

Exercise solutions here in function:

#1 Capitalize all of the pet names and print the list

output:

#2 Zip the 2 lists into a list of tuples, but sort the numbers from lowest to highest.

#3 Filter the scores that pass over 50%

#4 Combine all of the numbers that are in a list on this file using reduce (my_numbers and scores). What is the total?

Output:

Lambda Expressions in python:

Lambda is a computer science term. Which is an anonymous function. Which don’t use more than once for a purpose. Usually in lambda we don’t need to decalre any function name. What happens inside a function we can write in simple line using lambda function.

lambda using map:

lambda using filter:

lambda using reduce:

# Exercises using lambda
1. make a lambda example to squre

2. make a lambda example to make a sorted list

List Comprehension

Set and Dict Comprehension:

#dict comprehension

Comprehension is for shorthand.

Now a small exercise:

Problem: to write a one line code to find duplicate character to show in a answer
Soln code:

Output:

Decorators:

another example:

Higher Order Function HOC

the decorator can supercharge the function and can add an extra feature

Decorator:

Another example:

Practical Application of Decorator:

Exercise:

Need to do later as it is not downloading on my tablet

Error Handling:

error:

custom error in error handling:

Generators:
Range is a generator. Generator is special type in python

generator is iterable but all iterable is not generator
example: range is generator that is always iterable, list is also iterable but not generator

Modules:

Some examples of using modules here:
utility.py : in this file I put all the functions for opertions

Now I am sending values to those function using main :

 

Again another way:
main_buy.py:

shopping_cart.py:

The thing need to remember usually in a package automatically a file __init__.py creates.

Another important thing a successful program without error run with exit code 0
And with error run with exit code 1

Another way of example:

main.py

utility.py

shopping_cart.py

 

__name__:
Again example with names:

__name__

print(__name__)
#if __name__==’__main__’:

test.py:

utility.py

Python Built in Modules:

In other language it is known as standard library.
You don’t need to remember all, just know it exists and google it when needful.

https://docs.python.org/3/py-modindex.html

 

 

 

 

 

Spread the love