How to use list_regions method in tempest

Best Python code snippet using tempest_python

03 字符串格式化_列表.py

Source:03 字符串格式化_列表.py Github

copy

Full Screen

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#...

Full Screen

Full Screen

obstacles.py

Source:obstacles.py Github

copy

Full Screen

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):...

Full Screen

Full Screen

exercise05.py

Source:exercise05.py Github

copy

Full Screen

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):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful