Best Python code snippet using tempest_python
03 字符串格式化_列表.py
Source: 03 字符串格式化_列表.py
1"""2åç¬¦ä¸²æ ¼å¼å3"ææ¯%s,ä»å¹´%.2dï¼ä½é%.2f"%(name,int(age),float(weight))4 å符串 æ´æ° å°æ°ï¼ä¿ç两ä½å°æ°5"""6# name = input("è¾å
¥å§åï¼")7# age = input("è¾å
¥å¹´é¾ï¼")8# weight = input("è¾å
¥ä½éï¼")9# print("ææ¯%s,ä»å¹´%.3dï¼ä½é%.3f" % (name, int(age), float(weight)))10# message = "ææ¯%s,ä»å¹´%.3dï¼ä½é%.3f" % (name, int(age), float(weight))11#追å ãæå
¥12# list_name_area=["ä¸å½","ç¾å½","æ¥æ¬"]13# list_name_add=["10","20","30"]14# list_name_area.append("è±å½")15# list_name_add.append("40")16# print(list_name_area)17# print(list_name_add)18#19# list_name_area.insert(1,"åå")20# list_name_add.insert(1,"50")21# print(list_name_area)22# print(list_name_add)23"""24éåãååºãä¿®æ¹25"""26# list_name_area = ["ä¸å½", "ç¾å½", "æ¥æ¬", "åå"]27#28# for item in list_name_area:29# print(item)30#31# for i in range(len(list_name_area) - 1, -1, -1):32# print(list_name_area[i])33#34# for i in range(len(list_name_area)):35# list_name_area[i] = 036# print(list_name_area)37"""38å®ç°å¦ä¸39*40**41***42**43*44"""45# list01=[1,2,3,2,1]46# for item in list01:47# print("*"*item)48#49#50#ç´¯ä¹51# list01 = [1, 2, 3, 2, 1]52# result = 153# for item in list01:54# result *= item55# print(result)56#个ä½ä¸æ¯5æ3çæ°åï¼åå
¥å¦ä¸ä¸ªå表57# list01 = [25, 63, 27, 75, 70, 83, 27]58# result = []59# for item in list01:60# if item % 10 != 5 and item % 10 != 3:61# result.append(item)62# print(result)63"""64è¾å
¥ç«æ
å°åºå称ï¼65å¦æè¾å
¥ä¸ºç©ºï¼ååæ¢è¾å
¥66å¦æè¾å
¥çå°åºå·²ç»åå¨ï¼åæ¾ç¤ºå·²åå¨67æåååºæå°ææå°åº68"""69# list_regions = []70# while True:71# region = input("è¾å
¥å°åºå称")72# if region == "":73# break74# if region in list_regions:75# print("å·²åå¨")76# else:77# list_regions.append(region)78# for i in range(len(list_regions) - 1, -1, -1):79# print(list_regions[i])80"""81è¾å
¥ä¸æ¬¡ç¡®è¯äººæ°ï¼ä½¿ç¨å
ç½®å½æ°ï¼è¾åºæ大å¼ãæå°å¼ãå¹³åå¼82"""83# list_confirm_num = []84# for i in range(3):85# list_confirm_num.append(int(input("è¾å
¥ç¬¬%d次确è¯äººæ°" % (i + 1))))86# print(list_confirm_num)87# print(max(list_confirm_num))88# print(min(list_confirm_num))89# print(sum(list_confirm_num) / len(list_confirm_num))90#91#92#93"""94è¾å
¥ç«æ
å°åºå称ï¼95å¦æè¾å
¥ä¸ºç©ºï¼ååæ¢è¾å
¥96å¦æè¾å
¥çå°åºå·²ç»åå¨ï¼åæ¾ç¤ºå·²åå¨97@@@@@@@@@@@@@@@æåæå°å表æå符串ï¼è¿æ¥ç¬¦æ¯-98"""99# list_regions = []100# while True:101# region = input("è¾å
¥å°åºå称")102# if region == "":103# break104# if region in list_regions:105# print("å·²åå¨")106# else:107# list_regions.append(region)108# str_regions = ".".join(list_regions)109# print(str_regions)110"""111å°è±æè¯å¥ï¼æç
§åè¯ç¿»è½¬ï¼ä¾å¦,112å³å符串转æ¢æå表ï¼å表翻转åï¼åæå表转æ¢æå符串113to have a114æ¹æ115a have to116"""117"""118å表æ¨å¯¼å¼ï¼å¦ä¸ä¸¤æ®µä»£ç ï¼ç»ææ¯ä¸æ ·ç119"""120# list_result="to have a".split(" ")121# print(list_result)122# print(" ".join(list_result[::-1]))123# list01 = []124# for r in range(1, 8):125# for c in range(1, 8):126# for m in range(1, 8):127# list01.append((r, c, m)) #å表é追å çå
ç´ ï¼æ¯å
ç»128# print(list01)129# list01 = [(r, c, m) for r in range(1, 8) for c in range(1, 8) for m in range(1, 8)]130# print(list01)131#132"""133å®ä¹å½æ°ï¼å°å表ä¸å¥æ°å é¤134 æ ¹æ®æç§æ¡ä»¶ï¼å é¤å®¹å¨ä¸çå¤ä¸ªå
ç´ ï¼éç¨ååºå é¤ï¼æ£åºå é¤çè¯ï¼å®¹ææ¼å ãç´¢å¼è¶ç135 å é¤çæ¬è´¨ï¼æ¯åä¸ä¸ªå
ç´ ï¼æ¤æåä¸ä¸ªå
ç´ çä½ç½®ï¼136 æ¯å¦å
å 0ç´¢å¼çå
ç´ ï¼ååæ¬ç´¢å¼1çå
ç´ ï¼åæ0ï¼ä¸ä¸ä¸ªå¾ªç¯ä»1å¼å§ï¼ååæ¬ç´¢å¼1çå
ç´ å°±è¢«æ¼æäº137"""138# list01 = [3, 7, 5, 6, 7, 8, 9, 13]139#140# def del_list(list_arge):141# for i in range(len(list_arge) - 1, -1, -1):142# if list_arge[i] % 2 == 1:143# del list_arge[i]144# print(list_arge)145#...
obstacles.py
Source: obstacles.py
1import math2class ObstacleContainer:3 def __init__(self, pos=[], orient=0):4 self.obs = []5 self.pos = pos6 self.orientation = orient7 # obs - маÑÑив ÑоÑек кооÑÐ´Ð¸Ð½Ð°Ñ [x, y]8 # Ðобавление и ÑилÑÑÑаÑÐ¸Ñ Ð½Ð¾Ð²ÑÑ
даннÑÑ
Ñ ÐÐÐÐРа9 def update(self, pos, points, dphi=0):10 new_pos = []11 self.pos = pos12 self.orientation = dphi13 self.update_obstacles()14 self.obs = []15 for p in points:16 if p[0] == p[1] == 0: continue17 new_x = ((int)(p[0] * 1000))/1000.018 new_y = ((int)(p[1] * 1000))/1000.019 # new_pos.append([new_x, new_y])20 self.obs.append([new_x, new_y])21 # for p in new_pos:22 # if not self.is_Ñontain(p):23 # self.obs.append(p)24 # self.update_obstacles()25 # ФилÑÑÑаÑÐ¸Ñ ÑоÑек: ÐÑли ÑоÑка в маÑÑиве obs не вÑ
Ð¾Ð´Ð¸Ñ Ð² пÑÑмоÑголÑнÑÑ Ð¾Ð±Ð°ÑÑÑ Ð²Ð¾ÐºÑÑг ÑобоÑа26 def update_obstacles(self):27 new_obs = []28 for p in self.obs:29 if (abs(p[0] - self.pos[0]) <= 2.5) and (abs(p[1] - self.pos[1]) <= 2.5):30 new_obs.append(p)31 self.obs = new_obs32 '''33 new_obs = []34 for obs in self.obs:35 if not self.get_distance(obs, self.pos) > 2.5:36 new_obs.append(obs)37 self.obs = new_obs38 '''39 def get_obs(self):40 return self.obs41 # ÐозвÑаÑÐ°ÐµÑ Ð¿ÑиведеннÑе к ÑенÑÑÑ ÑобоÑа кооÑдинаÑÑ ÑоÑек42 def get_norm_obs(self):43 new_obs = []44 for p in self.obs:45 new_x = p[0] - self.pos[0]46 new_y = p[1] - self.pos[1]47 new_obs.append([new_x, new_y])48 return new_obs49 # ÐÑли ÑÐ°ÐºÐ°Ñ ÑоÑка имееÑÑÑ, Ñо возвÑаÑаем True50 def is_Ñontain(self, obs_pos):51 for obs in self.obs:52 if obs_pos[0] == obs[0] and obs_pos[1] == obs[1]:53 return True54 return False55 @staticmethod56 def get_distance(obs_pos, pos):57 return math.sqrt(math.pow(pos[0] - obs_pos[0], 2) + math.pow(pos[1] - obs_pos[1], 2))58# ÐозвÑаÑÐ°ÐµÑ Ð±Ð»Ð¸Ð¶Ð°Ð¹ÑÑÑ ÑоÑÐºÑ Ð² Ñегионе59def get_regions(obstacle):60 # _res = obstacle.get_norm_obs()61 _res = list(obstacle.get_obs())62 res = []63 # for i in _res:64 # res.append(i)65 N = 1866 reg = []67 da = (180 / N) * math.pi / 18068 for i in range(N):69 reg.append(10)70 alpha = math.pi/2 - da71 for point in _res:72 if (math.atan2(point[1], point[0]) >= -math.pi/2) and (math.atan2(point[1], point[0]) <= math.pi/2):73 res.append(point)74 for i in range(N):75 n_alpha = alpha - da * i76 mass_j = []77 for j, val in enumerate(res):78 if(math.atan2(val[1], val[0]) >= n_alpha):79 mass_j.append(j)80 min_len = reg[i]81 for k in mass_j:82 dist = get_distance(res[k])83 if(dist < min_len):84 min_len = dist85 reg[i] = min_len86 list_to_delete = []87 for k in mass_j:88 list_to_delete.append(res[k])89 for k in list_to_delete:90 res.remove(k)91 return reg92def get_obstacles_in_regions(obstacles):93 list_regions = [10, 10, 10, 10, 10]94 for obstacle in obstacles:95 if obstacle[0] < 0:96 if obstacle[1] > 0:97 if(list_regions[0] > obstacle[1]):98 list_regions[0] = obstacle[1]99 else:100 if (list_regions[4] > -obstacle[1]):101 list_regions[4] = -obstacle[1]102 else:103 if obstacle[1] > -0.2 and obstacle[1] < 0.2:104 if (list_regions[2] > obstacle[0]):105 list_regions[2] = obstacle[0]106 elif obstacle[1] <= -0.2 and obstacle[0] < 0.5:107 if (list_regions[3] > -obstacle[1]):108 list_regions[3] = -obstacle[1]109 elif obstacle[1] >= 0.2 and obstacle[0] < 0.5:110 if (list_regions[1] > obstacle[1]):111 list_regions[1] = obstacle[1]112 return list_regions113def get_distance(landmark):...
exercise05.py
Source: exercise05.py
1"""2 å¨ç»ç«¯ä¸å½å
¥ç«æ
å°åºå称ï¼å¦æè¾å
¥ç©ºå符串ï¼ååæ¢ã3 å¦æå½å
¥çå称已ç»åå¨ä¸è¦å次添å .4 æåååºæå°ææç份å称(ä¸è¡ä¸ä¸ª)5"""6list_regions = []7while True:8 region = input("请è¾å
¥ç«æ
å°åºå称ï¼")9 if region == "":10 break11 if region in list_regions:12 print("å·²ç»åå¨")13 else:14 list_regions.append(region)15# 3 2 1 016for i in range(len(list_regions) - 1, -1, -1):...
Check out the latest blogs from LambdaTest on this topic:
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
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.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
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!!