コード例 #1
0
ファイル: backup.py プロジェクト: boris-volkov/Python
def times(player, current_record, how_many):
    done = 0

    def ask(a):
        user_guess = ""
        while not user_guess.isnumeric():
            user_guess = input(make_string(a))
            if not user_guess.isnumeric():
               q.empty_thread().start()
               only = "numbers only please"
               print(red + f'{only:^19}')
        user_guess = int(user_guess)
        if not user_guess == a.ans:
            print(red+ progress_bar(done/how_many))
            q.fail_thread().start()
            ask(a)
    
    print(screen)
    intro = 'press enter'
    _ = input(f'{intro:^19}')
    
    length = len(player.list)

    for _ in range(how_many):
        i = random.randint(0,length-1)
        print(yellow + progress_bar(done/how_many))
        start = time.perf_counter()
        ask(player.list[i])
        finish = time.perf_counter()
        elapsed = finish - start
        Problem.update_avg(player.list[i], elapsed)
        player.list[i].count += 1 
        if player.list[i].avg < 5:
            Record.update(current_record, player.list[i])
            Problem.next_problem(player.biggest)
            player.list[i] = player.biggest
            print('replaced')
            player.mastered += 1
            q.success_thread().start()
        done += 1
    

    d = 'done'
    print(bg_rgb(210,180,110) + rgb(0,0,0) + f'{d:^19}' + clear + green)  
    print(q.frog + '-great job!' '\n' + yellow + 'practice pays off.' + '\n' +cyan +'mastered: ' + str(player.mastered) + ' facts')
    
    _ = input()
コード例 #2
0
ファイル: plus.py プロジェクト: boris-volkov/Python
def times(limit):
    done = 0
    table = []
    for i in range(2, limit):
        for j in range(i, limit):
            table.append((j, i, i + j))
    random.shuffle(table)

    full_list = len(table)

    def ask(a):
        user_guess = ""
        while not user_guess.isnumeric():
            user_guess = input(make_string(a))
            if not user_guess.isnumeric():
                q.empty_thread().start()
                only = "numbers only please"
                print(red + f'{only:^19}')
        user_guess = int(user_guess)
        if not user_guess == a[2]:
            print(red + progress_bar(done / full_list))
            q.fail_thread().start()
            ask(a)

    print(screen)
    intro = 'press enter'
    _ = input(f'{intro:^19}')
    start = time.perf_counter()
    while table:
        print(yellow + progress_bar(done / full_list))
        ask(table.pop())
        q.success_thread().start()
        done += 1
    finish = time.perf_counter()
    elapsed = round(finish - start)
    d = 'done'
    print(bg_rgb(210, 180, 110) + rgb(0, 0, 0) + f'{d:^19}' + clear + green)
    print(q.frog + '-great job!'
          '\n' + yellow + 'practice pays off.' + '\n' + cyan + 'took: ' +
          str(elapsed) + " seconds")
    _ = input()
コード例 #3
0
ファイル: sixteens.py プロジェクト: boris-volkov/Python
    '\U00002469',
    '\U0000246a',
    '\U0000246b',
    '\U0000246c',
    '\U0000246d',
    '\U0000246e',
    '\U0000246f',
    '\U00002470',
    '\U00002471',
    '\U00002472',
    '\U00002473',
]

board_colors = [black, yellow, cyan, red, magenta, yellow]
board_colors = [
    colors.bg_rgb(250, 250, 0),
    colors.bg_rgb(50, 150, 255),
    colors.bg_rgb(255, 80, 80),
    colors.bg_rgb(50, 205, 55)
]

#board_colors = [white, black, white, black]

margin = ' ' * 5
white = colors.rgb(255, 255, 255)
black = colors.rgb(0, 0, 0)


def print_grid(grid):
    for row in grid:
        print(margin + black, end='')
コード例 #4
0
def challenge(limit, hardmode = False, lvl = 5,
               addition = True, 
               subtraction = True, 
               multiplication = True, 
               division = True):
    while 1:
        global level
        global g_elapsed
        global g_limit
        g_limit = limit
        g_elapsed = 0
        total_probs = 0
        time_series = [(0,5,'yellow')]
        local_time = time.asctime( time.localtime(time.time()) )
        level = lvl
        print(intro_string())
        adds = Addition()
        subs = Subtraction()
        mult = Multiplication ()
        divs = Division()
        age = ''
        while age == '':
            age = input(yellow + '  ENTER your name  \n  ' + green)
            if age == '':
                print('\033[3A')
        print(screen)
        total_time = 0
        limit = limit + time.time()
        while total_time < limit:
            if addition       : 
                start = time.perf_counter()
                elapsed = adds.question()
                finish = time.perf_counter()
                print(finish-start)
                total_time = time.time()
                total_probs += 1
                print(str(round(total_time)))
                time.sleep(1)
            if total_time > limit: break
            if subtraction    : 
                elapsed = subs.question()
                total_time = time.time()
                total_probs += 1
                time.sleep(1)
            if total_time > limit: break
            if multiplication : 
                elapsed = mult.question()
                total_time = time.time()
                total_probs += 1
                time.sleep(1)
            if total_time > limit: break
            if division       : 
                elapsed = divs.question()
                total_time = time.time()
                total_probs += 1
                time.sleep(1)
        
        d = 'done'
        print(bg_rgb(210,180,110) + rgb(0,0,0) + f'{d:^19}' + clear + green)
        print(frog + '-great job!' '\n' + yellow + 'practice pays off.' + '\n' +cyan +'level: ' +  str(round(level)))
        finish_song() 

        if division == False or addition == False or subtraction == False or multiplication == False:
            return

        already_there = path.exists('records.csv')
        with open('records.csv', mode='a+') as csv_file:
            fieldnames = ['age', 'level', 'problems', 'time','add_av','sub_av','mul_av','div_av', 'date', 'time_series']
            writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
            if not already_there:
                writer.writeheader()
            writer.writerow({'age'     : age,
                             'level'   : round(level), 
                             'problems': total_probs,
                             'time'    : limit,
                             'add_av'  : adds.av_time,
                             'sub_av'  : subs.av_time,
                             'mul_av'  : mult.av_time,
                             'div_av'  : divs.av_time,
                             'date'    : local_time,
                             'time_series' :time_series
                            })

        total_time = 0
        level = 5
        mode = False
        adds = None
        subs = None
        mult = None
        divs = None
        _ = input()