Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

shell-funcoes.py

by Cicero Garrozi last modified 2014-07-03 07:24

Click here to get the file

Size 1.1 kB - File type text/python-source

File contents

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> f = lambda x: x[0] != 'a' and x[0] != 'A'
>>> f("teste")
True
>>> f("amanda")
False
>>> f("Adalgiza")
False
>>> f("cicero")
True
>>> f("Beto")
True
>>> l=['fita', 'Adenilton', 'armario', 'gaveta', 'Bruna', 'sai', 'folga', 'impressora']
>>> filter(f, l)
['fita', 'gaveta', 'Bruna', 'sai', 'folga', 'impressora']
>>> def g(x):
	if x[0] != 'a' and x[0] != 'A':
		return True
	else:
		return False

	
>>> l
['fita', 'Adenilton', 'armario', 'gaveta', 'Bruna', 'sai', 'folga', 'impressora']
>>> filter(g, l)
['fita', 'gaveta', 'Bruna', 'sai', 'folga', 'impressora']
>>> filter(lambda x: x[0] != 'a' and x[0] != 'A', l)
['fita', 'gaveta', 'Bruna', 'sai', 'folga', 'impressora']
>>> 
>>> range(0, 11, 2)
[0, 2, 4, 6, 8, 10]
>>> l = range(0, 11, 2)
>>> l
[0, 2, 4, 6, 8, 10]
>>> map(lambda x: x*x, l)
[0, 4, 16, 36, 64, 100]
>>> map(lambda x: x**2, l)
[0, 4, 16, 36, 64, 100]
>>> map(lambda x: x*x, range(0, 11, 2))
[0, 4, 16, 36, 64, 100]
>>> map(lambda x: x*x, range(0, 10000001, 2))

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: