조카놈이 공부를 너무 안하고 못해서 영어 불규칙 동사를 외우게 시킬 겸 간단한 프로그램을 만들어 보았습니다. 준비물은 Google Colab 로그인과 해당 코드에 쓰인 "test.txt" 파일입니다. 파일은 아래에 첨부해 놓겠습니다.
import random
f = open("test.txt")
lines = f.readlines()
f.close()
test = []
for i in range(1,len(lines)//10):
temp = []
for j in range(3):
temp.append(lines[i*10+4+j*2][:-1])
test.append(temp)
def irregular_verb_test(num_prob):
num = list(range(119))
num = random.sample(num, num_prob)
score = 0
for i in num:
inp1 = input(test[i][0] + "의 과거형은 무엇입니까?: ")
inp2 = input(test[i][0] + "의 과거분사형은 무엇입니까?: ")
if inp1 == test[i][1] and inp2 == test[i][2]:
print("정답입니다.")
score += 1
else:
print(f"오답입니다. 정답은 {test[i][1]}, {test[i][2]}입니다.")
per_score = score/num_prob*100
print(f"\n 당신의 점수는 {per_score}점입니다.")
아래는 코드에 쓰인 텍스트 파일입니다.
너무 쉬운거라 올릴까 말까 하다가 혹여나 필요한 사람이 있을수도 있고 저도 언젠간 쓸일이 있을 것 같아 업로드 해둡니다.
728x90
반응형
'프로그래밍 이것저것' 카테고리의 다른 글
Anaconda에서 GPU 사용 가능한 Tensorflow 설치하기 (0) | 2025.02.04 |
---|---|
VS Code에서 OpenMC 실습해 보기 (0) | 2024.09.20 |
Windows 사용자를 위한 VS Code로 OpenMC 설치하기 (11) | 2024.09.19 |
Windows 사용자를 위한 Anaconda Navigator로 OpenMC 설치하기 (12) | 2024.09.18 |
[코딩] 파이썬 기초 수업 소개 (0) | 2023.03.22 |