Module Expr Str Import alias Import alias Import alias ImportFrom alias Assign NameStore Num Assign NameStore Call AttributeLoad Str attr NameLoad Assign NameStore Str ClassDef bases AttributeLoad NameLoad attr body FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Num Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Num Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Print Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Num NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr If NameLoad body If CompareEq NameLoad AttributeLoad NameLoad attr body Assign NameStore Str Expr Call AttributeLoad NameLoad attr orelse If CompareLt NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad Str attr NameLoad orelse Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body TryExcept body Assign NameStore Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr Return NameLoad handlers ExceptHandler type NameLoad body Expr Call AttributeLoad Call AttributeLoad NameLoad attr attr Str Return NameLoad decorator_list decorator_list FunctionDef arguments args defaults body Expr Str TryFinally body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Raise NameLoad finalbody Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Expr Str Expr Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Print Str Return TupleLoad Num Num NameLoad orelse Print Call AttributeLoad Str attr SubscriptLoad NameLoad Index Num BinOpDiv SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Return TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr Str TupleLoad NameLoad Str Expr Call AttributeLoad NameLoad attr Str TupleLoad NameLoad Str orelse Expr Call AttributeLoad NameLoad attr Str Dict Str Str Str Str NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Expr Str Assign NameStore Num Assign NameStore Call AttributeLoad NameLoad attr Num NameLoad While NameLoad body Assign NameStore Call NameLoad AugAssignAdd NameStore Num If CompareEq NameLoad NameLoad body Print Str Print Call AttributeLoad Str attr NameLoad Return NameLoad orelse If CompareEq NameLoad Num body Print Call AttributeLoad Str attr NameLoad Return NameLoad orelse If CompareLt NameLoad NameLoad body Print Str orelse If CompareGt NameLoad NameLoad body Print Str decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareNotEq NameLoad Num body Print Call AttributeLoad Str attr NameLoad NameLoad Print Call AttributeLoad Str attr BinOpDiv NameLoad NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad Print Str decorator_list FunctionDef arguments args defaults body Expr Str Assign TupleStore NameStore NameStore NameStore Call NameLoad If CompareEq NameLoad Num body Print Str orelse Print Str While NameLoad body Assign NameStore Call NameLoad If NameLoad body AugAssignAdd NameStore NameLoad AugAssignAdd NameStore Num Assign NameStore Call NameLoad Str If CompareNotEq NameLoad Str body Break orelse Break Expr Call NameLoad NameLoad NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr
N/A N/A  Guess the number: Full GUI using PyQt

 N/A random N/A sqlite3 N/A sys PyQt4 QtGui N/A max_nb 100 N/A prompt N/A N/A Guess a number, between 1 and {}, or enter -1 to quit: format max_nb N/A db_file_name guessing_game.db GameWindow N/A N/A QtGui QMainWindow N/A __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super __init__ N/A N/A N/A self create_layout N/A create_layout N/A N/A self N/A N/A N/A N/A N/A self setWindowTitle Guess the number game! N/A N/A N/A self resize 450 200 N/A exit_action N/A N/A QtGui QAction &Quit self N/A N/A N/A exit_action setShortcut Ctrl+Q N/A N/A N/A exit_action setStatusTip Quit game N/A N/A N/A N/A exit_action triggered connect N/A self safe_exit N/A menubar N/A N/A self menuBar N/A actions_menu N/A N/A menubar addMenu &Action N/A N/A N/A actions_menu addAction exit_action N/A N/A N/A N/A N/A self statusBar showMessage Select from menu N/A N/A self label N/A N/A QtGui QLabel Your guess self N/A N/A N/A N/A self label move 10 40 N/A N/A self entry N/A N/A QtGui QLineEdit self N/A N/A N/A N/A N/A self entry returnPressed connect N/A self analyze_guess N/A N/A N/A N/A self entry move 200 40 N/A N/A self new_game_button N/A N/A QtGui QPushButton New Game self N/A N/A N/A N/A N/A self new_game_button clicked connect N/A self new_game N/A N/A N/A self waiting_for_game N/A N/A N/A self show N/A safe_exit N/A N/A self N/A N/A N/A save relevant info, close databse, etc. N/A Goodbye N/A N/A N/A N/A QtGui qApp quit N/A waiting_for_game N/A N/A self N/A N/A N/A N/A N/A N/A self label hide N/A N/A N/A N/A self entry hide N/A N/A N/A N/A self new_game_button show N/A new_game N/A N/A self N/A N/A N/A N/A N/A N/A self label show N/A N/A N/A N/A self entry show N/A N/A N/A N/A self new_game_button hide N/A N/A self goal N/A N/A random randint 1 max_nb N/A analyze_guess N/A N/A self N/A N/A N/A guess N/A N/A self safe_conversion N/A N/A N/A self entry text N/A guess N/A N/A N/A guess N/A self goal N/A N/A message You win N/A N/A N/A self waiting_for_game N/A N/A N/A guess N/A self goal N/A N/A message N/A N/A {} is too low. format guess N/A N/A message N/A N/A {} is too high. format guess N/A N/A N/A N/A N/A self statusBar showMessage message N/A N/A N/A N/A self entry setText N/A safe_conversion N/A N/A self guess N/A N/A N/A N/A N/A guess N/A int N/A N/A N/A self entry text N/A guess N/A N/A N/A ValueError N/A N/A N/A N/A N/A N/A self statusBar showMessage You must enter an integer value N/A False N/A N/A create_db N/A N/A N/A N/A N/A Creates a database file with the required basic structure N/A N/A N/A N/A N/A db N/A N/A sqlite3 connect db_file_name N/A cursor N/A N/A db cursor N/A N/A N/A cursor execute CREATE TABLE IF NOT EXISTS
            stats(name TEXT, nb_games INTEGER, nb_guesses INTEGER)
             N/A N/A N/A db commit N/A N/A N/A Exception N/A e N/A N/A N/A N/A db rollback N/A e N/A N/A N/A N/A db close N/A retrieve_data N/A N/A N/A N/A N/A retrieves nb_games and nb_guesses from default player
       if it exists, otherwise returns 0 for both values.  In addition,
       returns boolean indicating whether or not the data existed.
     N/A N/A create_db N/A db N/A N/A sqlite3 connect db_file_name N/A cursor N/A N/A db cursor N/A N/A N/A cursor execute SELECT name, nb_games, nb_guesses FROM stats N/A stats N/A N/A cursor fetchone N/A N/A N/A db close N/A N/A stats None N/A N/A 
    This is your first game! 
 N/A N/A 0 0 False N/A N/A N/A N/A      So far you have played {} games
            and required {} guesses on average format N/A stats N/A 1 N/A N/A stats N/A 2 N/A stats N/A 1 N/A N/A N/A stats N/A 1 N/A stats N/A 2 True N/A save_data N/A N/A nb_games nb_guesses data_exists N/A N/A N/A saves the relevant data, updating the database if the
       information was already present, inserting it otherwise
     N/A db N/A N/A sqlite3 connect db_file_name N/A cursor N/A N/A db cursor N/A data_exists N/A N/A N/A N/A cursor execute UPDATE stats SET nb_games = ? WHERE name = ?
             N/A nb_games player N/A N/A N/A cursor execute UPDATE stats SET nb_guesses = ? WHERE name = ?
             N/A nb_guesses player N/A N/A N/A N/A cursor execute INSERT INTO stats(name, nb_games, nb_guesses)
            VALUES(:name, :nb_games, :nb_guesses) N/A name nb_games nb_guesses player nb_games nb_guesses N/A N/A N/A db commit N/A N/A N/A db close N/A game N/A N/A N/A N/A N/A A single game

       The number of guesses made is returned if a successful guess was
       made - otherwise the return value is False
     N/A nb_attempts 0 N/A number N/A N/A random randint 1 max_nb N/A True N/A N/A guess N/A safe_input N/A nb_attempts 1 N/A N/A guess number N/A N/A Congratulations, you guessed correctly. N/A N/A N/A You only needed {} attempts. format nb_attempts N/A nb_attempts N/A N/A N/A guess -1 N/A N/A N/A N/A Sorry to see you leave; the number was {}. format number N/A False N/A N/A N/A guess number N/A N/A     Your guess is too low.
 N/A N/A N/A guess number N/A N/A     Your guess is too high.
 N/A goodbye N/A N/A nb_games total_attempts data_exists N/A N/A N/A provide feedback to player included average number of attempts
       required if at least one game was played and, if the statistics
       were updated, saves the new values.
     N/A N/A nb_games 0 N/A N/A N/A N/A You have guessed {} numbers in {} attempts. format nb_games total_attempts N/A N/A N/A The average number of guesses per game was {}. format N/A total_attempts nb_games N/A N/A save_data nb_games total_attempts data_exists N/A Goodbye and thanks for playing N/A play_games N/A N/A N/A N/A N/A play multiple games, keeping track of the total number of games played
       and the total number of attempts made to guess a number
     N/A N/A nb_games total_attempts data_exists N/A retrieve_data N/A N/A nb_games 0 N/A N/A Welcome to the Guessing Game!
 N/A N/A Welcome back to the Guessing Game!
 N/A True N/A N/A result N/A game N/A result N/A N/A total_attempts result N/A nb_games 1 N/A ans N/A input Another game? 'y' to continue, anything else to quit. N/A N/A ans y N/A N/A N/A N/A N/A N/A goodbye nb_games total_attempts data_exists N/A N/A N/A __name__ __main__ N/A N/A app N/A N/A QtGui QApplication N/A sys argv N/A window N/A GameWindow N/A N/A N/A N/A app aboutToQuit connect N/A window safe_exit N/A N/A N/A sys exit N/A N/A app exec_