Skip to content
Snippets Groups Projects
Select Git revision
  • 101b3fc5a025db67d98329b31da3e68dc393928f
  • master default protected
2 results

graph-check-color.py

Blame
  • 07-types.py 1.00 KiB
    # 7 Types principaux en Python
    
    if type(1) is not int : print('oups')
    
    if type('1') is not int : print(1)
    
    type(3.14)
    # float
    
    type(None)
    # NoneType
    
    f = lambda c : c if type(c) is str and  c.isalpha() else '?'
    type(f)
    # function
    
    # Utilisation de f (voir plus loin les "lambda expressions") :
    f('a')  # donne 'a' car 'a' est alphabétique
    f('1')  # donne '?' car '1' n'est  pas alphabétique
    f(1)    # donne '?'  car  1 n'est  pas une chaine
    
    import sys;
    
    print(sys.int_info)
    # sys.int_info(bits_per_digit=30, sizeof_digit=4)
    
    print(sys.float_info)
    # sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
    # min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15,
    # mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
    
    print(sys.getsizeof(float))     # La taille de  la classe float
    # 400
    print(sys.getsizeof(float()))   # La taille d'un  float
    # 24                            # Ce que coute en octes un réel 
                                    # (valeur  + infos supplémentaires)