Best Python code snippet using SeleniumBase
calc_yacc.py
Source: calc_yacc.py
1# calculadora_yacc.py2# 3# Aula 8: 2021-04-20, barata4#5# (5+2) * (3-1)6# 177# 2-68#9# Comandos -> Comandos Comando10# | Comando11#12# Comando -> Ler13# | Escrever14# | Despejar15# | Atribuir16#17# Ler -> '?' id18# Escrever -> '!' exp19# Despejar -> '!!'20# Atribuir -> id = Exp21#22# Exp -> Exp '+' Termo23# | Exp '-' Termo24# | Termo25#26# Termo -> Termo '*' Fator27# | Termo '/' Fator28# | Fator29#30# Fator -> '(' Exp ')'31# | num32# | id33#34import ply.yacc as yacc35from calc_lex import tokens36def p_Comandos(p):37 "Comandos : Comandos Comando"38 pass39def p_Comandos_single(p):40 "Comandos : Comando"41 pass42def p_Comando(p):43 """44 Comando : Ler45 | Escrever46 | Despejar47 | Atribuir48 """49 pass50def p_Exp_add(p):51 " Exp : Exp '+' Termo"52 p[0] = p[1] + p[3]53def p_Exp_sub(p):54 " Exp : Exp '-' Termo"55 p[0] = p[1] - p[3]56def p_Exp_termo(p):57 " Exp : Termo "58 p[0] = p[1]59def p_Termo_mul(p):60 " Termo : Termo '*' Fator"61 p[0] = p[1] * p[3]62def p_Termo_div(p):63 " Termo : Termo '/' Fator"64 if(p[3] != 0):65 p[0] = p[1] / p[3]66 else:67 print("Erro: Divisão por 0, a continuar com 0...")68 p[0] = 069def p_Termo_fator(p):70 " Termo : Fator"71 p[0] = p[1]72def p_Fator_num(p):73 " Fator : num "74 p[0] = int(p[1])75def p_Fator_id(p):76 " Fator : id "77 p[0] = p.parser.registers.get(p[1])78def p_Fator_group(p):79 " Fator : '(' Exp ')' "80 p[0] = p[2]81def p_Ler(p):82 " Ler : '?' id"83 valor = int(input("Introduza um valor inteiro: "))84 p.parser.registers.update({p[2]: valor})85def p_Escrever(p):86 " Escrever : '!' Exp"87 print(p[2])88def p_Despejar(p):89 " Despejar : '!' '!' "90 print(p.parser.registers)91def p_Atribuir(p):92 " Atribuir : id '=' Exp"93 p.parser.registers.update({p[1]: p[3]})94def p_error(p):95 print('Erro sintático:', p)96 parser.success = False97# build the parser98parser = yacc.yacc()99# my state100parser.registers = {}101# Read line from input and parse it102import sys103for linha in sys.stdin:104 parser.success = True105 result = parser.parse(linha)106 if parser.success:107 print(result)108 else:...
despejar_balon.py
Source: despejar_balon.py
1import numpy2from act.accion import Accion3from config import Config4from colorama import Fore, Style5config = Config()6class Despejar_balon(Accion):7 def __init__(self, agente, **args) -> None:8 self.agente = agente9 self.tiempo = 0.110 self.tipo = config.ACCIONES.JUGADOR.ACT_DESPEJAR_BALON11 self.estado = None12 self.__descripcion = f"El jugador {self.agente.nombre} "13 def descripcion(self):14 return self.__descripcion15 16 def precondicion(self, partido) -> bool:17 return partido.ultima_accion.tipo == config.ACCIONES.JUGADOR.ACT_SAQUE_ESQUINA and partido.ultima_accion.agente.equipo != self.agente.equipo18 def ejecutar(self, partido):19 # CREO QUE NO SE DEBERIA PONER PROBABILIDADES DE DESPEJE A LOS JUGADORES20 # EL DESPEJE ES UNA ACCION QUE PUEDE SALIR PARA DONDE SEA LITERALMENTE21 # BANDA, SAQUE DE ESQUINA, BALON SUELTO22 despeje = numpy.random.choice(numpy.arange(0, 3), p=[0.35, 0.3, 0.35])23 if despeje:24 self.estado = config.ACCIONES.ESTADO.DESPEJAR_BALON.DESPEJE_LINEA_FINAL25 elif not despeje:26 self.estado = config.ACCIONES.ESTADO.DESPEJAR_BALON.DESPEJE_BANDA27 else:28 self.estado = config.ACCIONES.ESTADO.DESPEJAR_BALON.DESPEJE_JUGADOR29 # print(f'{partido.obtener_tiempo()} {self.descripcion()}{Fore.GREEN}{self.estado}{Style.RESET_ALL}')30 partido.reporte.annadir_a_resumen(f'{partido.obtener_tiempo()} {self.descripcion()}{Fore.GREEN}{self.estado}{Style.RESET_ALL}', partido.pt)31 self.poscondicion(partido)32 def poscondicion(self, partido):33 partido.ultima_accion = self34 partido.pos_balon = None35 if self.estado == config.ACCIONES.ESTADO.DESPEJAR_BALON.DESPEJE_LINEA_FINAL or self.estado == config.ACCIONES.ESTADO.DESPEJAR_BALON.DESPEJE_BANDA:36 partido.estado = config.PARTIDO.ESTADO.DETENIDO ...
ficha7 ex4.py
Source: ficha7 ex4.py
...25 self.cheia += litros26 self.vazia -= litros27 if self.cheia == self.capacidade:28 print('Garrafa Cheia')29 def despejar(self,litros):30 self.cheia = self.cheia - litros31 self.vazia = self.vazia + litros32print()33capacidade = int(input('Qual a Capacidade Máxima? '))34litros = Garrafa(capacidade)35despejar = int(input('Quantos litros foram despejados? '))36litros.despejar(despejar)37litros.imprimir_dados()38encher = int(input('Quantos litros foram enchidos? '))39litros.encher(encher)...
Check out the latest blogs from LambdaTest on this topic:
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.
In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.
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!!