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 random | |
| graal = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100] | |
| binf,bsup = min(graal),max(graal) | |
| k = 0 | |
| while( k<len(graal) ): | |
| attempt = list() | |
| for i in xrange(len(graal)): | |
| attempt.append( random.randint( binf, bsup)) | |
| if (graal[k] ==attempt[k]): | |
| print ' '.join( [chr(code) for code in attempt] ) |
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
| # -*- coding: utf-8 -*- | |
| import random | |
| chars=[' ','┌','┐','└','┘','─','│'] | |
| N,M = 32,16 | |
| matr = list() | |
| for i in xrange(M): | |
| line = list() | |
| for i in xrange(N): | |
| line.append( random.choice( chars) ); | |
| matr.append(line) |
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 string, random | |
| print 'enter a list of movies you\'ve watched, separated by comas' | |
| movies = string.split( raw_input() , ',') | |
| # initializing var. for movie ranking | |
| scores = dict(); | |
| for mov in movies: | |
| scores[mov]={ 'won':1, 'lost':1, 'better_th':list() } | |
| for i in xrange( int(round(len(movies)*1.5)) ): # 50% extra questions |
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
| # imports the sleep function; it will add some suspense | |
| from time import sleep | |
| import random | |
| score = 0 | |
| reasonable_player = False | |
| print '*** tough guy simulator ***' | |
| invite_msg = 'so you want to play the russian roulette, hu?' | |
| while(not reasonable_player): | |
| # this inner loop aims at validating the answer |
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 os | |
| from time import sleep | |
| WIDTH = 32; | |
| def old_school_disp( x_pos, velocity): | |
| os.system('clear')# replace by os.system('cls') on windows systems | |
| pos = int(x_pos ) | |
| for i in xrange(WIDTH): | |
| if(pos == i ): | |
| print 'O', | |
| else: |
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 datetime import timedelta, date, datetime | |
| import random | |
| import time | |
| import os | |
| import string #for the split function | |
| def respPositiveTo( question ): | |
| """ | |
| this function aims at displaying a question | |
| & validating the Y/N answer |
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 random | |
| import sys # for exit function | |
| import pygame | |
| from pygame import Rect | |
| # DEFINITIONS | |
| ################################################ | |
| BLACK = ( 0, 0, 0) | |
| DISP_COLOR=(230, 190, 230) #gray with a violet touch | |
| DISP_COLOR_2=(69, 0, 82) #violet |
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 random | |
| import sys # for exit function | |
| import time | |
| import pygame | |
| from pygame import Rect | |
| # DEFINITIONS | |
| ################################################ | |
| DISP_COLOR=(230, 190, 230) #gray with a violet touch | |
| PREDEF_RADIUS = 8 |
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 os | |
| import random | |
| from time import sleep | |
| def disp_word_letter_up( word, ind_letter=-1 ): | |
| chars = list(word) | |
| os.system('clear')# replace by os.system('cls') on windows systems | |
| #upper row | |
| for i in xrange( len(chars)): | |
| if(ind_letter == i ): |
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
| # As you know there's no such thing as a switch statement in python | |
| # but it can be easily simulated using functions | |
| def switch_simu( val, funct_dict): | |
| if( not val in funct_dict.keys()): | |
| funct_dict[ 'default']() | |
| return | |
| funct_dict[ val]() | |
| def below2Message(): |
OlderNewer