How to use get_information method in lisa

Best Python code snippet using lisa_python

itt_student_practice.py

Source:itt_student_practice.py Github

copy

Full Screen

1import json2def search_word_1st(get_information, search, main_key):3 find_list=[]4 for num in range(0, len(get_information)):5 for find_key,find_value in get_information[num].items():6 if search in find_value:7 if main_key==find_key:8 find_list.append([num, find_key, find_value])9 return find_list10def search_word_2nd(get_information, search, main_key, second_key):11 find_list=[]12 for num in range(0, len(get_information)):13 for find_key, find_value in get_information[num][main_key].items():14 if search==find_value:15 if second_key==find_key:16 find_list.append([num, find_key, find_value])17 print(find_value)18 print(find_list)19 return find_list20def search_word_3th(get_information, search, main_key, second_key, third_key):21 find_list=[]22 for num in range(0, len(get_information)):23 for num in range(0, len(get_information[num][main_key][second_key])):24 for find_key, find_value in get_information[num][main_key][second_key][num].items():25 if search in find_value:26 if third_key==find_key:27 find_list.append([num, find_key, find_value])28 return find_list29def search_course_learned(get_information, search, main_key, second_key):30 find_list=[]31 find_list_2=[]32 for num in range(0,len(get_information)):33 if len(get_information[num][main_key][second_key])!=0:34 find_list.append([num, main_key, len(get_information[num][main_key][second_key])])35 elif len(get_information[num][main_key][second_key])==0:36 find_list.append([num, main_key, len(get_information[num][main_key][second_key])])37 if search=='y':38 print_result(get_information, find_list)39 elif search=='n':40 print_result(get_information, find_list_2)41 else:42 search=input("'y' or 'n' 으로 입력해주세요: ")43 search_course_learned(get_information, search, main_key, second_key)44def print_result(get_information, find_list):45 if len(find_list)==1:46 num=find_list[0][0]47 print("* ID: %s"%get_information[num]['student_ID'])48 print("* 이름: %s"%get_information[num]['student_name'])49 print("* 나이: %s"%get_information[num]['student_age'])50 print("* 주소: %s"%get_information[num]['address'])51 print("* 수강 정보")52 print(" + 과거 수강 횟수: %s"%get_information[num]['total_course_info']['num_of_course_learned'])53 print(" + 현재 수강 과목: ")54 for count in range(len(get_information[num]['total_course_info']['learning_course_info'])):55 print(" %s)"%(count+1))56 print(" 강의 코드: %s"%get_information[num]['total_course_info']['learning_course_info'][count]['course_code'])57 print(" 강의명: %s"%get_information[num]['total_course_info']['learning_course_info'][count]['course_name'])58 print(" 강사: %s"%get_information[num]['total_course_info']['learning_course_info'][count]['teacher'])59 print(" 개강일: %s"%get_information[num]['total_course_info']['learning_course_info'][count]['open_date'])60 print(" 종료일: %s"%get_information[num]['total_course_info']['learning_course_info'][count]['close_date'])61 elif len(find_list)==0:62 pass63 else:64 print(" ----- 요약 결과 ----- ")65 for num in range(0,len(find_list)):66 print("학생 ID: %s, 학생 이름: %s"%(get_information[num]['student_ID'],get_information[num]['student_name']))67def insert_information(get_information):68 file_data_list=[]69 global file_data70 while True:71 file_data={}72 count=len(get_information)73 file_data['student_ID'] = ("ITT{0:0>3}".format(count+1))74 file_data['student_name'] = input("이름 (예: 홍길동): ")75 file_data['student_age'] = input("나이 (예: 29): ")76 file_data['address'] = input("주소 (예: 대구광역시 동구 아양로 135): ")77 num_of_course_learned=input("과거 수강 횟수 ( 예: 1): ")78 now_learn=input("현재 수강하는 과목이 있습니까? (예: y/n): ")79 learning_course_info=[]80 while True:81 if now_learn=='y':82 course_code=input("강의코드 (예: IB171106, OB0104 ..): ")83 course_name=input("강의명 (예: IOT 빅데이터 실무반): ")84 teacher=input("강사 (예: 이현구): ")85 open_date=input("개강일 (예: 2017-11-06): ")86 close_date=input("종료일 (예: 2018-09-05): ")87 learning_course_info.append({'course_code':course_code,'course_name':course_name,'teacher':teacher,'open_date':open_date,'close_date':close_date,})88 now_learn=input("현재 수강하는 과목이 더 있습니까? (예: y/n): ")89 elif now_learn=='n':90 if len(learning_course_info)==0:91 learning_course_info.append({})92 break93 else:94 now_learn=input("'y' or 'n' 으로 입력해주세요: ")95 file_data['total_course_info']={'learning_course_info':learning_course_info,'num_of_course_learned':num_of_course_learned}96 file_data_list.append(file_data)97 get_information=file_data_list98 print(file_data_list)99 insert_continue=input("학생 정보를 더 입력하시겠습니까? (y/n): ")100 if insert_continue=='n':101 break102 print(file_data_list)103 print(get_information)104 return get_information105def select_information(get_information):106 print("아래 메뉴를 선택하세요.\n1. 전체 학생정보 조회\n검색 조건 선택\n2. ID 검색\n3. 이름 검색\n4. 나이 검색\n5. 주소 검색\n6. 과거 수강 횟수 검색\n7. 현재 강의를 수강중인 학생\n8. 현재 수강 중인 강의명\n9. 현재 수강 강사\n10. 이전 메뉴\n")107 select_num=input("메뉴를 선택하세요: ")108 main_key=''109 second_key='learning_course_info'110 if select_num=='1':111 for num in range(len(get_information)):112 print("학생 ID: %s, 학생 이름: %s"%(get_information[num]['student_ID'],get_information[num]['student_name']))113 main()114 elif select_num=='10':115 main()116 elif select_num=='7':117 main_key='total_course_info'118 search=input("검색어를 입력하세요 (y/n 로 입력하세요.): ")119 search_course_learned(get_information, search, main_key, second_key)120 main()121 search=input("검색어를 입력하세요: ")122 third_key='teacher'123 if select_num=='2':124 main_key='student_ID'125 elif select_num=='3':126 main_key='student_name'127 elif select_num=='4':128 main_key='student_age'129 elif select_num=='5':130 main_key='address'131 print_result(get_information, search_word_1st(get_information, search, main_key))132 main_key='total_course_info'133 if select_num=='6':134 second_key='num_of_course_learned'135 print_result(get_information, search_word_2nd(get_information, search, main_key, second_key))136 elif select_num=='9':137 print_result(get_information, search_word_3th(get_information, search, main_key, second_key, third_key))138 elif select_num=='8':139 third_key='course_code'140 find_list=search_word_3th(get_information, search, main_key, second_key, third_key)141 if len(find_list)>0:142 print_result(get_information, find_list)143 else:144 third_key='course_name'145 find_list_2=search_word_3th(get_information, search, main_key, second_key, third_key)146 print_result(get_information, find_list_2)147def update_search(get_information, ):148 search=input("정보를 수정할 학생의 ID를 입력해주세요. : ")149 find_list=search_word_1st(get_information, search, 'student_ID')150 print_result(get_information, find_list)151 return find_list152def update_main_key(get_information, find_list, main_key):153 print("현재 값: %s"%get_information[find_list[0][0]][main_key])154 get_information[find_list[0][0]][main_key]=input("바꾸실 값을 입력하세요. :")155def update_2nd_key(get_information, find_list, second_key):156 print("현재 값: %s"%get_information[find_list[0][0]]['total_course_info'][second_key])157 get_information[find_list[0][0]]['total_course_info'][second_key]=input("바꾸실 값을 입력하세요. :")158def update_3th_key(get_information, find_list, third_key):159 if len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])==1:160 print("수강과목 현재 값: %s"%(get_information[find_list[0][0]]['total_course_info']['learning_course_info'][0][third_key]))161 get_information[find_list[0][0]]['total_course_info']['learning_course_info'][0][third_key]=input("바꾸실 값을 입력하세요. :")162 elif len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])>1:163 update_code=input("수정할 내용의 수강과목 코드를 입력해 주세요. :")164 for num in range(0,len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])):165 for find_key, find_value in get_information[find_list[0][0]]['total_course_info']['learning_course_info'][num].items():166 if find_key=='course_code':167 if find_value==update_code:168 print("%s) 수강과목 현재 값: %s"%(num,get_information[find_list[0][0]]['total_course_info']['learning_course_info'][num][third_key]))169 get_information[num]['total_course_info']['learning_course_info'][num][third_key]=input("바꾸실 값을 입력하세요. :")170def update_information(get_information):171 find_list=update_search(get_information)172 while len(find_list)!=1:173 find_list=update_search(get_information)174 update_num=input("수정할 항목을 선택하세요.\n1. 학생 이름\n2. 나이\n3. 주소\n4. 과거 수강 횟수\n5. 현재 수강 중인 강의 정보\n0. 이전 메뉴\n메뉴 번호를 입력하세요: ")175 if update_num=='1':176 update_main_key(get_information, find_list, 'student_ID')177 elif update_num=='2':178 update_main_key(get_information, find_list, 'student_age')179 elif update_num=='3':180 update_main_key(get_information, find_list, 'address')181 elif update_num=='4':182 update_2nd_key(get_information, find_list, 'num_of_course_learned')183 elif update_num=='5':184 update_num_learned_info=input("1. 강의 코드\n2. 강의명\n3. 강사\n4. 개강일\n5. 종료일\n0. 취소\n메뉴 번호를 입력하세요: ")185 if update_num_learned_info=='1':186 update_3th_key(get_information, find_list, 'course_code')187 elif update_num_learned_info=='2':188 update_3th_key(get_information, find_list, 'course_name')189 elif update_num_learned_info=='3':190 update_3th_key(get_information, find_list, 'teacher')191 elif update_num_learned_info=='4':192 update_3th_key(get_information, find_list, 'open_date')193 elif update_num_learned_info=='5':194 update_3th_key(get_information, find_list, 'close_date')195 elif update_num_learned_info=='0':196 pass197 elif update_num=='0':198 main()199def delete_course(get_information, find_list):200 if len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])==1:201 del get_information[find_list[0][0]]['total_course_info']['learning_course_info'][0]202 elif len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])>1:203 update_code=input("삭제할 내용의 수강과목 코드를 입력해 주세요. :")204 for num in range(0,len(get_information[find_list[0][0]]['total_course_info']['learning_course_info'])):205 for find_key, find_value in get_information[find_list[0][0]]['total_course_info']['learning_course_info'][num].items():206 if find_key=='course_code':207 if find_value==update_code:208 del get_information[find_list[0][0]]['total_course_info']['learning_course_info'][num]209def delete_information(get_information):210 delete_num=input("삭제 유형을 선택하세요.\n1. 전체 삭제\n2. 현재 수강 중인 특정 과목정보 삭제\n3. 이전 메뉴\n메뉴 번호를 선택하세요: ")211 delete_std=input("삭제할 학생의 ID를 입력하세요: ")212 find_list=search_word_1st(get_information, delete_std, 'student_ID')213 print(find_list)214 if delete_num=='1':215 del get_information[find_list[0][0]]216 elif delete_num=='2':217 delete_course(get_information,find_list)218 elif delete_num=='3':219 main()220def make_json_file():221 make_order=str(input("파일을 찾을 수 없습니다.\n1. 파일을 새로 만들겠습니다.\n2. 경로를 입력하겠습니다.\n1, 2로 선택하세요. : "))222 while True:223 if make_order=='1':224 json_file_name=input("파일명을 입력해주세요. (ex.ITT_Student.json): ")225 break226 elif make_order=='2':227 json_file_name=input("경로를 입력해주세요. (ex.ITT_Student.json): ")228 break229 else:230 make_json_file()231 return json_file_name232def main():233 while True:234 print("\t<< json기반 주소록 관리 프로그램 >>\n1. 학생 정보입력\n2. 학생 정보조회\n3. 학생 정보수정\n4. 학생 정보삭제\n5. 프로그램 종료\n")235 select_num=input("메뉴를 선택하세요: ")236 if select_num=='1':237 insert_information(get_information)238 print(json.dumps(file_data, ensure_ascii=False, indent="\t"))239 elif select_num=='2':240 select_information(get_information)241 elif select_num=='3':242 update_information(get_information)243 elif select_num=='4':244 delete_information(get_information)245 elif select_num=='5':246 print("학생 정보 관리 프로그램을 종료합니다.")247 break248 with open(json_file_name,'w',encoding='UTF8') as file_make:249 file_data_list=json.dumps(file_data, ensure_ascii=False, sort_keys=True, indent=4)250 file_make.write(file_data_list)251try:252 global json_file_name253 json_file_name='ITT_Student.json'254 with open(json_file_name,'r',encoding='utf8') as selection:255 get_info=json.load(selection)256 get_information=get_info257except FileNotFoundError:258 json_file_name=make_json_file()259 get_name=str(json_file_name)260 get_information=[]261 get_information=insert_information(get_information)...

Full Screen

Full Screen

concrete.py

Source:concrete.py Github

copy

Full Screen

1from abc import ABCMeta2class IConcrete(metaclass=ABCMeta):3 @staticmethod4 def get_information():5 """"The Pizzeria Interface"""6class PipperoniHam(IConcrete):7 def __init__(self):8 self.cheese = 709 self.carbs = 4510 self.fat = 3811 self.protein = 812 def get_information(self):13 return {"cheese": self.cheese, "carbohydrates": self.carbs, "fats": self.fat, "proteins": self.protein}14class Stagioni(IConcrete):15 def __init__(self):16 self.cheese = 3017 self.carbs = 5918 self.fat = 2919 self.protein = 6.320 def get_information(self):21 return {"cheese": self.cheese, "carbohydrates": self.carbs, "fats": self.fat, "proteins": self.protein}22class SpicyHot(IConcrete):23 def __init__(self):24 self.flavour = "hot"25 self.first = "tomato"26 self.second = "ham"27 self.stage = "oliva"28 def get_information(self):29 return {"Number of flavour": self.flavour, "first dish": self.first, "second dish": self.second, "stage": self.stage}30class ConcreteFactory:31 @staticmethod32 def get_information(pizzatype):33 try:34 if pizzatype == "PippetoniHam":35 return PipperoniHam()36 if pizzatype == "Stagioni":37 return Stagioni()38 if pizzatype == "SpicyHot":39 return SpicyHot()40 raise AssertionError("Pizza is lost")41 except AssertionError as _e:42 print(_e)43if __name__ == "__main__":44 PIZZA = ConcreteFactory.get_information("PipperoniHam")45 print("PipperoniHam contains", PIZZA.get_information())46 PIZZA = ConcreteFactory.get_information("Stagioni")47 print("Stagioni Piza contains", PIZZA.get_information())48 PIZZA = ConcreteFactory.get_information("SpicyHot")...

Full Screen

Full Screen

pizzeria.py

Source:pizzeria.py Github

copy

Full Screen

1from abc import ABCMeta2class Pizza(metaclass=ABCMeta):3 @staticmethod4 def get_information():5 """"The Pizza Interface"""6class PepperoniPizza(Pizza):7 def __init__(self):8 self.cheese = 709 self.carbs = 4510 self.fat = 3811 self.protein = 812 def get_information(self):13 return {"cheese": self.cheese, "carbohydrates": self.carbs, "fats": self.fat, "proteins": self.protein}14class CheesePizza(Pizza):15 def __init__(self):16 self.cheese = 3017 self.carbs = 5918 self.fat = 2919 self.protein = 6.320 def get_information(self):21 return {"cheese": self.cheese, "carbohydrates": self.carbs, "fats": self.fat, "proteins": self.protein}22class SpicyPizza(Pizza):23 def __init__(self):24 self.cheese = 025 self.carbs = 6526 self.fat = 2827 self.protein = 4.328 def get_information(self):29 return {"cheese": self.cheese, "carbohydrates": self.carbs, "fats": self.fat, "proteins": self.protein}30class Pizzeria:31 @staticmethod32 def get_pizza(pizzatype):33 try:34 if pizzatype == "Pepperoni":35 return PepperoniPizza()36 if pizzatype == "Cheese":37 return CheesePizza()38 if pizzatype == "Spicy":39 return SpicyPizza()40 raise AssertionError("Pizza is lost")41 except AssertionError as _e:42 print(_e)43 def get_flyweight(self, param):44 pass45if __name__ == "__main__":46 pizza = Pizzeria.get_pizza("Pepperoni")47 print("Pepperoni Pizza Contains", pizza.get_information())48 pizza = Pizzeria.get_pizza("Cheese")49 print("Cheese Pizza Contains", pizza.get_information())50 pizza = Pizzeria.get_pizza("Spicy")...

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 lisa 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