How to use check_symbol method in refurb

Best Python code snippet using refurb_python

task1.2.py

Source:task1.2.py Github

copy

Full Screen

1def additional(a, i):2 rezult = a + i3 return rezult4def subtraction(a, i):5 rezult = a - i6 return rezult7def multiplication(a, i):8 rezult = a * i9 return rezult10def division(a, i):11 rezult = a / i12 return rezult13def exponentiation(a, i):14 rezult = a ** i15 return rezult16def integer_division(a, i):17 rezult = a // i18 return rezult19def remainder_division(a, i):20 rezult = a % i21 return rezult22def proverka(c):23 c = list(c)24 check_digit = False25 check_symbol = False26 for i in range(len(c)):27 if c[i].isdigit():28 check_digit = True29 i = len(c)30 for i in range(len(c)):31 if c[i] == "+" or c[i] == "-" or c[i] == "*" or c[i] == "/" or c[i] == "**" or c[i] == "%" :32 check_symbol = True33 i = len(c)34 if (check_digit is True) and (check_symbol is True):35 c = "".join(c)36 c, e = parse(c)37 return c, e38 elif (check_digit is True) and (check_symbol is False):39 c = "".join(c) + "+"40 c, e = parse(c)41 return c, e42 elif (check_digit is False) and (check_symbol is True):43 b = str(ord(c[0]))44 c = "".join(c) + b45 c, e = parse(c)46 print("""Вы ввели строку не содержащую хотя бы одну цифру...47 Вывод в соответствие с кодом ASCII: """+str(b))48 return c, e49 elif (check_digit is False) and (check_symbol is False):50 b = str(ord(c[0]))51 print("""Вы ввели строку не содержащую хотя бы одну цифру...52 Вывод в соответствие с кодом ASCII: """+str(b))53 c = "".join(c) + b + "+"54 c, e = parse(c)55 return c, e56def parse(b):57 c = []58 e = []59 for i in b:60 if i.isdigit() or i == "." or i == ",":61 if i == ",":62 i = "."63 c.append(i)64 elif i == "+" or i == "-" or i == "*" or i == "/" or i == "%" :65 e.append(i)66 return c, e67def get_operation(e):68 operation = ""69 if len(e) > 1:70 if e[0] == "/" and e[1] == "/":71 operation = "//"72 return operation73 elif e[0] == "*" and e[1] == "*":74 operation = "**"75 return operation76 else:77 operation = e[0]78 return operation79 else:80 operation = e[0]81 return operation82def get_number(c):83 c = "".join(c)84 if c.count(".") == 1:85 c = float(c)86 return c87 elif c.count(".") > 1:88 count = True89 d = []90 for i in c:91 if (count is True and i == ".") or (i.isdigit()):92 d.append(i)93 if (d.count(".") == 1):94 count = False95 c = float("".join(d))96 return c97 else:98 c = int(c)99 return c100 101def proverka_a(a):102 a = list(a)103 check_digit = False104 check_symbol = False105 for i in range(len(a)):106 if a[i].isdigit():107 check_digit = True108 i = len(a)109 for i in range(len(a)):110 if a[i] == "+" or a[i] == "-" or a[i] == "*" or a[i] == "/" or a[i] == "**" or a[i] == "//" or a[i] == "%" :111 check_symbol = True112 i = len(a)113 if (check_digit is True) and (check_symbol is True):114 a = "".join(a)115 rez = parse(a)116 a = rez[0]117 a = get_number(a)118 return a119 elif (check_digit is True) and (check_symbol is False):120 a = "".join(a)121 rez = parse(a)122 a = rez[0]123 a = get_number(a)124 return a125 elif (check_digit is False) and (check_symbol is True):126 b = ord(a[0])127 print("""Вы ввели строку не содержащую хотя бы одну цифру...128 Вывод в соответствие с кодом ASCII: """+str(b))129 return b130 elif (check_digit is False) and (check_symbol is False):131 b = ord(a[0])132 print("""Вы ввели строку не содержащую хотя бы одну цифру...133 Вывод в соответствие с кодом ASCII: """+str(b))134 return b 135if __name__=="__main__":136 a = input("Введите число: ")137 while a == "":138 a = input("Пустая строка? ДА ТЫ РОФЛИШЬ!!! Введи число: ")139 a = proverka_a(a)140 start = True141 while start == True:142 b = input("Введите знак операции и число (например: + 2): ")143 while b == "":144 b = input("Пустая строка? ДА ТЫ РОФЛИШЬ!! Введи знак операции и число (например: + 2): ")145 if b.count("=") < 1:146 c, e = proverka(b)147 print(c)148 print(e)149 c = get_number(c)150 operation = get_operation(e)151 print(str(c))152 print(operation)153 print(str(a))154 if operation == "+":155 a = additional(a, c)156 elif operation == "-":157 a = subtraction(a, c)158 elif operation == "*":159 a = multiplication(a, c)160 elif operation == "/":161 if c != 0:162 a = division(a, c)163 else:164 c, e = proverka(b)165 c = get_number(c)166 operation = get_operation(e)167 elif operation == "**":168 a = exponentiation(a, c)169 elif operation == "//":170 if c != 0:171 a = integer_division(a, c)172 else:173 c, e = proverka(b)174 c = get_number(c)175 operation = get_operation(e)176 elif operation == "%":177 if c != 0:178 a = remainder_division(a, c)179 else:180 c, e = proverka(b)181 c = get_number(c)182 operation = get_operation(e)183 print("Результат: "+str(a))184 else:185 print("Итого: "+str(a))...

Full Screen

Full Screen

tictactoe.py

Source:tictactoe.py Github

copy

Full Screen

1import random2board = []345def print_board():6 print('-------------')7 for i in range(3):8 for j in range(3):9 if board[i][j] == 'X':10 print('| X ', end='')11 elif board[i][j] == 'O':12 print('| O ', end='')13 else:14 print('| ', end='')15 print('| ')16 print('-------------')171819def check_winner(player):20 check_symbol = 'X' if player else 'O'21 won = False22 for i in range(3):23 # check a horizontal way24 if board[i][0] == check_symbol and board[i][1] == check_symbol and board[i][2] == check_symbol:25 won = True26 break27 # check a vertical way28 if board[0][i] == check_symbol and board[1][i] == check_symbol and board[2][i] == check_symbol:29 won = True30 break31 # check a diagonal way32 if board[0][0] == check_symbol and board[1][1] == check_symbol and board[2][2] == check_symbol:33 won = True3435 if board[2][0] == check_symbol and board[1][1] == check_symbol and board[0][2] == check_symbol:36 won = True3738 return won394041def computer_move():42 while True:43 i = random.randint(0, 2)44 j = random.randint(0, 2)45 if board[i][j] == '':46 break47 board[i][j] = 'O'484950def board_check_full():51 board_full = True52 for i in range(3):53 for j in range(3):54 if board[i][j] == '':55 board_full = False56 break57 return board_full585960for i in range(3):61 row = []62 for j in range(3):63 row.append('')64 board.append(row)6566# starting from here67game_continue = True68while game_continue:69 data = input('Enter your position e.g.(1,1) \n')7071 try:72 position = data.split(',')73 x = int(position[0].strip())74 y = int(position[1].strip())75 skip_round = False76 if board[x-1][y-1] != '':77 print('sry, it position already taken try again')78 skip_round = True79 else:80 board[x-1][y-1] = 'X'81 print_board()8283 if not skip_round:84 player_won = check_winner(True)85 if player_won:86 print('\U0001F389 \U0001F38A \U0001F388 \U0001F389 \U0001F38A \U0001F388')87 print('You won Congratulation')88 game_continue = False8990 board_full = board_check_full()91 if board_full and not player_won:92 print('it\'s tie!')93 game_continue = False9495 if game_continue:96 computer_move()97 print_board()98 computer_won = check_winner(False)99 if computer_won:100 print('Computer won the game')101 game_continue = False102 except:103 print("Invalid input, try again") ...

Full Screen

Full Screen

test_symbol_table.py

Source:test_symbol_table.py Github

copy

Full Screen

1def check_symbol(symbol, binding, typ):2 assert symbol["binding"] == binding3 assert symbol["type"] == typ4def test_symbol_table(session, cpg_db_v2, optimization_flags):5 cpg = cpg_db_v2(6 "symbol-menagerie.c", compile_options=dict(extra_compiler_flags=optimization_flags)7 )8 module = session.query(cpg.Module).one()9 # "foo" is a weakly bound function.10 foo = [s for s in module.symbols if s["name"] == "foo"]11 assert len(foo) == 112 foo = next(iter(foo))13 check_symbol(foo, "STB_WEAK", "STT_FUNC")14 # "bar" is a locally bound (i.e., static) function.15 bar = [s for s in module.symbols if s["name"] == "bar"]16 assert len(bar) == 117 bar = next(iter(bar))18 check_symbol(bar, "STB_LOCAL", "STT_FUNC")19 # "barp" is a locally bound (i.e., static) global variable (i.e., object)20 barp = [s for s in module.symbols if s["name"] == "barp"]21 assert len(barp) == 122 barp = next(iter(barp))23 check_symbol(barp, "STB_LOCAL", "STT_OBJECT")24 # "barp_result" is an globally bound (i.e., non-static) global variable (i.e., object)25 barp_result = [s for s in module.symbols if s["name"] == "barp_result"]26 assert len(barp_result) == 127 barp_result = next(iter(barp_result))28 check_symbol(barp_result, "STB_GLOBAL", "STT_OBJECT")29 # "baz" is a globally bound (i.e., non-static) function30 baz = [s for s in module.symbols if s["name"] == "baz"]31 assert len(baz) == 132 baz = next(iter(baz))33 check_symbol(baz, "STB_GLOBAL", "STT_FUNC")34 # "baz_alias" is a globally bound alias of "baz"35 baz_alias = [s for s in module.symbols if s["name"] == "baz_alias"]36 assert len(baz_alias) == 137 baz_alias = next(iter(baz_alias))38 check_symbol(baz_alias, "STB_GLOBAL", "STT_FUNC")39 # "baz_weak_alias" is a weakly bound alias of "baz"40 baz_weak_alias = [s for s in module.symbols if s["name"] == "baz_weak_alias"]41 assert len(baz_weak_alias) == 142 baz_weak_alias = next(iter(baz_weak_alias))43 check_symbol(baz_weak_alias, "STB_WEAK", "STT_FUNC")44 # "quux" is a globally bound thread-local variable45 quux = [s for s in module.symbols if s["name"] == "quux"]46 assert len(quux) == 147 quux = next(iter(quux))48 check_symbol(quux, "STB_GLOBAL", "STT_TLS")49 # "quux2" is a locally bound (i.e., static) thread-local variable50 quux2 = [s for s in module.symbols if s["name"] == "quux2"]51 assert len(quux2) == 152 quux2 = next(iter(quux2))...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run refurb automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful