Advertisement
molnarjani

Untitled

May 28th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. class Tetel:
  2.     def __init__(self, f):
  3.         global x
  4.         f, x = open(f,'r'), []
  5.         for l in f:
  6.            x += [int(l)]
  7.  
  8.     def osszegez(self):
  9.         sum = 0
  10.         for n in x:
  11.             sum = sum + n
  12.         return sum
  13.  
  14.     def maxker(self):
  15.         max = x[:].pop(0)
  16.         for n in x:
  17.             if n > max: max = n
  18.         return max
  19.  
  20.     def feltmaxker(self, f):
  21.         max, b = x[:].pop(0), False
  22.         for n in x:
  23.             if b:
  24.                 if f(n):
  25.                     if n > max: max = n
  26.             if not b:
  27.                 if f(n): max, b = n, True
  28.         return max
  29.  
  30.     def szamlal(self, f):
  31.         db = 0
  32.         for n in x:
  33.             if f(n): db = db + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement