Advertisement
Guest User

Untitled

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