David_Moses_HENDERSON
5 min readFeb 12, 2022

9 UK noteworthy companies using Python:

Zopa, Newable Bussiness Finance, Zego, Flatfair, Livemore Capital, Sharegain, Ten Group, Mintel, Funding Options

Less code means fewer errors.

Tüm kod satırını seçip ctrl + / seçileni komple comment yapar.

When a float converted to integer, its decimal part is disregarded.

Any values which are evaluated to False when applied to a Boolean operator(not, and, or) are None, False, zero numeric types, empty sequences and empty collections.

If you combine strings with numbers, Python gets confused, gives error.

x = y = z = “same” atamaları yaparken sağdan sola atayarak gideriz. Yani önce value’yu z’ye, sonra z’yi y’ye ve en son y’yi x’e atarız.

+ işareti integer da addition yapar, string de concatenate(bitiştirmek) yapar.

String içinde backslash \ kodu böler, özel işaretin özelliğini kaybettirir, \n alt satıra atar, \t 4 boşluk(tab) atar, \b backspace(escape sequences) yapar geriye doğru bir eleman siler.

İşlem sırası (priority of boolean operators) not, and, or

Python is a case sensitive high level language.

Strings are immutable. When we use str.strip() code, at the same time we are creating a new copy of string.

Bir string’de indexleme 1 eleman almak, slicelamak daha çok eleman almak demektir.

String slicelamada [-2:-7] boş string sonuç verir çünkü step(- değer) girmezsen soldan sağa hareket eder. Aynı şekilde [2:7:-1] ye step (-değer) sonuç vermez.

Input istediğimizde boş enter yaparsak “” anlamına gelir yani False bir değer olur.

Normal divisions’ output is always float, floor division and modulus’ output is always integer.

len() function gives numbers of items, not index!!!

[start:stop:step] use this in slicing and indexing strings

String’in len() sonucu 15'i geçiyorsa list() kodunu uyguladığımızda alt alta sıralıyor, aksi halde yan yana liste yapıyor.

We use collections for all types render as a single object.

list = seperated by commas, in square brackets[], we can create a list with list() code.

list_name.append() adds only one object into the last index of list.

list() function takes iterable data, this fuction seperated all items of a data, spaces too.

Integer object is not iterable, so not run with len() or list() function.

list_name.sort() puts in alphabetic order and can’t reverse previous order.

For example ord(“1”) or ord(“@”) gives ASCII numeric code(parentheses inside must be string)

chr(70) gives ASCII value or character(parentheses inside must be integer)

Neyi slicelıyorsanız(not indexing) çıktısı aynı type dır. list list çıkar, string string çıkar, tabi iterable olmalı.

range() fucntion iterable üretir.

.endswith ve .startswith boolean verir.

Tuple içine iterable alır.

{} curly braces are using in dictionary, string.format method, sets.

A set is a collection of elements with no repeats and without insertion order but sorted order.

in ve not in operatörleri set lerde ve dictionary lerde kullanılır, boolean verir.

Tuple içindeki değişebilen mutable elemanları değiştirebiliriz, tuple lar immutable olsa da.

unhashable hatası örneği : sözlükte key word ler mutable olan list vs. olamaz.

Fonksiyonlar normal parantezle çalışır list(), dict() gibi…

dict(animal = “dog”) sözlüklerde burdaki animal key word oluyor ve stringe dönüyor, çağırırken [“animal”] yazılmalıdır.

type(key) value değeri ne tip ise onu gösterir(sözlüklerde).

dict.update() metodu aynı anda birden fazla key-value pair eklemek için kullanılır

dict.items() sözlüğü (key, value)tuple pairleri oluşturur.

del komutu değişkenleri de siler bu hafızayı boşaltmak için gereklidir. Big data durumunda RAM yetmeyebilir.

temp_dict[‘k4’]= temp_dict.pop(‘k2’) # dict. key değeri böyle silerek değiştirilir.

Fonksiyon içinde key = kullanımıyla(parametre değiştirmek) fonksiyonun işlevini değiştirebiliyoruz.

starred expression seperate iterable object to elements.

python virgülle ayrılmış elemanları tuple yapma eğilimindedir.

input fonksiyonu default type string dir.

en az değişkenle işimizi yapmaya çalışmalıyız, böylece daha hızlı ve daha az memory kaplar.

iterasyonda counter kullanmayı unutma!!

__name__ is one such special variable. If the source file is executed as the main program, the interpreter sets the __name__ variable to have a value “__main__”.

zip : en az ikili (pair) demek, demek ki dict ile iyi çalışır !!!

place holder özelliği listeden özel elemanı alır atar : a, _, b, _ = [1, 2, 3, 4] → a : 1, b : 3 olur.

5.5 → 6'ya yuvarlıyor, 6.5 → 6'ya yuvarlıyor !!!!

‘123’.isdigit → true verir, çünkü string de olsa 0–9 arası rakamdır.

a = 3, dersen 3 parametre olur, my_function(3), dersen 3 argüman olur

(i for i in range(5)) burdan bir generator oluşur

all([]) true döndürür fakat [] normelde false dur. any({}) false döndürür normalde {} false dur.

filter(function, iterable) function kısmına None girersek truthy leri döndürür.

enumerate(iterable, start=0) index numaraları ile elemanları tuple içinde çiftler halinde yazar. list fonksiyonu ile gösterilir.

sum(iterable, start) bu start toplamın üstüne ilave ediyor.

LEGB Ranking Rule

When you call an object (method or variable), the interpreter looks for its name in the following order:

  1. Locals. The space which is searched first, contains the local names defined in a function body.
  2. Enclosing. The scopes of any enclosing functions, which are searched starting with the nearest enclosing scope (from inner to outer), contains non-local, but also non-global names.
  3. Globals. It contains the current module’s global names. The variables defined at the top-level of its module.
  4. Built-in. The outermost scope (searched last) is the namespace containing built-in names.

Scope is not about parameters, it is about variables.

(lambda parameters : expression) yapısı içinde ternary if’ler ve list comprehensionlar burada kullanılırlar.

lambda tek kullanımlık fonksiyonlardır. değişkene atayınca istediğimiz kadar kullanırız. (one time function)

map(function, iterable) iterable nin elemanlarına tek tek uygular. iterable object üretir. for veya list ile print edilebilir.

map(lambda) ile kullanılınca expression kısmına sayısız iterable yazarak kullanabiliriz.

filter(lambda) bool döndüren bir lambda ile çalışır. filter(function, sequence). filter’ın function’ı true ise truty sonuçları verir.

script is a python file with a .py extension and module is a python file which has script(s) in it and we load it with using import keyword. Our current file and module file should be in the same directory.

bir modulü (mesela adı my_first_module olsun) import my_first_module.py olarak çağırırsak script olur, yani bir python dosyasını run etmek gibi olur. eğer import my_first_module şeklinde uzantısız yazıp çağırırsak module olur.

==>her modulün içinde bulunan __name__ iki farklı değer alabilir. Bunlardan biri ‘__main__’ (doğrudan run ettiğimizde) veya modülün(modül olarak import edip çalıştırdığımızda) adıdır. bir .py dosyasında print(__name__) dersek output __main__ olur.

In order to make the modules more systematically organized, we can use packages.

Note that when using from package import item, the item can be either a submodule (or subpackage) of the package, or some other name defined in the package, like a function, class or variable.

TypeError → expected type does not match with the given type

ValueError → missing of values, suppose you have to enter 6 and you entered 2

NameError → undefined variable or function

IndexError → try to access invalid index

KeyError → try to access invalid key in dictionary

IOError → try to access into a file that does not exist

interpretation = execution

how to work python : compiling →byte-code → virtual machine ==>The COMPILER translates your Python statements (source code) into BYTE-CODE. — — Different from the binary machine code, the byte code is platform-independent, primitive level and specific version of the Python source code. That’s why some Python programs are executed not as fast as in C-based conventional compiled languages. — — After compilation of Python statements into byte-code, Just like in compiler, VIRTUAL MACHINE(it’s not a real machine, it’s a software) executes byte-codes that come into it by reading line by line from top to bottom and from left to right.

exec() : block kod çalıştırır

eval() : single expression kod çalıştırır

nested functions ile outer function ı inner function içinde çağırmak recursion oluşturur ve bunlar döngülerden daha hızlıdır.

David_Moses_HENDERSON
David_Moses_HENDERSON

Written by David_Moses_HENDERSON

ABAP und Javascript spielen, Deutsch lernen

Responses (1)