Skip to content

Instantly share code, notes, and snippets.

@mapio
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapio/fe745b947276c834a095 to your computer and use it in GitHub Desktop.
Save mapio/fe745b947276c834a095 to your computer and use it in GitHub Desktop.
Come tenere occupato un nano saccente…
# -*- coding: utf-8 -*-
import subprocess
from random import randint, choice
VOCI = "Alice", "Federica", "Luca", "Paola"
COMPIMENTI = "geniaccio", "sei un figo", "super", "che gallo"
OFFESE = "coglionazzo", "minchione", "cacchio dici"
OP = ( lambda a, b: a + b, "più"), ( lambda a, b: a - b, "meno" )
def dici( frase ):
subprocess.call("say -v {} '{}'".format( choice( VOCI ), frase ), shell=True)
while True:
a = randint( 1, 10 )
b = randint( 1, 10 )
a, b = max( a, b ), min( a, b )
while True:
op = choice( OP )
dici( "Dimmi cosa fa {} {} {}".format( a, op[ 1 ], b ) )
c = int( raw_input() )
if c == op[ 0 ]( a, b ):
dici( "Bravo {}! ".format( choice( COMPIMENTI ) ) )
break
else:
dici( "Hai sbagliato {}, riprova!".format( choice( OFFESE ) ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment