Best Python code snippet using stestr_python
Dot_matriks.py
Source: Dot_matriks.py
...11col_pins = [27, 22, 4, 14, 15]12# set all the pins as outputs and set column pins high, row pins low13GPIO.setup(col_pins, GPIO.OUT, initial=GPIO.LOW)14GPIO.setup(row_pins, GPIO.OUT, initial=GPIO.HIGH)15def show_row(row_number, columns, delay):16 GPIO.output(row_pins[row_number - 1], GPIO.LOW)17 # Control a row of the dot matrix display18 for i in columns:19 GPIO.output(col_pins[i-1], GPIO.HIGH)20 time.sleep(delay)21 for i in columns:22 GPIO.output(col_pins[i-1], GPIO.LOW)23 GPIO.output(row_pins[row_number - 1], GPIO.HIGH)24 25listikene = [[5],[4],[3],[2],[1]]26listikene2 = [7,6,5,4,3,2,1]27def lightshow():28# for i in range(1000):29# show_row(2, [1,2,3,4,5], 0.00001)30 for i in range(3):31 for i in range (7):32 for s in range(300):33 show_row(listikene2[i], [1,2,3,4,5], 0.00001)34 for i in range (7):35 for s in range(300):36 show_row(i+1, [1,2,3,4,5], 0.00001)37 for i in range (5):38 for s in range(50):39 show_row(1, [i+1], 0.00001)40 show_row(2, [i+1], 0.00001)41 show_row(3, [i+1], 0.00001)42 show_row(4, [i+1], 0.00001)43 show_row(5, [i+1], 0.00001)44 show_row(6, [i+1], 0.00001)45 show_row(7, [i+1], 0.00001)46 for i in range (5):47 for s in range(50):48 show_row(1, listikene[i], 0.00001)49 show_row(2, listikene[i], 0.00001)50 show_row(3, listikene[i], 0.00001)51 show_row(4, listikene[i], 0.00001)52 show_row(5, listikene[i], 0.00001)53 show_row(6, listikene[i], 0.00001)54 show_row(7, listikene[i], 0.00001)55 for i in range(5):56 for i in range (50):57 show_row(1, [1,2,4,5], 0.00001)58 show_row(2, [1,3,5], 0.00001)59 show_row(3, [1,2,4,5], 0.00001)60 show_row(4, [1,3,5], 0.00001)61 show_row(5, [1,2,4,5], 0.00001)62 show_row(6, [1,3,5], 0.00001)63 show_row(7, [1,2,4,5], 0.00001)64 for i in range (50):65 show_row(1, [1,3,5], 0.00001)66 show_row(2, [2,4], 0.00001)67 show_row(3, [1,3,5], 0.00001)68 show_row(4, [2,4], 0.00001)69 show_row(5, [1,3,5], 0.00001)70 show_row(6, [2,4], 0.00001)71 show_row(7, [1,3,5], 0.00001)72 for i in range (5):73 for s in range(50):74 show_row(1, [i+1], 0.00001)75 show_row(2, [i+1], 0.00001)76 show_row(3, [i+1], 0.00001)77 show_row(4, [i+1], 0.00001)78 show_row(5, [i+1], 0.00001)79 show_row(6, [i+1], 0.00001)80 show_row(7, [i+1], 0.00001)81 for i in range (5):82 for s in range(50):83 show_row(1, listikene[i], 0.00001)84 show_row(2, listikene[i], 0.00001)85 show_row(3, listikene[i], 0.00001)86 show_row(4, listikene[i], 0.00001)87 show_row(5, listikene[i], 0.00001)88 show_row(6, listikene[i], 0.00001)89 show_row(7, listikene[i], 0.00001)90 for i in range (7):91 for s in range(300):92 show_row(i+1, [1,2,3,4,5], 0.00001)93 for i in range (7):94 for s in range(300):95 show_row(listikene2[i], [1,2,3,4,5], 0.00001)96 # I97# show_row(1, [3], 0.00001)98# show_row(2, [3], 0.00001)99# show_row(3, [3], 0.00001)100# show_row(4, [3], 0.00001)101# show_row(5, [3], 0.00001)102# show_row(6, [3], 0.00001)103# show_row(7, [3], 0.00001)104# 105# # G106# show_row(1, [2,3,4,5], 0.00001)107# show_row(2, [1], 0.00001)108# show_row(3, [1], 0.00001)109# show_row(4, [1,3,4], 0.00001)110# show_row(5, [1,5], 0.00001)111# show_row(6, [1,5], 0.00001)112# show_row(7, [2,3,4,5], 0.00001)113# 114# # H115# show_row(1, [1, 5], 0.00001)116# show_row(2, [1, 5], 0.00001)117# show_row(3, [1, 5], 0.00001)118# show_row(4, [1,2,3,4,5], 0.00001)119# show_row(5, [1, 5], 0.00001)120# show_row(6, [1, 5], 0.00001)121# show_row(7, [1, 5], 0.00001)122# 123# # T124# show_row(1, [1,2,3,4,5], 0.00001)125# show_row(2, [1], 0.00001)126# show_row(3, [1], 0.00001)127# show_row(4, [1], 0.00001)128# show_row(5, [1], 0.00001)129# show_row(6, [1], 0.00001)130# show_row(7, [1], 0.00001)131# 132# # S133# show_row(1, [2,3,4,5], 0.00001)134# show_row(2, [1], 0.00001)135# show_row(3, [1], 0.00001)136# show_row(4, [2,3,4], 0.00001)137# show_row(5, [5], 0.00001)138# show_row(6, [5], 0.00001)139# show_row(7, [1,2,3,4], 0.00001)140# 141# # H142# show_row(1, [1, 5], 0.00001)143# show_row(2, [1, 5], 0.00001)144# show_row(3, [1, 5], 0.00001)145# show_row(4, [1,2,3,4,5], 0.00001)146# show_row(5, [1, 5], 0.00001)147# show_row(6, [1, 5], 0.00001)148# show_row(7, [1, 5], 0.00001)149# 150# # O151# show_row(1, [1,2,3,4,5], 0.00001)152# show_row(2, [1,5], 0.00001)153# show_row(3, [1,5], 0.00001)154# show_row(4, [1,5], 0.00001)155# show_row(5, [1,5], 0.00001)156# show_row(6, [1,5], 0.00001)157# show_row(7, [1,2,3,4,5], 0.00001)158# 159# # W160# show_row(1, [1, 5], 0.00001)161# show_row(2, [1, 5], 0.00001)162# show_row(3, [1, 5], 0.00001)163# show_row(4, [1, 3, 5], 0.00001)164# show_row(5, [1, 3, 5], 0.00001)165# show_row(6, [1, 3, 5], 0.00001)166# show_row(7, [2, 4], 0.00001)167# ...
zebra-puzzle-3.py
Source: zebra-puzzle-3.py
...7class Nation:elems= "British Swedish Danish Norvegian German".split()8for c in (Number, Color, Drink, Smoke, Pet, Nation):9 for i, e in enumerate(c.elems):10 exec "%s.%s = %d" % (c.__name__, e, i)11def show_row(t, data):12 print "%6s: %12s%12s%12s%12s%12s" % (13 t.__name__, t.elems[data[0]],14 t.elems[data[1]], t.elems[data[2]],15 t.elems[data[3]], t.elems[data[4]])16def main():17 perms = list(permutations(range(5)))18 for number in perms:19 if number[Nation.Norvegian] == Number.One: # Constraint 1020 for color in perms:21 if color[Nation.British] == Color.Red: # Constraint 222 if number[color.index(Color.Blue)] == Number.Two: # Constraint 15+1023 if number[color.index(Color.White)] - number[color.index(Color.Green)] == 1: # Constraint 524 for drink in perms:25 if drink[Nation.Danish] == Drink.Tea: # Constraint 426 if drink[color.index(Color.Green)] == Drink.Coffee: # Constraint 627 if drink[number.index(Number.Three)] == Drink.Milk: # Constraint 928 for smoke in perms:29 if smoke[Nation.German] == Smoke.Prince: # Constraint 1430 if drink[smoke.index(Smoke.BlueMaster)] == Drink.Beer: # Constraint 1331 if smoke[color.index(Color.Yellow)] == Smoke.Dunhill: # Constraint 832 if number[smoke.index(Smoke.Blend)] - number[drink.index(Drink.Water)] in (1, -1): # Constraint 1633 for pet in perms:34 if pet[Nation.Swedish] == Pet.Dog: # Constraint 335 if pet[smoke.index(Smoke.PallMall)] == Pet.Bird: # Constraint 736 if number[pet.index(Pet.Horse)] - number[smoke.index(Smoke.Dunhill)] in (1, -1): # Constraint 1237 if number[smoke.index(Smoke.Blend)] - number[pet.index(Pet.Cat)] in (1, -1): # Constraint 1138 print "Found a solution:"39 show_row(Nation, range(5))40 show_row(Number, number)41 show_row(Color, color)42 show_row(Drink, drink)43 show_row(Smoke, smoke)44 show_row(Pet, pet)45 print...
Check out the latest blogs from LambdaTest on this topic:
In recent times, many web applications have been ported to mobile platforms, and mobile applications are also created to support businesses. However, Android and iOS are the major platforms because many people use smartphones compared to desktops for accessing web applications.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
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!!