Best Python code snippet using pyatom_python
main.py
Source:main.py
...67kapal1.settype("Kapal01")68kapal1.setage(5)69kapal1.setcountry("Indonesia")70kapal1.setftype("Fuel01")71kapal1.setmax(250)7273kapal2 = ship()74kapal2.settype("Kapal02")75kapal2.setage(3)76kapal2.setcountry("Indonesia")77kapal2.setftype("Fuel01")78kapal2.setmax(200)7980kapal3 = ship()81kapal3.settype("Kapal03")82kapal3.setage(7)83kapal3.setcountry("Inggris")84kapal3.setftype("Fuel01")85kapal3.setmax(300)8687kapal4 = ship()88kapal4.settype("Kapal04")89kapal4.setage(6)90kapal4.setcountry("Indonesia")91kapal4.setftype("Fuel02")92kapal4.setmax(275)9394kapal5 = ship()95kapal5.settype("Kapal05")96kapal5.setage(3)97kapal5.setcountry("Jerman")98kapal5.setftype("Fuel02")99kapal5.setmax(200)100101listship = [kapal1,kapal2,kapal3,kapal4,kapal5]102103#List Pesawat104air1 = airplane()105air1.settype("Pesawat01")106air1.setage(20)107air1.setlen(500)108air1.setftype("Fuel03")109air1.setmax(150)110111air2 = airplane()112air2.settype("Pesawat02")113air2.setage(21)114air2.setlen(550)115air2.setftype("Fuel03")116air2.setmax(155)117118air3 = airplane()119air3.settype("Pesawat03")120air3.setage(10)121air3.setlen(700)122air3.setftype("Fuel04")123air3.setmax(180)124125air4 = airplane()126air4.settype("Pesawat04")127air4.setage(5)128air4.setlen(850)129air4.setftype("Fuel04")130air4.setmax(195)131132air5 = airplane()133air5.settype("Pesawat05")134air5.setage(20)135air5.setlen(500)136air5.setftype("Fuel03")137air5.setmax(100)138139listairplane = [air1,air2,air3,air4,air5]140141#Looping untuk print142x=1143for i in range(5):144 print()145 print("======================")146 print("Data ke-" + str(x))147 listperson[i].printperson()148 if(i%2==0):149 listperson[i].sleep()150 x = x + 1151 for j in range(5):
...
placing_parentheses.py
Source:placing_parentheses.py
1import re2def mini_max(i, j, operations, setMin, setMax):3 mn = float('inf')4 mx = float('-inf')5 for k in range(i, j):6 a = evalt(setMax[i][k], setMax[k+1][j], operations[k])7 b = evalt(setMax[i][k], setMin[k+1][j], operations[k])8 c = evalt(setMin[i][k], setMax[k+1][j], operations[k])9 d = evalt(setMin[i][k], setMin[k+1][j], operations[k])10 mn = min(mn, a, b, c, d)11 mx = max(mx, a, b, c, d)12 return mn, mx13def get_maximum_value(dataset):14 digits, operations = Split(dataset)15 # Fill Subsets16 setMin, setMax = init_sets(digits)17 # s[0][0], s[1][1]18 for s in range(1, len(digits)):19 for i in range(len(digits)-s):20 j = i + s21 setMin[i][j], setMax[i][j] = mini_max(i, j, operations, setMin, setMax)22 # for i in range(len(digits)-1):23 # subset[i][i+1] = evalt(subset[i][i], subset[i+1][i+1], operations[i])24 #write your code here25 return setMax[0][len(digits)-1]26def init_sets(digits):27 setMin, setMax = [ ], [ ]28 for i,v in enumerate(digits):29 ar = [0] * len(digits)30 ar[i] = v31 setMin.append(ar)32 setMax.append(list(ar))33 return setMin, setMax34def Split(data):35 digits = [int(d) for d in re.findall(r'\d+', data)]36 operations = re.findall(r'\D+', data)37 return digits, operations38# Uses python339def evalt(a, b, op):40 if op == '+':41 return a + b42 elif op == '-':43 return a - b44 elif op == '*':45 return a * b46 else:47 assert False48if __name__ == "__main__":49 dataset = input()50 #dataset = '1+5'51 #dataset = '5-8+7*4-8+9'...
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!!