Skip to content

Biruk-N/Python-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python-practice

The pracitce file is in main.py

python basics

data-types

opertators

math functions

round function abs function

operator precedence

variables

expresions vs statement

augumented assignment operators

strings and concatination

type conversion

escape sequence

formatted strings

imutability | string is immutable

built-in functions

len()

cpapitalize() | only the first letter

upper()

find()

replace()

list

list slicing

matrix

list methods

list methods reference

common list patterns

to reverse slicing reverse, [::-1]

range(start, end), range(value)

join

list unpacking

dictionary

keys can hold only immutable datatypes link int, str,tuple ... but not list

dictionary methods, .get(key) or .get(key, default_Value)

.values()

.items()

.clear()

.copy()

.pop() or popitem()

.update({key: value})

datastructure

dictionary

list

tuples: like as list but immutable, so it's much faster than list

set: one_set.difference(other_set), difference_update(), .discard(), .difference_update(), .intersection() or &, .isdisjoint(), .issuperset(), .issubset(), .union() or | .


Python Basic II

indentation

truthy and falsy

ternary operators

short-circuiting:

** short-circuiting ** mean the stoppage of execution of boolean operation if the truth value of expression has been determined already.

logical operator

loops

for loop: when the iteration value known

iterable - list, dictionary, tuple, set, string

iterated - one by one check each item in the collection

.items(): to access key and value for dictionary in for loop

.values(): to print out only values of a dictionary

.keys(): only key

range(): in for loop

enumerate(): to list index with value in for loop

while : when the value not known

break: break out of the loop.

continue: means back to the loop don't care about the other program left in a function. print nothing.

pass: pass to the next ... at least fill something in a loop if nothing is there in a loop

print(value, end=)

functions

to do action in our code.

DRY(don't repeat your self)

parameter vs argument

positional arguments

default parameter and keyword arguments

return

docstrings description of the function, help(func), print(func.doc)

argument and keyword argument(*args **kwargs)

rule of orders: params, *args, default parameters, **kwargs

Scope inside a function varables are local variables

global key word

nonlocal key word

walrus operator

Table

Mutable Immutable
List Set
- Dictionary(key)
- -
- String

OOP

class

@classmethod and @staticmethod

4 pillars of OOP

encapsulation: package

abstraction: private & public

inheritance

polymorphism

dunder mehtod

MRO method resolution order

Functional programming

map()

filter()

zip()

reduce()

lambda expression

list comprehension

set and dictionary comprehension

Decoration

All tutorial

  • Python basics I
  • Python basics II
  • Advanced oop
  • Advanced Functional programming
  • Advanced

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages