Typy proste i funkcja type()

Zmienne, typy i operatory - Podstawy Pythona (Python)

Typy proste w Pythonie to: int, float, str, bool. To mniej niz w Javie (tam byly osobno byte/short/int/long, float/double, char). Funkcja type() podaje typ zmiennej.

whole = 100
float_number = 3.14
text = "Python"
flag = True
print(type(whole))         # <class 'int'>
print(type(float_number))  # <class 'float'>
print(type(text))          # <class 'str'>
print(type(flag))          # <class 'bool'>

Ładowanie interaktywnego edytora... Jeśli się nie pojawi, włącz JavaScript.

Wszystkie lekcje kursu Podstawy Pythona · Zaloguj się, aby zapisać postęp na koncie.