Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 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.  
  15. l1 = float(input(f'Podaj pierwsza liczbe: ').replace(',', '.'))
  16. l2 = float(input(f'Podaj druga liczbe: ').replace(',', '.'))
  17. pattern = compile(r'([\[|(])([\d\.]+);([\d\.]+)([\]|)])')
  18. for x in range(STARTUJ_OD_WIERSZA_NUMER - 1, len(ctn)):
  19.     fa = findall(pattern, ctn[x])
  20.     if eval(f"l1 {('>=' if fa[0][0] == '[' else '>')} float(fa[0][1]) and l1 {('<=' if fa[0][3] == ']' else '<')} float(fa[0][2])") \
  21.         and \
  22.         eval(f"l2 {('>=' if fa[1][0] == '[' else '>')} float(fa[1][1]) and l2 {('<=' if fa[1][3] == ']' else '<')} float(fa[1][2])"):
  23.         print(f'Odpowiedz z wiersza nr {x+1}: {ctn[x].strip()[-1]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement