This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import pymongo | |
| import sys | |
| connection = pymongo.MongoClient("mongodb://localhost") | |
| db = connection.reddit | |
| stories = db.stories | |
| def find(): | |
| query = {'title':{'$regex': 'Python'}} | |
| selector = {'title': 1, 'num_comments': 1, '_id': 0} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import pymongo | |
| import sys | |
| connection = pymongo.MongoClient("mongodb://localhost") | |
| db = connection.school | |
| scores = db.scores | |
| def find(): | |
| query = {} | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import pymongo | |
| def get_next_sequence_number(name): | |
| connection = pymongo.MongoClient("mongodb://localhost") | |
| db = connection.test | |
| counters = db.counters | |
| counter = counters.find_and_modify(query={'type':name}, | |
| update={'$inc':{'value':1}}, | |
| upsert=True, new=True) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import pymongo | |
| import gridfs | |
| import sys | |
| con = pymongo.MongoClient("mongodb://localhost") | |
| db = con.test | |
| videos_meta = db.videos_meta | |
| grid = gridfs.GridFS(db, 'videos') | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Oficina MongoDB e Python - FISL | |
| Install python 3.x (provavelmente vc já tem, 3.7 no mínimo) | |
| https://www.python.org/downloads/ | |
| para testar python -V | |
| Install mongoDB última versão | |
| https://www.mongodb.org/downloads | |
| criar diretório \data\db com as permissões necessárias para testar bin\mongod (servidor) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from random import randint | |
| print ('Bem vindo!') | |
| sorteado = randint(1, 100) | |
| chute = 0 | |
| while chute != sorteado: | |
| chute = int(input ('Chute: ')) | |
| if chute == sorteado: | |
| print ('Você venceu!') | |
| else: | |
| if chute > sorteado: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # program template for Spaceship | |
| import simplegui | |
| import math | |
| import random | |
| # globals for user interface | |
| WIDTH = 800 | |
| HEIGHT = 600 | |
| score = 0 | |
| lives = 3 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #conteúdo do texto abaixo original de http://afterfest.com.br/fotos/XV-Edicao | |
| texto = ''' | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title>Fotos BIXURRASCO - XV Edicao - FATEC - 14/09/2013 - Afterfest</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <meta content="all" name="robots" /> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from functools import wraps | |
| def hitchhiker(func): | |
| @wraps(func) | |
| def wrapper(*args, **kwargs): | |
| return 42 | |
| return wrapper | |
| @hitchhiker | |
| def fat(n): | |
| if n < 2: return 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def pi_digits(n): | |
| k, a, b, a1, b1 = 2, 4, 1, 12, 4 | |
| while n > 0: | |
| p, q, k = k*k, 2*k+1, k+1 | |
| a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 | |
| d, d1 = a/b, a1/b1 | |
| while d == d1: | |
| yield int(d) | |
| n -= 1 | |
| a, a1 = 10*(a%b), 10*(a1%b1) |