- list container만 사용하기 (다른 container사용불가)
- Class 사용금지
#2022-07-19 과제
students = [["강아지", "123", "90", "60", "80"],
["강아지2", "456", "50", "30", "80"]]
students_key = ['이름', '학번', 'Python', 'R', '통계']
def print_center(str_data):
print(f'{str_data:=^60}')
def print_bar():
print('=' * 60)
def print_bar2():
print('-' * 63)
def print_menu():
print(f'[1]성적입력 [2]전체조회 [3]학생검색 [4]종료 : ')
return input()
def print_main():
print_center(" 학점 관리 프로그램 ")
return print_menu()
def input_score():
student = []
for key in students_key:
student.append(input(f'{key}입력 : '))
students.append(student)
def get_degree(num):
if num >= 90: return "A"
if num >= 80: return "B"
if num >= 70: return "C"
if num >= 60: return "D"
return "F"
def get_student_from_num(num):
for student in students:
if student[1] == num:
return student
return []
def print_student_key():
for key in students_key:
print(f'{key:<4}', end='\t')
print(f'{"평균":<4}\t{"학점":<4}')
print_bar2()
def print_student_info(student):
for ele in student:
print(f'{ele:<4}', end='\t')
sum = 0
for val in student[2:5]:
sum += int(val)
print(f'{sum / 3:<4.1f}\t{get_degree(sum // 3):<4}')
def print_graph(student):
print(' ' * 10, '1 2 3 4 5 6 7 8 9 10')
for idx in range(2, 5):
print(f'{students_key[idx]:<6}\t : {"* " * (int(student[idx]) // 10)}')
print_bar()
def 전체조회():
print_center(" 전체 조회 ")
if len(students) == 0:
return
print_student_key()
for student in students:
print_student_info(student)
def 성적조회(num):
print_center(" 성적 조회 ")
print_student_key()
student = get_student_from_num(num)
if len(student) == 0:
return
print_student_info(student)
print_center(" 성적 그래프 ")
print_graph(student)
def main():
menu_num = -1
while not (menu_num == '4'):
menu_num = print_main()
if menu_num == '1':
input_score()
elif menu_num == '2':
전체조회()
elif menu_num == '3':
num = input('검색할 학번 입력 :')
성적조회(num)
if __name__ == '__main__':
# input_score()
# value = print_main()
# print(value)
# 전체조회()
# 성적조회('123')
# print_center("안녕하세요")
# print_graph(students[0])
main()