• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python exercise1.grade_to_gpa函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_letter_grade

def test_letter_grade():
    """
    Letter grade inputs
    """

    # Positive Tests
    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

    # Negative Tests
    assert grade_to_gpa("A+") == 0.0
    assert grade_to_gpa("A") == 3.7
    assert grade_to_gpa("A-") == 3.3
    assert grade_to_gpa("B+") == 3.0
    assert grade_to_gpa("B") == 2.7
    assert grade_to_gpa("B-") == 0.0
    assert grade_to_gpa("FZ") == 4.0

    # Invalid string inputs
    with pytest.raises(ValueError):
        grade_to_gpa("q")
    with pytest.raises(ValueError):
        grade_to_gpa("wfucgwiubwt")
    with pytest.raises(ValueError):
        grade_to_gpa("1234567890")
开发者ID:quanras,项目名称:inf1340_2014_asst1,代码行数:30,代码来源:test_exercise1.py


示例17: test_percentage_grade

def test_percentage_grade():
    """
    Numeric grade inputs
    """
    assert grade_to_gpa(100) == 4.0, "test letter: Case 1"
    assert grade_to_gpa(95) == 4.0, "test letter: Case 2"
    assert grade_to_gpa(90) == 4.0, "test letter: Case 3"

    assert grade_to_gpa(89) == 4.0, "test letter: Case 4"
    assert grade_to_gpa(87) == 4.0, "test letter: Case 5"
    assert grade_to_gpa(85) == 4.0, "test letter: Case 6"

    assert grade_to_gpa(84) == 3.7, "test letter: Case 7"
    assert grade_to_gpa(82) == 3.7, "test letter: Case 8"
    assert grade_to_gpa(80) == 3.7, "test letter: Case 9"

    assert grade_to_gpa(79) == 3.3, "test letter: Case 10"
    assert grade_to_gpa(78) == 3.3, "test letter: Case 11"
    assert grade_to_gpa(77) == 3.3, "test letter: Case 12"

    assert grade_to_gpa(76) == 3.0, "test letter: Case 13"
    assert grade_to_gpa(74) == 3.0, "test letter: Case 14"
    assert grade_to_gpa(73) == 3.0, "test letter: Case 15"

    assert grade_to_gpa(72) == 2.7, "test letter: Case 16"
    assert grade_to_gpa(71) == 2.7, "test letter: Case 17"
    assert grade_to_gpa(70) == 2.7, "test letter: Case 18"

    assert grade_to_gpa(69) == 0.0, "test letter: Case 19"
    assert grade_to_gpa(37) == 0.0, "test letter: Case 20"
    assert grade_to_gpa(0) == 0.0, "test letter: Case 21"

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


示例18: grade_to_gpa

    assert grade_to_gpa(0) == 0.0, "test letter: Case 21"

    with pytest.raises(ValueError):
        grade_to_gpa(101)
        grade_to_gpa(-1)


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

# add functions for any other tests

# imports one per line
import pytest

from exercise1 import grade_to_gpa

grade = input("Enter Grade: ")
if grade.isdigit():
    grade = int(grade)
    print(grade_to_gpa(grade))
else:
    print(grade_to_gpa(grade))
test_float_input()
test_letter_grade()
test_percentage_grade()
开发者ID:jkolbe,项目名称:INF1340-Fall14-A1,代码行数:30,代码来源:test_exercise1.py


示例19: 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
    
    with pytest.raises(ValueError):
        grade_to_gpa("Q")  # not within letter grade range
    with pytest.raises(ValueError):
        grade_to_gpa("a+")  # not correct format; capitalization
    with pytest.raises(ValueError):
        grade_to_gpa("A Plus")  # not correct spelling
    with pytest.raises(ValueError):
        grade_to_gpa("Perfect!")  # not proper input value
开发者ID:soniaduda,项目名称:inf1340_2014_asst1,代码行数:21,代码来源:test_exercise1.py


示例20: test_cornercase_input

def test_cornercase_input():
    """
        Check Corner Testcases - Checking the cases that are right on the boundary.
    """
    assert grade_to_gpa(90) == 4.0
    assert grade_to_gpa(70) == 2.7
开发者ID:inf1340-nkt,项目名称:Excercise1,代码行数:6,代码来源:test_exercise1.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python exercise1.pig_latinify函数代码示例发布时间:2022-05-24
下一篇:
Python executor.Executor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap