Değişken Veri Tipleri

Finans için Python’a Giriş

Adina Howe

Instructor

Python Veri Tipleri

Değişken Tipleri Örnek
String'ler 'hello world'
Integer'lar 40
Float'lar 3.1417
Boolean'lar True veya False
Finans için Python’a Giriş

Değişken Tipleri

Değişken Tipleri Örnek Kısaltmalar
String'ler 'Tuesday' str
Integer'lar 40 int
Float'lar 3.1417 float
Boolean'lar True veya False bool
Finans için Python’a Giriş

Bir değişkenin veri tipi: type()

Türü belirlemek için type() fonksiyonunu kullanabiliriz:

type(variable_name)
pe_ratio = 40
print(type(pe_ratio))
<class 'int'>
Finans için Python’a Giriş

Değişkenlerle işlemler

x = 5
print(x * 3)
15
print(x + 3)
8
y = 'stock'
print(y * 3)
'stockstockstock'
print(y + 3)
TypeError: must be str, not int
Finans için Python’a Giriş

Değişken tiplerini dönüştürme

pi = 3.14159
print(type(pi))
<class 'float'>
pi_string = str(pi)
print(type(pi_string))
<class 'str'>
print('I love to eat ' + pi_string + '!')
I love to eat 3.14159!
Finans için Python’a Giriş

Hadi pratik yapalım!

Finans için Python’a Giriş

Preparing Video For Download...