/home/tuhe/Documents/unitgrade_private/examples/presentation/student_handins/intro_python_exam/tmp/submissions/s221001/2_exam.py

other

import numpy as np
from unitgrade import UTestCase, Report, hide
import intro_python
from intro_python.problems import water_height, tictactoe, time_angle, astronomical_season, standardize_address

class Q1_WaterHeight(UTestCase):
    def test1(self):
        h0 = 5
        assert(False)
other

        r = np.array([4.5, 0, 1.5, 0, 0, 0.5, 1, 2, 5])
        h = water_height(h0, r)
        print("Water height computed to be", h, "should be", self.get_expected_test_value())
        assert(False)
other

        self.assertEqual(h, 3.0) # Check the height is 3.0


class Q2_AstronomicalSeason(UTestCase):
    def test_seasons(self):
        season = astronomical_season('09/12-2020')
        print("Season was computed to be", season, "it was supposed to be", self.get_expected_test_value())
        self.assertEqualC(season)



class Q3_TimeAngle(UTestCase):
    def test_angle(self):
        a = time_angle(hour=8, minute=20)
        print("Angle was", a, "it was supposed to be", self.get_expected_test_value())
        self.assertEqualC(a)


class Q4_TicTacToe(UTestCase):
    def test_tic_tac(self):
        board = np.array([[2, 1, 1],
                          [1, 1, 2],
                          [2, 0, 0]])
        score = tictactoe(board)
        print("Score for board was", score, "it is supposed to be", self.get_expected_test_value())
        self.assertEqualC(score)



class Q5_StandardizeAddress(UTestCase):
    def test_standardize_address(self):
        s = standardize_address('New York 10001')
        print("Address computed to be", s, "was supposed to be", self.get_expected_test_value())
        self.assertEqualC(s)




class Exam2021(Report):
    title = "Introduction to Python: Exam spring 2021"
    pack_imports = [intro_python]
    questions = [(Q1_WaterHeight, 20),
                 (Q2_AstronomicalSeason, 20),
                 (Q3_TimeAngle, 20),
                 (Q4_TicTacToe, 20),
                 (Q5_StandardizeAddress, 20)]

if __name__ == "__main__":
    from unitgrade import evaluate_report_student
    evaluate_report_student(Exam2021())