Python-Ref > Basic usage > Types > Basic types
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Basic types

Each piece of data in python program has its type. The type distinguishes between numbers, text, functions, classes etc. and says the python interpreter what is possible to do with each data type.
Expand/Shrink
Zdroj: (types1.py)
  1   i = 1  # small integers are commonly named i,j,k
  2   x = 0.05
  3   f = range  # range is a builtin function that returns a list of integers of specified length
  4   s1 = "hi"
  5   s2 = "2"
  6   s3 = '1.3'
  7   l = [i,x,f,s1,s2,s3]  # a list of all previously created varibles
  8   
  9   print type( i)  # the type function returns the type of a variable
 10   print type( x)
 11   print type( f)
 12   print type( s1)
 13   print type( s2)
 14   print type( s3)
 15   print type( l)
stdout:
<type 'int'>
<type 'float'>
<type 'builtin_function_or_method'>
<type 'str'>
<type 'str'>
<type 'str'>
<type 'list'>
Doba běhu: 21.7 ms