Best Python code snippet using autotest_python
deadly_aim.py
Source:deadly_aim.py
...89 dice = get_dice(DICE)90 dmg = dice+DMG91 dmg_da = dmg+2*DEADLY92 return (dice,max(dmg-DR,0),max(dmg_da-DR,0))93def get_full(ac,bonus,dmg,use_flu=True):94 rolls = ''95 dmgs = 096 atts = 1+(BAB-1)/597 flu_atts = FLURRY if use_flu else 098 for i in range(0,EXTRA):99 (r,d) = get_dmg(ac,bonus,dmg)100 rolls += '%-2s '%r101 dmgs += d102 for i in range(0,atts):103 (r,d) = get_dmg(ac,bonus-5*i,dmg)104 for j in range(0,1+(i<flu_atts)):105 rolls += '%-2s '%r106 dmgs += d107 return (rolls,dmgs)108def calc_one(ac):109 (dice,dmg,dmg_da) = get_vals(ac)110 rolls = {}111 dmgs = {}112 (rolls['one'],dmgs['one']) = get_dmg(ac,BONUS,dmg)113 (rolls['one_da'],dmgs['one_da']) = get_dmg(ac,BONUS-DEADLY,dmg_da)114 (rolls['full'],dmgs['full']) = get_full(ac,BONUS,dmg,False)115 (rolls['full_da'],dmgs['full_da']) = get_full(ac,BONUS-DEADLY,dmg_da,False)116 (rolls['flu'],dmgs['flu']) = get_full(ac,F_BONUS,dmg)117 (rolls['flu_da'],dmgs['flu_da']) = get_full(ac,F_BONUS-DEADLY,dmg_da)118 dmg = odict([('one',dmgs['one']),119 ('one_da',dmgs['one_da']),120 ('full',dmgs['full']),121 ('full_da',dmgs['full_da']),122 ('flu',dmgs['flu']),123 ('flu_da',dmgs['flu_da'])])124 names = {'one':'One',125 'one_da':'One+DA',126 'full':'Full',127 'full_da':'Full+DA',128 'flu':'Flurry',129 'flu_da':'Flurry+DA'}130 n = ''131 m = 0...
main.py
Source:main.py
1import requests2poke = requests.get('https://pokeapi.co/api/v2/pokemon/ditto').json()3print(poke['id'], poke['name'], poke['weight'], poke['height'])4class BasePokemon:5 def __init__(self, name):6 self.name == 'ditto'7class Pokemon(BasePokemon):8 def __init__(self, id, name, height, weight):9 self.id == 13210 self.name == 'ditto'11 self.weight == 4012 self.height == 313 def __str__(self, id, name, height, weight):14 return f'Pokemon is {self.name}, {self.age}, {self. height}, {self. weight}'15 def get_name(self):16 return self.__name17 def set_name(self, name):18 self.__name = name19 def get_id(self):20 return self.__id21 def set_id(self, id):22 self.__id = id23 def get_height(self):24 return self.__height25 def set_height(self, height):26 self.__height = height27 def get_weight(self):28 return self.__weight29 def set_weight(self, weight):30 self.__weight = weight31class PokeAPI(Pokemon):32 def __init__(self, id, name, height, weight, get_full):33 self. id = id34 self. name = name35 self. height = height36 self. weight = weight37 self.get_full = False38 def get_Pokemon(self, id, get_full):39 return Pokemon40 def get_all(self, get_full):...
test_full_name.py
Source:test_full_name.py
1import unittest2import full_name3class testCaseAdd(unittest.TestCase):4 def test_normal(self):5 self.assertEqual(full_name.get_Full("fred", "green"), "fred green")6 def test_capitalization(self):7 self.assertEqual(full_name.get_Full("bEnnY", "BeAVer"), "bEnnY BeAVer")8 def test_format_int(self):9 self.assertEqual(full_name.get_Full(23, 42), "23 42")10 def test_format_float(self):11 self.assertEqual(full_name.get_Full(5.6, 90.2), "5.6 90.2")12if __name__ == '__main__':...
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!!