Last active
August 29, 2015 14:12
-
-
Save mapio/fe745b947276c834a095 to your computer and use it in GitHub Desktop.
Come tenere occupato un nano saccente…
This file contains 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
# -*- 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