Best Python code snippet using pandera_python
Personnages.py
Source: Personnages.py
1from random import randint, uniform2class Nom:3 """Classe qui definie les info nominatifs du joueur"""4 def __init__(self, nom_personnage, nom_heros, genre):5 self.nom_personnage = nom_personnage6 self.nom_heros = nom_heros7 self.genre = genre8class Caracteristiques:9 """ Classe qui definie les attributs du personnage"""10 def __init__(self, force, dexterite, constitution, intelligence, sagesse, charisme):11 self.force = force12 self.dexterite = dexterite13 self.constitution = constitution14 self.intelligence = intelligence15 self.sagesse = sagesse16 self.charisme = charisme17class Physique:18 """Classe qui definie le physique du personnage"""19 def __init__(self, p_max, p_min, a_min, a_max, t_min, t_max):20 self.p_max = p_max21 self.p_min = p_min22 self.a_min = a_min23 self.a_max = a_max24 self.t_min = t_min25 self.t_max = t_max26 self.poids = 027 self.age = 028 self.taille = 029 def calcul_poids(self, p_min, p_max):30 self.poids = randint(p_min, p_max)31 def calcul_age(self, a_min, a_max):32 self.age = randint(a_min, a_max)33 def calcul_taille(self, t_min, t_max):34 self.taille = uniform(t_min, t_max)35# Classes filles qui regroupent les classes mere et rajoutent la race36class Demi_Elfe(Nom, Physique, Caracteristiques):37 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,38 force, dexterite, constitution, intelligence, sagesse, charisme):39 Nom.__init__(self, nom_personnage, nom_heros, genre)40 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)41 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)42 self.race = "Demi-Elfe"43 self.calcul_poids(p_min,p_max)44 self.calcul_age(a_min,a_max)45 self.calcul_taille(t_min,t_max)46class Demi_Orques(Nom, Physique, Caracteristiques):47 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,48 force, dexterite, constitution, intelligence, sagesse, charisme):49 Nom.__init__(self, nom_personnage, nom_heros, genre)50 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)51 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)52 self.race = "Demi-Orques"53 self.calcul_poids(p_min, p_max)54 self.calcul_age(a_min, a_max)55 self.calcul_taille(t_min, t_max)56class Elfes_Hauts(Nom, Physique, Caracteristiques):57 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,58 force, dexterite, constitution, intelligence, sagesse, charisme):59 Nom.__init__(self, nom_personnage, nom_heros, genre)60 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)61 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)62 self.race = "Elfes Hauts"63 self.calcul_poids(p_min, p_max)64 self.calcul_age(a_min, a_max)65 self.calcul_taille(t_min, t_max)66class Elfes_Sylvains(Nom, Physique, Caracteristiques):67 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,68 force, dexterite, constitution, intelligence, sagesse, charisme):69 Nom.__init__(self, nom_personnage, nom_heros, genre)70 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)71 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)72 self.race = "Elfes Sylvains"73 self.calcul_poids(p_min, p_max)74 self.calcul_age(a_min, a_max)75 self.calcul_taille(t_min, t_max)76class Gnomes(Nom, Physique, Caracteristiques):77 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,78 force, dexterite, constitution, intelligence, sagesse, charisme):79 Nom.__init__(self, nom_personnage, nom_heros, genre)80 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)81 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)82 self.race = "Gnomes"83 self.calcul_poids(p_min, p_max)84 self.calcul_age(a_min, a_max)85 self.calcul_taille(t_min, t_max)86class Halfelins(Nom, Physique, Caracteristiques):87 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,88 force, dexterite, constitution, intelligence, sagesse, charisme):89 Nom.__init__(self, nom_personnage, nom_heros, genre)90 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)91 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)92 self.race = "Halfelins"93 self.calcul_poids(p_min, p_max)94 self.calcul_age(a_min, a_max)95 self.calcul_taille(t_min, t_max)96class Humains(Nom, Physique, Caracteristiques):97 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,98 force, dexterite, constitution, intelligence, sagesse, charisme):99 Nom.__init__(self, nom_personnage, nom_heros, genre)100 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)101 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)102 self.race = "Humains"103 self.calcul_poids(p_min, p_max)104 self.calcul_age(a_min, a_max)105 self.calcul_taille(t_min, t_max)106class Nains(Nom, Physique, Caracteristiques):107 def __init__(self, nom_personnage, nom_heros, genre, p_max, p_min, a_min, a_max, t_min, t_max,108 force, dexterite, constitution, intelligence, sagesse, charisme):109 Nom.__init__(self, nom_personnage, nom_heros, genre)110 Physique.__init__(self, p_max, p_min, a_min, a_max, t_min, t_max)111 Caracteristiques.__init__(self, force, dexterite, constitution, intelligence, sagesse, charisme)112 self.race = "Nains"113 self.calcul_poids(p_min, p_max)114 self.calcul_age(a_min, a_max)...
helpers.py
Source: helpers.py
1from collections import namedtuple2Cuboid = namedtuple("Cuboid", "state x y z")3def axis_intersection(a_min, a_max, b_min, b_max):4 # we have to consider 4 cases5 if a_min >= b_min and b_max >= a_min and b_max <= a_max:6 # first case:7 # a_min *----------* a_max8 # b_min *---------* b_max9 return b_max - a_min + 1, a_min, b_max10 elif b_min >= a_min and b_min <= a_max and b_max >= a_max:11 # second case:12 # a_min *----------* a_max13 # b_min *--------* b_max14 return a_max - b_min + 1, b_min, a_max15 elif b_min >= a_min and b_max <= a_max:16 # third case:17 # a_min *--------------------* a_max18 # b_min *--------* b_max19 return b_max - b_min + 1, b_min, b_max20 elif a_min >= b_min and a_max <= b_max:21 # fourth case:22 # b_min *--------------------* b_max23 # a_min *--------* a_max24 return a_max - a_min + 1, a_min, a_max25 return 0, 0, 026def find_intersection_volume(a, b):27 # finds volume of two cubes interesection28 side_x, _, _ = axis_intersection(a.x[0], a.x[1], b.x[0], b.x[1])29 side_y, _, _ = axis_intersection(a.y[0], a.y[1], b.y[0], b.y[1])30 side_z, _, _ = axis_intersection(a.z[0], a.z[1], b.z[0], b.z[1])31 return side_x * side_y * side_z32def find_intersection_cuboid(a, b, intersection_state):33 _, x_min, x_max = axis_intersection(a.x[0], a.x[1], b.x[0], b.x[1])34 _, y_min, y_max = axis_intersection(a.y[0], a.y[1], b.y[0], b.y[1])35 _, z_min, z_max = axis_intersection(a.z[0], a.z[1], b.z[0], b.z[1])36 return Cuboid(37 x=(x_min, x_max), y=(y_min, y_max), z=(z_min, z_max), state=intersection_state38 )39def get_volume(cuboid):40 size_x = cuboid.x[1] - cuboid.x[0] + 141 size_y = cuboid.y[1] - cuboid.y[0] + 142 size_z = cuboid.z[1] - cuboid.z[0] + 1...
FAIRELCT.py
Source: FAIRELCT.py
1# Question : https://www.codechef.com/JAN21B/problems/FAIRELCT2try:3 t = int(input())4 while t:5 n, m = map(int,input().split())6 a = list(map(int,input().split()))7 b = list(map(int,input().split()))8 a_sum = sum(a)9 b_sum = sum(b)10 a_min = min(a)11 b_max = max(b)12 swaps=013 while a_sum<=b_sum and b_max>a_min:14 a_min = min(a)15 b_max = max(b)16 a_sum = a_sum - a_min + b_max17 b_sum = b_sum - b_max + a_min18 a_min_index = a.index(a_min)19 b_max_index = b.index(b_max)20 a[a_min_index] = b_max21 b[b_max_index] = a_min22 # a.remove(a_min)23 # a.append(b_max)24 # b.remove(b_max)25 # b.append(a_min)26 a_min = min(a)27 b_max = max(b)28 swaps+=129 if sum(a)>sum(b):30 print(swaps)31 else:32 print("-1")33 t-=134except:...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
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!!