Beispiel #1
0
    def __init__(self):
        instruction = """Write a function called f which returns the value 42.
And then call the check method with the function
i.e. cucats.demo2.check(f)"""
        title = "Demo 2"
        Wrapper.__init__(self, title, value_answer, instruction)
        print ("Demo 2 loaded")
Beispiel #2
0
    def __init__(self):
        instruction = """Write a function called f which returns the value 42.
And then call the check method with the function
i.e. cucats.demo2.check(f)"""
        title = "Demo 2"
        Wrapper.__init__(self, title, value_answer, instruction)
        print("Demo 2 loaded")
Beispiel #3
0
def squaring(f):
    test = [int(rand() * 1000) for i in range(100)]
    answer = [x * x for x in test]
    user_answer = [f(x) for x in test]
    if (answer == user_answer):
        Wrapper.printCorrect()
    else:
        Wrapper.printWrong(user_answer, answer)
Beispiel #4
0
    def __init__(self):
        instructions = """
        In this exercise, your task is to write a function 'between(city1, city2)' that:
        - Takes the names of two cities as input strings
        - Tells us what is at the point between the cities

        To help you do this, we're giving you two functions:
        - 'coordinates(city)': Takes the name of a city as input and gives you (latitude, longitude)
        - 'city(latitude,longitude)': Takes a latitude and a longitude as input and returns a string telling you what's at the point


        Hint: the coordinates of a point in the middle of two others are the averages of the coordinates of the two points.
        Hint: 'coordinates(city)' returns a pair of values. You can record this as:
        '(latitude, longitude) = coordinates(city)'
        """
        title = "Cities"
        Wrapper.__init__(self, title, test, instructions)
        print("Cities loaded")
Beispiel #5
0
 def __init__(self):
     instruction = "Write a function f that returns the square of the input. Call ex2.check(f)"
     title = "Writing a "
     Wrapper.__init__(self, title, squaring, instruction)
     print("Exercises 2 loaded")
Beispiel #6
0
    def __init__(self):
        instruction = """Call the check method with the value of 40 + 2.
i.e. cucats.demo1.check(answer)"""
        title = "Demo 1"
        Wrapper.__init__(self, title, value_answer, instruction)
        print("Demo 1 loaded")
Beispiel #7
0
 def __init__(self):
     instruction = "Use python as a calculator to calculate the value of 2^1000. Check your answer with ex1.check(answer)"
     title = "Using python as a calculator"
     Wrapper.__init__(self, title, calculator, instruction)
     print ("Exercises 1 loaded")
Beispiel #8
0
    def __init__(self):
        instruction = """Call the check method with the value of 40 + 2.
i.e. cucats.demo1.check(answer)"""
        title = "Demo 1"
        Wrapper.__init__(self, title, value_answer, instruction)
        print ("Demo 1 loaded")
Beispiel #9
0
 def __init__(self):
     title = "Fizzbuzz"
     Wrapper.__init__(self, title, check_function, instruction)
     print(title + " loaded")
Beispiel #10
0
 def __init__(self):
     title = "Fizzbuzz"
     Wrapper.__init__(self, title, check_function, instruction)
     print (title + " loaded")
Beispiel #11
0
 def __init__(self):
     instruction = "Use python as a calculator to calculate the value of 2^1000. Check your answer with ex1.check(answer)"
     title = "Using python as a calculator"
     Wrapper.__init__(self, title, calculator, instruction)
     print("Exercises 1 loaded")