jumboframe

08-filter-base

Jul 4th, 2018
150
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def is_float_try(str):
  2.     try:
  3.         float(str)
  4.         return True
  5.     except ValueError:
  6.         return False
  7.  
  8. def is_int_try(str):
  9.     try:
  10.         int(str)
  11.         return True
  12.     except ValueError:
  13.         return False
  14.  
  15. in_line=input()
  16. dict = {}
  17. age={}
  18. salary={}
  19. position={}
  20.  
  21. while in_line != "filter base":
  22.     params = in_line.split(" -> ")
  23.     in_name = params[0].strip(" ")
  24.  
  25.     in_param = params[1].strip(" ")
  26.  
  27.     if is_int_try(in_param):
  28.         age[in_name] = abs(int(in_param))
  29.     elif is_float_try(in_param):
  30.         salary[in_name] = abs(float(in_param))
  31.     else:
  32.         position[in_name] = in_param
  33.  
  34.     in_line = input()
  35.  
  36. ## Read sort coloumn
  37. sort_criteria=input().strip(" ")
  38.  
  39. if sort_criteria.lower() == "age":
  40.     for i in age:
  41.         if len(i) == 0:
  42.             continue
  43.         print(f"Name: {i}")
  44.         print(f"Age: {age[i]}")
  45.         print("====================")
  46. elif sort_criteria.lower() == "salary":
  47.     for i in salary:
  48.         if len(i) == 0:
  49.             continue
  50.         print(f"Name: {i}")
  51.         print(f"Salary: {salary[i]}")
  52.         print("====================")
  53. elif sort_criteria.lower() == "position":
  54.     for i in position:
  55.         if len(i) == 0:
  56.             continue
  57.         print(f"Name: {i}")
  58.         print(f"Position: {position[i]}")
  59.         print("====================")
RAW Paste Data