daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 47 in 1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try:
  2.     f = open('operands.txt')
  3.     compare_file = open('comparison_data.txt')
  4.  
  5.     sayilar = [i.split(' ') for i in f.read().split('\n')]
  6.     sonuclar = [i.split(' ') for i in compare_file.read().split('\n')]
  7.  
  8.     global i
  9.  
  10.     for i in range(len(sayilar)):
  11.         try:
  12.             print("------------")
  13.             kesin_sonuc = []
  14.             sonuc = list(range((int(float(sayilar[i][2]))), int(float(sayilar[i][3]) + 1)))
  15.             for x in sonuc:
  16.                 if round(x) % (round(int(float(sayilar[i][0])))) == 0 and round(x) % (
  17.                 round(int(float(sayilar[i][1])))) != 0:
  18.                     kesin_sonuc.append(x)
  19.             aaa = ' '.join(map(str, kesin_sonuc))
  20.             bbb = ' '.join(map(str, sonuclar[i]))
  21.             print("My results:\t\t", " ", aaa)
  22.             print("Results to compare:\t", " ", bbb)
  23.             try:
  24.                 assert aaa == bbb
  25.                 print('Goool!!!')
  26.             except AssertionError:
  27.                 print('Assertion Error: results don’t match.')
  28.         except ValueError:
  29.             print('ValueError: only numeric input is accepted.')
  30.             print("Given input:", ' '.join(map(str, sayilar[i])))
  31.         except IndexError:
  32.             print('IndexError: number of operands less than expected.')
  33.             print("Given input:", ' '.join(map(str, sayilar[i])))
  34.         except ZeroDivisionError:
  35.             print('ZeroDivisionError: You can’t divide by 0.')
  36.             print("Given input:", ' '.join(map(str, sayilar[i])))
  37.         except:
  38.             print('kaBOOM: run for your life!')
  39. except IndexError:
  40.     print('IndexError: number of input files less than expected.')
  41. finally:
  42.     print('˜ Game Over ˜')
RAW Paste Data
Top