Contoh :
>>>
a = 10
>>>
type (a)
<type
'int'>
>>>
type(10)
<type
'int'>
Keluaran/output
<type 'int'> menunjukkan bahwa tipe data a adalah integer.
>>>
b = 10.589
>>>
type (b)
<type
'float'>
>>>
type (10.589)
<type
'float'>
Keluaran
<type 'float'> menunjukkan tipe datanya float/real.
>>>
type("BlankOn")
<type
'str'>
Keluaran
<type 'str'> menunjukkan tipe datanya string.
>>>
type(True)
<type
'bool'>
Keluaran
<type 'bool'> menunjukkan tipenya boolean.
>>>
type(40-25j)
<type
'complex'>
Keluaran
<type 'complex'> menunjukkan tipenya bilangan kompleks.
>>>
buah = ['mangga','pisang','jambu','pepaya','kurma','durian']
>>>
type(buah)
<type
'list'>
Keluaran
<type 'list'> menunjukkan tipe data dari buah adalah list.
0 komentar:
Posting Komentar