예제 #1
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def swap(x, y):
@    @f1@@
    if 'x' not in locals():
        raise pythia.UndeclaredException('x')
    if 'y' not in locals():
        raise pythia.UndeclaredException('y')
    if type(x) != int:
        raise pythia.BadTypeException('x', type(x), int)
    if type(y) != int:
        raise pythia.BadTypeException('y', type(y), int)
    return (x, y)
예제 #2
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def toursnumber(A, B):
@    @f1@@
    if 'pierre' not in locals():
        raise pythia.UndeclaredException('pierre')
    if 'claire' not in locals():
        raise pythia.UndeclaredException('claire')
    if type(pierre) != int:
        raise pythia.BadTypeException('pierre', type(pierre), int)
    if type(claire) != int:
        raise pythia.BadTypeException('claire', type(claire), int)
    return (pierre, claire)
예제 #3
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def simplify(time):
@    @f1@@
    if 'minutes' not in locals():
    	raise pythia.UndeclaredException('minutes')
    if 'seconds' not in locals():
        raise pythia.UndeclaredException('seconds')
    if type(minutes) != int:
    	raise pythia.BadTypeException('minutes', type(minutes), int)
    if type(seconds) != int:
        raise pythia.BadTypeException('seconds', type(seconds), int)
    return (minutes, seconds)
예제 #4
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def intanddec(s):
@    @f1@@
    if 'i' not in locals():
        raise pythia.UndeclaredException('i')
    if 'd' not in locals():
        raise pythia.UndeclaredException('d')
    if type(i) != int:
        raise pythia.BadTypeException('i', type(i), int)
    if type(d) != float:
        raise pythia.BadTypeException('d', type(d), float)
    return (i, d)
예제 #5
0
def computeend(hour, minute, second, duration):
@    @f1@@
    if 'endhour' not in locals():
        raise pythia.UndeclaredException('endhour')
    if 'endminute' not in locals():
        raise pythia.UndeclaredException('endminute')
    if type(endhour) != int:
        raise pythia.BadTypeException('endhour', type(endhour), int)
    if type(endminute) != int:
        raise pythia.BadTypeException('endminute', type(endminute), int)
    return (endhour, endminute)
예제 #6
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def checktemp(temperature, thermostat):
@    @f1@@
    if 'outlimits' not in locals():
        raise pythia.UndeclaredException('outlimits')
    if 'thermostat' not in locals():
        raise pythia.UndeclaredException('thermostat')
    if type(outlimits) != bool:
        raise pythia.BadTypeException('outlimits', type(outlimits), bool)
    if type(thermostat) != int:
        raise pythia.BadTypeException('thermostat', type(thermostat), int)
    return (outlimits, thermostat)
예제 #7
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def isbool(x):
@    @f1@@
    if 'ok' not in locals():
        raise pythia.UndeclaredException('ok')
    if type(ok) != bool:
        raise pythia.BadTypeException('ok', type(ok), bool)
    return ok
예제 #8
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def taxincluded(price, rate):
@    @f1@@
    if 'fullprice' not in locals():
        raise pythia.UndeclaredException('fullprice')
    if type(fullprice) != float:
        raise pythia.BadTypeException('fullprice', type(fullprice), float)
    return fullprice
예제 #9
0
def sumsinus(a, b):
@    @f1@@
    if 'result' not in locals():
        raise pythia.UndeclaredException('result')
    if type(result) != float:
        raise pythia.BadTypeException('result', type(result), float)
    return result
예제 #10
0
def canbuy(unitprice, quantity, money):
@    @f1@@
    if 'buy' not in locals():
        raise pythia.UndeclaredException('buy')
    if type(buy) != bool:
        raise pythia.BadTypeException('buy', type(buy), bool)
    return buy
예제 #11
0
def theaterprice(age, loyalty):
@    @f1@@
    if 'price' not in locals():
        raise pythia.UndeclaredException('price')
    if type(price) != int:
        raise pythia.BadTypeException('price', type(price), int)
    return price
예제 #12
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def syracuse(n):
@    @f1@@
    if 'time' not in locals():
        raise pythia.UndeclaredException('time')
    if type(time) != int:
        raise pythia.BadTypeException('time', type(time), int)
    return time
예제 #13
0
def convert(temperature, unit, to):
@    @f1@@
    if 'result' not in locals():
        raise pythia.UndeclaredException('result')
    if type(result) != float:
        raise pythia.BadTypeException('result', type(result), float)
    return result
예제 #14
0
def isforbidden(height):
@    @f1@@
    if 'forbidden' not in locals():
        raise pythia.UndeclaredException('forbidden')
    if type(forbidden) != bool:
        raise pythia.BadTypeException('forbidden', type(forbidden), bool)
    return forbidden
예제 #15
0
def binom(n, k):
@    @f1@@
    if 'coeff' not in locals():
        raise pythia.UndeclaredException('coeff')
    if type(coeff) != int:
        raise pythia.BadTypeException('coeff', type(coeff), int)
    return coeff
예제 #16
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def computesum(n):
@    @f1@@
    if 'result' not in locals():
        raise pythia.UndeclaredException('result')
    if type(result) != int:
        raise pythia.BadTypeException('result', type(result), int)
    return result
예제 #17
0
def computeprice(quantity, unitprice, loyalty):
@    @f1@@
    if 'totalprice' not in locals():
        raise pythia.UndeclaredException('totalprice')
    if type(totalprice) != float:
        raise pythia.BadTypeException('totalprice', type(totalprice), float)
    return totalprice
예제 #18
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def printdate(day, month, year):
@    @f1@@
    if 'date' not in locals():
        raise pythia.UndeclaredException('date')
    if type(date) != str:
        raise pythia.BadTypeException('date', type(date), str)
    return date
예제 #19
0
def getvalue():
@    @f1@@
    if not 'x' in locals():
        raise pythia.UndeclaredException('undeclared')
    elif not type(x) == int:
        raise pythia.BadTypeException('badtype')
    return x
예제 #20
0
def lettersinterval(start, end):
@    @f1@@
    if 'result' not in locals():
        raise pythia.UndeclaredException('result')
    if type(result) != str:
        raise pythia.BadTypeException('result', type(result), str)
    return result
예제 #21
0
def containstype(x):
@    @f1@@
    if 'istype' not in locals():
        raise pythia.UndeclaredException('istype')
    if type(istype) != bool:
        raise pythia.BadTypeException('istype', type(istype), bool)
    return istype
예제 #22
0
def absval(x):
@    @f1@@
    if 'x' not in locals():
        raise pythia.UndeclaredException('x')
    if type(x) != int:
        raise pythia.BadTypeException('x', type(x), int)
    return x
예제 #23
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def isprime(n):
@    @f1@@
    if 'prime' not in locals():
        raise pythia.UndeclaredException('prime')
    if type(prime) != bool:
        raise pythia.BadTypeException('prime', type(prime), bool)
    return prime
예제 #24
0
def concat(hour, minute, second):
@    @f1@@
    if 'result' not in locals():
        raise pythia.UndeclaredException('result')
    if type(result) != str:
        raise pythia.BadTypeException('result', type(result), str)
    return result
예제 #25
0
 def studentCode(self, data):
     find = [f for (n, f) in inspect.getmembers(q1, inspect.isfunction) if n == 'isperfect']
     if len(find) != 1:
         raise pythia.UndeclaredException('isperfect')
     if not callable(find[0]):
         raise pythia.BadTypeException('isperfect', type(find[0]), 'function')
     spec = inspect.getargspec(find[0])
     if len(spec.args) != 1:
         raise pythia.WrongParameterNumberException('isperfect', len(spec.args), 1)
     return q1.isperfect(data)
예제 #26
0
sys.stdout = open('/tmp/work/output/stdout', 'w')
sys.stderr = open('/tmp/work/output/stderr', 'w')

# Try to import student's code
sys.path.append('/tmp/work')
try:
    import q1
except Exception as e:
    print(e, file=sys.stderr)
    sys.exit(0)

# Execute student's code
try:
    find = [f for (n, f) in inspect.getmembers(q1, inspect.isfunction) if n == 'printhelloworld']
    if len(find) != 1:
        raise pythia.UndeclaredException('printhelloworld')
    if not callable(find[0]):
        raise pythia.BadTypeException('printhelloworld', type(find[0]), 'function')
    spec = inspect.getargspec(find[0])
    if len(spec.args) != 0:
        raise pythia.WrongParameterNumberException('printhelloworld', len(spec.args), 0)
    q1.printhelloworld()
except pythia.UndeclaredException as e:
    print('exception:undeclared:{}'.format(e.name), file=sys.stderr)
except pythia.BadTypeException as e:
    print('exception:badtype:{}:{}:{}'.format(e.name, e.actualtype, e.expectedtype), file=sys.stderr)
except pythia.WrongParameterNumberException as e:
    print('exception:wrongparameterexception:{}:{}:{}'.format(e.name, e.actualnumber, e.expectednumber), file=sys.stderr)
except Exception as e:
    print('exception:{}'.format(e), file=sys.stderr)
예제 #27
0
파일: q1.py 프로젝트: ukonline/pythia-tasks
def truthvalue(a, b, c):
    result = @@f1@@
    if type(result) != bool:
        raise pythia.BadTypeException('result', type(result), bool)
    return result
예제 #28
0
# -*- coding: utf-8 -*-
# Course: Apprendre Python
# Problem: Variable modification

import sys

sys.path.append('/task/static')
from lib import pythia

def getvalue():
    x = 10
@    @f1@@
    if not 'x' in locals():
        raise pythia.UndeclaredException('deleted')
    elif not type(x) == int:
        raise pythia.BadTypeException('badtype')
    return x
예제 #29
0
def div2and3(n):
    S = @@f1@@
    if type(S) != set:
        raise pythia.BadTypeException('S', type(S), set)
    return S
예제 #30
0
def absval(x):
    result = @@f1@@
    if type(result) != int:
        raise pythia.BadTypeException('result', type(result), int)
    return result