Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
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
Beispiel #8
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
Beispiel #9
0
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
Beispiel #10
0
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
Beispiel #11
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
Beispiel #12
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
Beispiel #13
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
Beispiel #14
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
Beispiel #15
0
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
Beispiel #16
0
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
Beispiel #17
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
Beispiel #18
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
Beispiel #19
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
Beispiel #20
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
Beispiel #21
0
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
Beispiel #22
0
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
Beispiel #23
0
def getvalue():
@    @f1@@
    if not 'x' in locals():
        raise pythia.UndeclaredException('undeclared')
    elif not type(x) == int:
        raise pythia.BadTypeException('badtype')
    return x
Beispiel #24
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
Beispiel #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)
Beispiel #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)
Beispiel #27
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