Değişkenler ve Türler

Python’a Giriş

Hugo Bowne-Anderson

Data Scientist at DataCamp

Değişken

  • Özel, büyük/küçük harfe duyarlı ad

  • Değişken adıyla değeri çağırın

  • 1,79 m - 68,7 kg

height = 1.79
weight = 68.7

height
1.79
Python’a Giriş

BMI Hesapla

height = 1.79
weight = 68.7

height
1.79

$$ \text{BMI} = \frac{\text{weight}}{\text{height}^2} $$

68.7 / 1.79 ** 2
21.4413
weight / height ** 2
21.4413
bmi = weight / height ** 2
bmi
21.4413
Python’a Giriş

Yeniden Üretilebilirlik

height = 1.79
weight = 68.7
bmi = weight / height ** 2
print(bmi)
21.4413
Python’a Giriş

Yeniden Üretilebilirlik

height = 1.79
weight = 74.2 # <-
bmi = weight / height ** 2
print(bmi)
23.1578
Python’a Giriş

Python Türleri

type(bmi)
float
day_of_week = 5
type(day_of_week)
int
Python’a Giriş

Python Türleri (2)

x = "body mass index"
y = 'this works too'

type(y)
str
z = True
type(z)
bool
Python’a Giriş

Python Türleri (3)

2 + 3
5
'ab' + 'cd'
'abcd'
  • Farklı tür = farklı davranış!
Python’a Giriş

Lass uns üben!

Python’a Giriş

Preparing Video For Download...