描述‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    大学第一学期必选课程及其学分如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬

    Python 高等数学 大学英语 大学体育 军事理论 哲学
    3学分 4学分 4学分 2学分 2学分 2学分

    请计算并输出大学第一学期共修多少学分?输入每学分应缴纳的学费(整数,单位为元),计算并输出第一学期应缴纳多少学费?输出格式请参考输入输出示例。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    输入‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    输入一个表示每学分应缴纳的学费的整数‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    输出‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    按示例格式分两行输出学分和学费‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬
    示例
    输入

    1. 328

    输出

    1. 你本学期选修了17个学分。
    2. 你应缴纳的学费为5576元。

    参考代码

    1. # ------------ ------- -------- ----------- -----------
    2. # @File : 学费计算.py
    3. # @Contact : vasp@qq.com
    4. # @Copyright : 2018-2025, Wuhan University of Technology
    5. # @Modify Time: 2021/4/26 11:36
    6. # @Author : 赵广辉
    7. # @Version : 1.0
    8. # @License : 仅限用于Python程序设计基础实践教程(赵广辉,高等教育出版社)配套实验
    9. # ------------ ------- -------- ----------- -----------
    10. # 大学第一学期必选课程及其学分如下:
    11. # Python 3 学分
    12. # 高等数学 4 学分
    13. # 大学英语 4 学分
    14. # 大学体育2 学分
    15. # 军事理论 2 学分
    16. # 哲学 2 学分
    17. # 1. 请计算并输出大学第一学期共修多少学分?输入每学分应缴纳的学费,
    18. # 计算并输出第一学期应缴纳多少学费?
    19. # 输入:
    20. # 请输入每学分学费金额:>>>328
    21. # 输出:
    22. # 你本学期选修了17 个学分。
    23. # 你应缴纳的学费为5576 元。
    24. python = 3
    25. math = 4
    26. english = 4
    27. physical_education = 2
    28. military_theory = 2
    29. philosophy = 2
    30. tuition_per_credit = int(input('请输入每学分学费金额:'))
    31. total_credits = (python + math + english + physical_education + military_theory + philosophy)
    32. total_tuition = total_credits * tuition_per_credit
    33. print(f'你本学期选修了{total_credits}个学分。')
    34. print(f'你应缴纳的学费为{total_tuition}元。')
    35. # 2. 大学可以申请助学贷款,申请额度不超过学费和生活费总额的60%,输
    36. # 入你每个月的生活费(浮点数),请计算你每个学期能够贷款多少元?(结果
    37. # 保留小数点后2 位数字,每个学期按5 个月计算)
    38. # 输入:
    39. # 请输入每学分学费金额:>>>328
    40. # 请输入你每个月生活费:>>>1600
    41. # (注:“请输入每学分学费金额:”和“请输入你每个月生活费:”是提示信息,
    42. # 由程序输出,仅328 和1600 是用户输入)
    43. # 输出:
    44. # 本学期你能够贷款8145.60 元
    45. python = 3
    46. math = 4
    47. english = 4
    48. physical_education = 2
    49. military_theory = 2
    50. philosophy = 2
    51. tuition_per_credit = int(input('请输入每学分学费金额:'))
    52. total_credits = (python + math + english + physical_education + military_theory + philosophy)
    53. total_tuition = total_credits * tuition_per_credit
    54. # print(f'你本学期选修了{total_credits}个学分。')
    55. # print(f'你应缴纳的学费为{total_tuition}元。')
    56. # 请输入每学分学费金额:328
    57. # 你本学期选修了17个学分。
    58. # 你应缴纳的学费为5576元。
    59. living_expenses = float(input('请输入你每个月生活费:'))
    60. total_cost = living_expenses * 5 + total_tuition
    61. student_loan = total_cost * 0.6
    62. print(f'本学期你能够贷款{student_loan:.2f}元')
    1. def cal_tuition(tuition_per_credit):
    2. """接受每学生的学费为在数,计算并返回总学生和总学费"""
    3. python = 3
    4. math = 4
    5. english = 4
    6. physical_education = 2
    7. military_theory = 2
    8. philosophy = 2
    9. total_credits = (python + math + english + physical_education + military_theory + philosophy)
    10. total_tuition = total_credits * tuition_per_credit
    11. return total_credits, total_tuition
    12. def loan_amount(cost, total_tuition):
    13. """接受生活费和学费为参数,计算并返回可贷款金额"""
    14. total_cost = cost * 5 + total_tuition
    15. student_loan = total_cost * 0.6
    16. return student_loan
    17. if __name__ == '__main__':
    18. tuition_credit = int(input())
    19. credit, tuition = cal_tuition(tuition_credit)
    20. print(f'你本学期选修了{credit}个学分。')
    21. print(f'你应缴纳的学费为{tuition}元。')
    22. living_expenses = float(input('请输入你每个月生活费:'))
    23. loan = loan_amount(living_expenses, tuition)
    24. print(f'本学期你能够贷款{loan:.2f}元')