Best Python code snippet using hypothesis
6.22.py
Source:6.22.py
1import calendar2# генеаÑÑÐ¸Ñ Ñагов3import random4# СÑеднее ÑиÑло Ñагов.5# ÐлобалÑÐ½Ð°Ñ ÐºÐ¾Ð½ÑÑанÑÑ6YEAR = 365 # кол-во дней в годÑ.7# Ðол-во дней в меÑÑÑе.8January = calendar.monthrange(2021, 1)[1]9February = calendar.monthrange(2021, 2)[1]10March = calendar.monthrange(2021, 3)[1]11April = calendar.monthrange(2021, 4)[1]12May = calendar.monthrange(2021, 5)[1]13June = calendar.monthrange(2021, 6)[1]14July = calendar.monthrange(2021, 7)[1]15August = calendar.monthrange(2021, 8)[1]16September = calendar.monthrange(2021, 9)[1]17October = calendar.monthrange(2021, 10)[1]18November = calendar.monthrange(2021, 11)[1]19December = calendar.monthrange(2021, 12)[1]20def main():21 # ÐÑÐ½Ð¾Ð²Ð½Ð°Ñ ÑÑнкÑиÑ.22 print(23 """24 ÐенÑ:25 1 - подгоÑовиÑÑ Ñайл Ñ ÐºÐ¾Ð»-вом Ñагов за 1 год(365 дней)26 2 - ÐÑвеÑÑи ÑÑеднее кол-во Ñагов в каждом меÑÑÑе.27 """28 )29 choice = int(input('ÐÐ°Ñ Ð²ÑÐ±Ð¾Ñ - '))30 if choice == 1:31 gen_steps()32 elif choice == 2:33 steps_mount()34 else:35 print('Такого пÑнкÑа Ð½ÐµÑ Ð² менÑ.')36def gen_steps():37 # ÐенеÑаÑÐ¸Ñ Ñагов за 1 год(365 дней)38 # Ð¡Ð¾Ð·Ð´Ð°Ñ ÑÑÑÑÑик ÑÑÑок39 count = 040 # ÐÑкÑÑÐ²Ð°Ñ Ñайл Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи ÑлÑÑайного кол-ва41 # Ñагов за 1 год(365 дней).42 steps = open('steps.txt', 'w')43 # ÐÑполÑзÑÑ Ñикл ÑÑÐ¾Ð±Ñ Ð·Ð°Ð¿Ð¸ÑаÑÑ Ñаги в Ñайл.44 while count != YEAR:45 step = random.randint(1, 10000)46 steps.write(str(step) + "\n")47 count += 148 # ÐакÑÑÐ²Ð°Ñ Ñайл.49 steps.close()50def steps_mount():51 # СÑеднее кол-во Ñагов ÑделанÑÑ
в ÑеÑении меÑÑÑа.52 # ÐеÑеменнÑе Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸Ñи ÑÑеднего кол-во Ñагов53 # за каждÑй меÑÑÑ.54 total1 = 055 total2 = 056 total3 = 057 total4 = 058 total5 = 059 total6 = 060 total7 = 061 total8 = 062 total9 = 063 total10 = 064 total11 = 065 total12 = 066 # ÐÑкÑÑÐ²Ð°Ñ Ñайл в Ñежиме ÑÑениÑ.67 year_steps = open('steps.txt', 'r')68 # ÐеÑÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑÑÑа ÑÑÑок в Ñайле.69 count_strings = 070 while count_strings != YEAR:71 count_strings += 172 if count_strings <= January:73 total1 += int(year_steps.readline())74 elif count_strings <= (January + February):75 total2 += int(year_steps.readline())76 elif count_strings <= (January + February + March):77 total3 += int(year_steps.readline())78 elif count_strings <= (January + February + March + April):79 total4 += int(year_steps.readline())80 elif count_strings <= (January + February + March + April +81 May):82 total5 += int(year_steps.readline())83 elif count_strings <= (January + February + March + April +84 May + June):85 total6 += int(year_steps.readline())86 elif count_strings <= (January + February + March + April +87 May + June + July):88 total7 += int(year_steps.readline())89 elif count_strings <= (January + February + March + April +90 May + June + July + August):91 total8 += int(year_steps.readline())92 elif count_strings <= (January + February + March + April +93 May + June + July + August + September):94 total9 += int(year_steps.readline())95 elif count_strings <= (January + February + March + April +96 May + June + July + August + September + October):97 total10 += int(year_steps.readline())98 elif count_strings <= (January + February + March + April +99 May + June + July + August + September + October +100 November):101 total11 += int(year_steps.readline())102 elif count_strings <= (January + February + March + April +103 May + June + July + August + September + October +104 November + December):105 total12 += int(year_steps.readline())106 print('СÑеднее колиÑеÑÑво Ñагов.\n')107 print('Ðа ЯнваÑÑ -',total1 // January)108 print('Ðа ФевÑÐ°Ð»Ñ -',total2 // February)109 print('Ðа ÐаÑÑ -', total3 // March)110 print('Ðа ÐпÑÐµÐ»Ñ -', total4 // April)111 print('Ðа Ðай -',total5 // May)112 print('Ðа ÐÑÐ½Ñ -', total6 // June)113 print('Ðа ÐÑлÑ', total7 // July)114 print('Ðа ÐвгÑÑÑ', total8 // August)115 print('Ðа СенÑÑбÑÑ', total9 // September)116 print('Ðа ÐкÑÑбÑÑ -', total10 // October)117 print('Ðа ÐоÑбÑÑ -',total11 // November)118 print('Ðа ÐекабÑÑ -',total12 // December)119# ÐÑзÑÐ²Ð°Ñ Ð³Ð»Ð°Ð²Ð½ÑÑ ÑÑнкÑиÑ....
sorted_strings.py
Source:sorted_strings.py
1'''2ÐоÑле ÑÐ°Ñ Ñ Ð¿ÐµÑенÑками ÑебÑÑа ÑеÑили поигÑаÑÑ Ð² игÑÑ.3Ðан Ð½Ð°Ð±Ð¾Ñ ÑÑÑок одинаковой длинÑ, ÑоÑÑоÑÑиÑ
из маленÑкиÑ
лаÑинÑкиÑ
бÑкв.4ÐÑжно опÑеделиÑÑ, какое минималÑное ÑиÑло позиÑий в каждой из5ÑÑÑок нÑжно ÑдалиÑÑ, ÑÑÐ¾Ð±Ñ Ð±ÑÐºÐ²Ñ Ð² ÑÑÑокаÑ
, ÑооÑвеÑÑÑвÑÑÑие каждомÑ6индекÑÑ Ð¸Ð· оÑÑавÑиÑ
ÑÑ,бÑли лекÑикогÑаÑиÑеÑки оÑÑоÑÑиÑÐ¾Ð²Ð°Ð½Ñ Ð¿Ð¾ неÑбÑваниÑ7(Ñо еÑÑÑ Ð¿Ð¾ÑледоваÑелÑноÑÑи, ÑиÑаÑÑиеÑÑ ÑвеÑÑ
Ñ Ð²Ð½Ð¸Ð·,8Ð´Ð¾Ð»Ð¶Ð½Ñ Ð±ÑÑÑ Ð¾ÑÑоÑÑиÑÐ¾Ð²Ð°Ð½Ñ Ð¿Ð¾ неÑбÑваниÑ).9Ðак пÑоиÑÑ
Ð¾Ð´Ð¸Ñ Ñдаление â один ÑÑÐ¾Ð»Ð±ÐµÑ Ð¿Ð¾Ð»Ð½Ð¾ÑÑÑÑ Ð±ÐµÑÐµÑ Ð¸ ÑниÑÑожаеÑÑÑ.10'''11def sorted_strings(count_strings, length_strings, strings):12 x = 013 y = 014 count_del = 015 while x < length_strings and count_strings > 1:16 if strings[y][x] > strings[y+1][x]:17 count_del += 118 print(y, strings[y][x], x)19 x += 120 y = 021 else:22 print(strings[y][x], strings[y+1][x])23 y += 124 if y >= count_strings - 1:25 y = 026 x += 127 return count_del28if __name__ == '__main__':29 count_strings = int(input())30 length_strings = int(input())31 strings = []32 for i in range(count_strings):33 strings.append(input())34 print(sorted_strings(count_strings, length_strings, strings))...
task1.py
Source:task1.py
1# ÐапиÑиÑе ÑÑнкÑÐ¸Ñ read_last(lines, file),2# коÑоÑÐ°Ñ Ð±ÑÐ´ÐµÑ Ð¾ÑкÑÑваÑÑ Ð¾Ð¿ÑеделеннÑй Ñайл file и вÑводиÑÑ3# на пеÑаÑÑ Ð¿Ð¾ÑÑÑоÑно поÑледние ÑÑÑоки в колиÑеÑÑве lines.4# ÐапиÑаÑÑ Ð½ÐµÑколÑко вÑзовов меÑода как Ð´Ð»Ñ Ð¿Ð¾Ð·Ð¸ÑивнÑÑ
и5# негаÑивнÑÑ
ваÑианÑов. ФÑнкÑÐ¸Ñ Ð´Ð¾Ð»Ð¶Ð½Ð° обÑабаÑÑваÑÑ Ð²Ñе ÑиÑÑаÑии6def read_last(lines, my_file):7 with open(my_file) as new_file:8 list_of_strings = new_file.readlines()9 count_strings = len(list_of_strings)10 out_line = count_strings - lines11 if lines <= 0:12 print("ÐевеÑное колиÑеÑÑво ÑÑÑок")13 elif count_strings >= lines:14 print(f'ÐоÑледние {lines} ÑÑÑоки в Ñайле:')15 while out_line != count_strings:16 print(list_of_strings[out_line], end='')17 out_line += 118 elif count_strings <= 0:19 print("Файл пÑÑÑой")20 else:21 print(f"Ð Ñайле менÑÑе {lines} ÑÑÑок")22my_file = "article.txt"...
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!!