Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. ######################################
  2. NAZWA_PLIKU = 'plik.txt'
  3.  
  4. #opcjonalnie
  5. STARTUJ_OD_WIERSZA_NUMER = 1
  6. ######################################
  7.  
  8.  
  9. from re import findall, compile
  10. ctn = ''
  11. with open(NAZWA_PLIKU, 'r') as fd:
  12.     ctn = fd.read().replace(',', '.').splitlines()
  13.  
  14. pattern = compile(r'([\[|(])([\d\.]+);([\d\.]+)([\]|)])')
  15. for x in range(STARTUJ_OD_WIERSZA_NUMER - 1, len(ctn)):
  16.     fa = findall(pattern, ctn[x])
  17.     l1 = float(input(f'Podaj pierwsza liczbe dla wiersza nr {x+1}: ').replace(',', '.'))
  18.     l2 = float(input(f'Podaj druga liczbe dla wiersza nr {x+1}: ').replace(',', '.'))
  19.     if eval(f"l1 {('>=' if fa[0][0] == '[' else '>')} float(fa[0][1]) and l1 {('<=' if fa[0][3] == ']' else '<')} float(fa[0][2])") \
  20.         and \
  21.         eval(f"l2 {('>=' if fa[1][0] == '[' else '>')} float(fa[1][1]) and l2 {('<=' if fa[1][3] == ']' else '<')} float(fa[1][2])"):
  22.         print(ctn[x].strip()[-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement