• 카테고리

    질문 & 답변
  • 세부 분야

    업무 자동화

  • 해결 여부

    미해결

함수 계산 결과 불러오기

22.06.07 17:07 작성 조회수 142

0

함수를 입력했을 때 계산값이 저장이 안되서 조건문이 제대로 역할을 하지 못하는데요.

따로 열어서 계산 후 저장하고 프로그램 돌리는 것 없이 바로 함수 계산값을 활용할 수 있는 방법은 없나요?

from openpyxl import Workbook
from random import *
wb = Workbook()
ws = wb.active
ws.title = "Project"

#주어진 점수표 랜덤 생성
max_value = [10, 10, 10, 20, 30, 20]

ws["A1"] = "학번"
ws["B1"] = "출석"
ws["C1"] = "퀴즈1"
ws["D1"] = "퀴즈2"
ws["E1"] = "중간고사"
ws["F1"] = "기말고사"
ws["G1"] = "프로젝트"

for y in range(1, 8):
    if y==1:
        for x in range(2, 11):
            ws.cell(row = x, column = y, value = x-1)
    else:
        for x in range(2, 11):
            ws.cell(row = x, column = y, value = randint(0, max_value[y-2]))

#조건에 맞게 수정
y=4
for x in range(2, 11):
    ws.cell(row = x, column = y, value = 10)

ws["H1"] = "총점"
y=8
for x in range(2, 11):
    ws.cell(row = x, column = y, value = f"=sum(B{x}:G{x})")

ws["I1"] = "성적"
y=9
for x in range(2, 11):
    if ws[f"B{x}"].value < 5:
        ws[f"I{x}"] = "F"
    else:
        if ws[f"G{x}"].value >= 90:
            ws[f"I{x}"] = "A"
        elif ws[f"G{x}"].value >= 80:# and ws[f"G{x}"].value < 90:
            ws[f"I{x}"] = "B"
        elif ws[f"G{x}"].value >= 70:# and ws[f"G{x}"].value < 80:
            ws[f"I{x}"] = "C"
        else:
            ws[f"I{x}"] = "D"

wb.save("scores.xlsx")

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!