当前位置: 首页>>代码示例>>Python>>正文


Python exercise1.grade_to_gpa函数代码示例

本文整理汇总了Python中exercise1.grade_to_gpa函数的典型用法代码示例。如果您正苦于以下问题:Python grade_to_gpa函数的具体用法?Python grade_to_gpa怎么用?Python grade_to_gpa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了grade_to_gpa函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bool_input

def test_bool_input():
    """
    Boolean inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa(True)
        grade_to_gpa(False)
开发者ID:ShuaiW,项目名称:inf1340,代码行数:7,代码来源:test_exercise1.py

示例2: test_float_input

def test_float_input():
    """
    Float inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)
        grade_to_gpa(-20.5)
开发者ID:ShuaiW,项目名称:inf1340,代码行数:7,代码来源:test_exercise1.py

示例3: test_array_input

def test_array_input():
    """
    Array inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa([1, 2, 3])
    with pytest.raises(TypeError):
        grade_to_gpa(['A', 'A+', 'B-'])
开发者ID:misquit3,项目名称:inf1340_2014_asst1,代码行数:8,代码来源:test_exercise1.py

示例4: test_float_input

def test_float_input():
    """
    Float inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)

# add functions for any other tests
开发者ID:TheShadowbyte,项目名称:inf1340_2014_asst1,代码行数:8,代码来源:test_exercise1.py

示例5: test_wrong_input_type

def test_wrong_input_type():

    # Float Inputs
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)

    # Boolean Inputs
    with pytest.raises(TypeError):
        grade_to_gpa(True)
开发者ID:tabris1103,项目名称:inf1340_2014_asst1,代码行数:9,代码来源:test_exercise1.py

示例6: test_letter_input

def test_letter_input():
    """
    Grade inputs
    """
    with pytest.raises(ValueError):
        grade_to_gpa("a+")

    with pytest.raises(ValueError):
        grade_to_gpa("v")
开发者ID:peymon,项目名称:inf1340_2014_asst1,代码行数:9,代码来源:test_exercise1.py

示例7: test_gpa_consistency

def test_gpa_consistency():
    """
    Makes sure that the letters and numbers return the same values
    """
    assert grade_to_gpa(100) == grade_to_gpa("A+")
    assert grade_to_gpa(80) == grade_to_gpa("A-")
    assert grade_to_gpa(70) == grade_to_gpa("B-")
    assert grade_to_gpa(50) == grade_to_gpa("FZ")
开发者ID:structur,项目名称:inf1340_2014_asst1,代码行数:8,代码来源:test_exercise1.py

示例8: test_letter_grade

def test_letter_grade():
    """
    Letter grade inputs
    """
    assert grade_to_gpa("A+") == 4.0, "test letter: Case 1"
    assert grade_to_gpa("A") == 4.0, "test letter: Case 2"
    assert grade_to_gpa("A-") == 3.7, "test letter: Case 3"
    assert grade_to_gpa("B+") == 3.3, "test letter: Case 4"
    assert grade_to_gpa("B") == 3.0, "test letter: Case 5"
    assert grade_to_gpa("B-") == 2.7, "test letter: Case 6"
    assert grade_to_gpa("FZ") == 0.0, "test letter: Case 7"

    with pytest.raises(ValueError):
        grade_to_gpa("q")
开发者ID:jkolbe,项目名称:INF1340-Fall14-A1,代码行数:14,代码来源:test_exercise1.py

示例9: test_letter_grade

def test_letter_grade():
    """
    Letter grade inputs
    """
    assert grade_to_gpa("A+") == 4.3
    assert grade_to_gpa("A") == 4.0
    assert grade_to_gpa("A-") == 3.7
    assert grade_to_gpa("B+") == 3.3
    assert grade_to_gpa("B") == 3.0
    assert grade_to_gpa("B-") == 2.7
    assert grade_to_gpa("FZ") == 0

    with pytest.raises(ValueError):
        grade_to_gpa("q")
开发者ID:Xwzhou,项目名称:1340A1,代码行数:14,代码来源:test_exercise1.py

示例10: test_float_input

def test_float_input():
    """
        Float inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)

    with pytest.raises(TypeError):
        grade_to_gpa(79.9)

    with pytest.raises(TypeError):
        grade_to_gpa(0.4)

    with pytest.raises(TypeError):
        grade_to_gpa(99.9)

    with pytest.raises(TypeError):
        grade_to_gpa(59.9)
开发者ID:inf1340-nkt,项目名称:Excercise1,代码行数:18,代码来源:test_exercise1.py

示例11: test_float_input

def test_float_input():
    """
    Float inputs
    """
    #Tests if there are errors in the input format
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)
    with pytest.raises(TypeError):
        grade_to_gpa(0.0)
    with pytest.raises(TypeError):
        grade_to_gpa(-100.0)
    with pytest.raises(TypeError):
        grade_to_gpa(74.4)
开发者ID:goelalex,项目名称:inf1340_2014_asst1_Alex_Zhao,代码行数:13,代码来源:test_exercise1.py

示例12: test_invalid_input

def test_invalid_input():
    """
    Float, tuple and list inputs
    """
    with pytest.raises(TypeError):
        grade_to_gpa(82.5)
    with pytest.raises(TypeError):
        grade_to_gpa(['A+', 100])
    with pytest.raises(TypeError):
        grade_to_gpa(('B+', 79))
开发者ID:structur,项目名称:inf1340_2014_asst1,代码行数:10,代码来源:test_exercise1.py

示例13: test_string_input

def test_string_input():
    """
    String inputs
    """
    with exercise1.raises(ValueError):
        grade_to_gpa("Sentences")

    with exercise1.raises(ValueError):
        grade_to_gpa("This is")

    with exercise1.raises(ValueError):
        grade_to_gpa("Invalid")
开发者ID:tariqjav,项目名称:inf1340_2014_asst1,代码行数:12,代码来源:test_exercise1.py

示例14: test_float_input

def test_float_input():
    """
    Float inputs
    """
    with exercise1.raises(TypeError):
        grade_to_gpa(82.5)

    with exercise1.raises(TypeError):
        grade_to_gpa(-30.07)

    with exercise1.raises(TypeError):
        grade_to_gpa(50600)
开发者ID:tariqjav,项目名称:inf1340_2014_asst1,代码行数:12,代码来源:test_exercise1.py

示例15: test_letter_grade

def test_letter_grade():
    """
    Letter grade inputs
    """
    assert grade_to_gpa("A+") == 4.0
    assert grade_to_gpa("A") == 4.0
    assert grade_to_gpa("A-") == 3.7
    assert grade_to_gpa("B+") == 3.3
    assert grade_to_gpa("B") == 3.0
    assert grade_to_gpa("B-") == 2.7
    assert grade_to_gpa("FZ") == 0.0

    # Test for invalid letter grade input
    with pytest.raises(ValueError):
        grade_to_gpa("Q")

    # Test for invalid input - special characters
    with pytest.raises(ValueError):
        grade_to_gpa("+")

    with pytest.raises(ValueError):
        grade_to_gpa("A*")

    # Test for invalid input - numeric input
    with pytest.raises(ValueError):
        grade_to_gpa("88")

    with pytest.raises(ValueError):
        grade_to_gpa("9+")
开发者ID:tabris1103,项目名称:inf1340_2014_asst1,代码行数:29,代码来源:test_exercise1.py


注:本文中的exercise1.grade_to_gpa函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。