Best Python code snippet using yandex-tank
main.py
Source:main.py
1from tkinter import *2import time3import math4game_on = True5total_seconds = 06add_second = ""7needed_text = "THIS IS THE FIRST TIME TO TEST TYPING"8def start_game():9 user_input.config(state=NORMAL)10 user_input.focus()11 def start_timer():12 global total_seconds, game_on, add_second13 # user_input.config(state=NORMAL)14 total_seconds += 115 time.sleep(1)16 format_timer()17 add_second = window.after(10, start_timer)18 start_timer()19def format_timer():20 print(total_seconds)21 minutes = math.floor(total_seconds / 60)22 seconds = total_seconds - (minutes * 60)23 if seconds < 10:24 seconds = f"0{seconds}"25 time_label.config(text=f"{minutes}:{seconds}")26def cancel_timer(event=None):27 global add_second28 print("CANCEL")29 window.after_cancel(add_second)30 final = user_input.get()31 final_array = [x for x in final]32 print(final_array)33 result_label.config(34 text=f"{len(final_array)} characters / {total_seconds} total seconds")35################################# UI #####################################36window = Tk()37window.title("Speed Test")38window.config(padx=20, pady=10, bg="grey", width=500, height=500,39 cursor="hand2")40time_label = Label(text=f"0:00", bg="grey", font=("Arial", 25))41time_label.grid(row=0, column=0, columnspan=2)42test_text = Label(text=needed_text,43 font=("Arial", 35, 'bold'), wraplength=500, justify=LEFT, bg='grey')44test_text.grid(column=0, row=1, columnspan=2, pady=5, padx=5)45user_input = Entry(font=("Arial", 20), width=50, state=DISABLED)46user_input.grid(column=0, row=2, padx=5, pady=5, columnspan=2)47# time_button = Button(text="Start", bg="grey", command=start_timer)48time_button = Button(text="Start", bg="grey", command=start_game)49time_button.grid(column=0, row=3, padx=5, pady=5, columnspan=2)50result_label = Label(bg="grey", font=("Arial", 25))51result_label.grid(row=4, column=0, columnspan=2)52window.bind('<Return>', cancel_timer)...
08_Practice15_2.py
Source:08_Practice15_2.py
...6 self.add_hour(int(time_list[0]))7 self.minute = 08 self.add_minute(int(time_list[1]))9 self.second = 010 self.add_second(int(time_list[2]))11 def add_hour(self,hour):12 self.hour += hour13 self.hour %= 2414 def add_minute(self,minute):15 self.minute += minute16 self.add_hour(self.minute // 60)17 self.minute %= 6018 def add_second(self,second):19 self.second += second20 self.add_minute(self.second // 60)21 self.second %= 6022 def print_watch(self):23 print('ê³ì°ë ìê°ì {}ì {}ë¶ {}ì´ ì
ëë¤.'.format(self.hour,self.minute,self.second))24watch = Watch()25watch.input_time()26watch.add_hour(int(input('ê³ì°í ìê°ì ì
ë ¥íì¸ì >>> ')))27watch.add_minute(int(input('ê³ì°í ë¶ì ì
ë ¥íì¸ì >>> ')))28watch.add_second(int(input('ê³ì°í ì´ì ì
ë ¥íì¸ì >>> ')))...
example.py
Source:example.py
1arr = [2, 4, 6, 8]2result_arr = []3def func1(a):4 print('I am A')5 6 add_first = a + 57 multiply_second = add_first * 38 9 return multiply_second10def func2(a):11 print('I am B')12 13 multiply_first = a * 314 add_second = multiply_first + 515 16 return add_second17for ele in arr:18 result_1 = func1(ele)19 result_2 = func2(ele)20 result_arr.append(result_1)21 result_arr.append(result_2)22 ...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!