Skip to content

Instantly share code, notes, and snippets.

@mapio mapio/opearazioni.py
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.