강의

멘토링

커뮤니티

Inflearn Community Q&A

hongjp2510's profile image
hongjp2510

asked

Free Python Course (Usage 4) - Business Automation (RPA)

Quiz

함수 계산 결과 불러오기

Written on

·

247

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")
rpa

Answer

This question is waiting for answers
Be the first to answer!
hongjp2510's profile image
hongjp2510

asked

Ask a question