示例#1
0
from circulos import area, perimetro

radio = float(raw_input('Radio:'))
print 'El area es', area(radio)
print 'El perimetro es', perimetro(radio)
print map(metade, [k*2 for k in [66,77,88,99]])

print [metade(k*2) for k in [66,77,88,99]]

# side effect:efeito colateral (print, concatenacao) != valor de retorno

# Modulos

import sys
for i in sys.path:
    print i

import circulos

print circulos.perimetro(2)
print circulos.area(2)
print circulos.potencia(2,5)
print circulos.nada()
print circulos.potencia.__doc__ # doc definido na propria funcao

# importa funcoes:
from circulos import perimetro,area # ou import *
print perimetro(2)
print area(2)

# modulos prontos python (googlar, p/ nao reinventar a roda):

from math import pi, sin, cos, log, log10, pow

print pi
示例#3
0
'''
Created on 11 de jul de 2017

@author: rsouza
'''

import circulos
circulos.potencia(2, 3)
"""circulos.area(3)
circulos.perimetro(13)
"""