class Eng_Txt():
def __init__(self) -> None:
self.txt = {}
def add_text(self):
text = input('추가 하실 단어를 입력하세요! : ')
min = input(f'{text}의 뜻을 입력하세요! : ')
self.txt[text] = min
print('정상적으로 추가 되었어요!')
def del_text(self):
text = input('삭제 하실 단어를 입력해주세요! : ')
del self.txt[text]
print('정상적으로 삭제 되었어요!')
def txt_test(self):
while 1:
ko_en = input('영어 한국어로 적기와 한국어 영어로 적기중 무엇으로 테스트를 볼 것입니까? : ')
if ko_en in ['한국어', '영어']:
point = {'정답':0, '오답':0}
if ko_en == '한국어':
for i in self.txt:
text = input(f'{i}의 뜻을 입력해주세요! : ')
if text == self.txt[i]:
point['정답'] += 1
continue
else:
point['오답'] += 1
continue
print(f'정답 : {point["정답"]}, 오답 : {point["오답"]}')
elif ko_en == '영어':
for i in self.txt:
text = input(f'{self.txt[i]}를 영어로 입력해주세요! : ')
if text == i:
point['정답'] += 1
continue
else:
point['오답'] += 1
continue
print(f'정답 : {point["정답"]}, 오답 : {point["오답"]}')
print('"한국어", "영어" 중에 입력해주세요!')
continue
import random
menu_list = ['1', '2', '3', '4', '5', '6']
file_name = 'E:\English_word.txt' #파일명 지정
def print_line():
print('-----------------------')
def print_line2():
print('=======================')
def print_menu():
while (1):
print_line2()
print('1. 단어장 출력')
print('2. 문제 풀기') # 영단어 뜻
print('3. 종료') # 종료
print_line()
print('4. 단어 추가') #a
print('5. 단어 삭제') #w
print('6. 단어장 초기화') #초기화
print_line2()
result = input("메뉴선택 : ")
if result in menu_list:
return result
else:
print("잘못된 선택입니다.")
def f_write():
e_word = input("영단어 입력 : ")
e_mean = input("단어 뜻 입력 : ")
f = open(file_name, 'a')
f.write(e_word + '|' + e_mean + '\n')
f.close()
def f_del():
word = input("삭제할 단어입력 : ")
f = open(file_name, 'r')
lines = f.readlines()
f.close()
x = 0 #삭제 구분자
f = open(file_name, 'w')
for line in lines:
if word + '|' not in line.strip('\n'):
f.write(line)
else:
x = 1
if x == 0:
print("단어를 찾을 수 없습니다.")
else:
print("삭제완료")
f.close()
def init():
init_select = input('초기화 하시겠습니까? (Y)')
if init_select != 'y' and init_select != 'Y':
print("취소")
return
f = open(file_name, 'w')
f.write('')
f.close()
print("초기화 완료")
def f_read():
word_dic = {}
f = open(file_name, 'r')
while(1):
line = f.readline().strip()
if not line:
break
n_word = line.split('|')
if n_word[0] != '':
word_dic.setdefault(n_word[0], n_word[1])
f.close()
return word_dic
def exam():
exam_dic = f_read()
exam_list = []
for i in exam_dic.keys():
exam_list.append(i)
ex_len = len(exam_dic)
ex_num = random.randrange(0, ex_len)
ex_word = exam_list[ex_num]
print('문제 : ' + ex_word)
ex_sel = input('정답 : ')
if ex_sel == exam_dic[ex_word]:
print("정답!")
else:
print("오답입니다.")
while(True):
select = print_menu()
if select == '3': #종료
print("종료")
print_line2()
break
elif select == '1': #단어장 출력
word_dic = f_read()
for key, val in word_dic.items():
print(key + ' : ' + val)
elif select == '2': #문제풀기
exam()
elif select == '4': #단어추가
f_write()
elif select == '5': #단어삭제
f_del()
elif select == '6': #초기화
init()
print_line2()
기능 1. 단어장 목록출력(기본 x) 2. 문제풀기 3. 종료 4. 단어 추가 5. 단어 삭제 6. 단어장 초기화
2023年03月31日 13:12
int main (void)
int a ;
{
printf("-----------------------\n");
printf("1.단어추가\n");
printf("2.단어삭제\n");
printf("3.문제풀기\n");
printf("-----------------------\n");
scanf_s("메뉴선택 : %d, &a);
return 0;
}
2022年11月29日 13:50
def show_menu():
print()
print()
print ('-------------')
print ('1. 단어추가')
print ('2. 단어 삭제')
print ('3. 문제풀기')
print ('4. 단어보기')
print ('-------------')
word={}
while (1):
show_menu()
choice=int(input('메뉴 선택 : '))
if choice==1:
en_word=input('추가하려는 영어 단어를 입력해주세요...')
ko_word=input('추가하려는 영어 단어의 뜻을 입력해주세요...')
word[en_word]=ko_word
print ('단어가 추가되었습니다')
elif choice==2:
en_word=input('삭제하려는 영어 단어를 입력해주세요...')
word.pop(en_word)
print ('단어가 삭제되었습니다')
elif choice==3:
for i in word:
q=i+'의 뜻은 무엇인가요?'
ans=input(q)
if ans==word[i]:
print ('딩동댕')
else:
print ('땡')
elif choice==4:
for i in word:
print ('%15s%15s' %(i,word[i]))
else:
print ('잘못 입력하셨습니다')
dic = {'a':'ᄀ','b':'ᄂ','c':'ᄃ'}
import random
def add():
print('키(영단어) 입력하세요.')
k= input()
print('값(한국어) 입력하세요.')
v= input()
print('저장 되었습니다.')
dic[k]=v
def sub():
print('삭제하고 싶은 영단어를 입력하세요.')
k= input()
del dic[k]
print('삭제되었습니다.')
def q():
dk=list(dic.keys())
ck=random.choice(dk)
print(ck+'의 한국어 뜻은?')
ans=input()
print('당신이 입력한 답은 '+ans+', 답은 '+dic[ck])
def menu():
print('사전내용: ',list(zip(dic.keys(),dic.values())))
print("기능: 1. 단어 추가 2. 단어 삭제 3. 문제풀기")
print('실행할 기능의 번호를 입력하세요.')
mc=int(input())
print('입력한 번호는 '+str(mc))
if mc == 1:
print('단어 추가 실행')
add()
if mc == 2:
print('단어 삭제 실행')
sub()
if mc == 3:
print('문제 풀기 실행')
q()
print('끝')
while True:
menu()
def add(words):
key = input("단어 입력: ")
words[key] = input("뜻 입력: ")
def delete(words):
key = input("제거할 단어: ")
if key in words:
del words[key]
else:
print("해당 단어 없음")
def problem(words):
print("\n\n\n문제지\n")
for i in words:
print(f"{i} : ")
print("\n\n\n")
def mode(num, words):
if num == 1:
add(words)
if num == 2:
delete(words)
if num == 3:
problem(words)
if num == 4:
print(words)
words = {}
num = 3
while num != 5:
num = int(input(
"-----------------\n"
"1. 단어 추가\n"
"2. 단어 삭제\n"
"3. 문제 풀기\n"
"4. 단어장 보기\n"
"5. 종료\n"
"-----------------\n"
"번호 입력 : "
))
mode(num, words)
파이썬입니다.
import random
# Create an empty dictionary to store words
words = {}
# Function to add a word
def add_word():
eng = input("Enter the English word: ")
kor = input("Enter the Korean translation: ")
words[eng] = kor
# Function to delete a word
def delete_word():
eng = input("Enter the English word to delete: ")
del words[eng]
# Function to test the words
def test_words():
score = 0
for eng, kor in words.items():
question = random.choice([eng, kor])
if question == eng:
ans = input(f"What is the Korean translation for {eng}? ")
if ans == kor:
print("Correct!")
score += 1
else:
print(f"Incorrect. The correct answer is {kor}.")
else:
ans = input(f"What is the English translation for {kor}? ")
if ans == eng:
print("Correct!")
score += 1
else:
print(f"Incorrect. The correct answer is {eng}.")
print(f"Total score: {score}/{len(words)}")
# Main menu
while True:
print("--------------------------")
print("1. Add a word")
print("2. Delete a word")
print("3. Test words")
print("--------------------------")
choice = int(input("Menu choice: "))
if choice == 1:
add_word()
elif choice == 2:
delete_word()
elif choice == 3:
test_words()
else:
print("Invalid choice. Please try again.")
2023年01月15日 17:57
print('영어 단어장입니다')
dictionary = [['hello','안녕'],['apple','사과'],['banana','바나나']]
while True:
print("--------------------------\n1. 단어 추가\n2. 단어 삭제\n3. 문제 풀기\n4. 종료\n--------------------------")
a = int(input('메뉴 선택 : '))
if a == 1:
b = input('추가할 단어 입력(영어) : ')
b1 = b.replace(' ','')
c = input('단어의 한글 뜻 입력 : ')
c1 = c.replace(' ','')
e = [b1,c1]
dictionary.append(e)
if a == 2:
aa = 0
for i in dictionary:
print(aa+1,'',dictionary[aa][0])
aa += 1
delete = int(input('삭제하고싶은 단어의 번호를 입력하십시오 : '))
print(dictionary[delete-1][0]+' 가 삭제되었습니다.')
del dictionary[delete-1]
if a == 3:
print('문제풀기를 선택하셨습니다. 영어단어에 맞는 한국어를 입력하십시오.')
bb = 0
for ii in dictionary:
solu = ii[0]+' 의 뜻을 적으시오 : '
solution = input(solu)
solution1 = solution.replace(' ','')
if solution1 == ii[1]:
print('맞추셨습니다!')
else:
print('틀리셨습니다. X')
if a == 4:
break
2023年03月05日 20:40
import random
dictionary = {}
quiz = []
while True:
choose = int(input("""
--------------------------
1. 단어 추가
2. 단어 삭제
3. 문제 풀기
--------------------------
메뉴 선택 : """))
if choose == 1:
word = input("단어를 입력하세요. : ")
quiz.append(word)
mean = input("뜻을 입력하세요 : ")
dictionary[word]=mean
elif choose == 2:
delword = input("삭제할 단어를 입력해주세요 : ")
if delword in dictionary:
del dictionary[delword]
print(dictionary)
else:
print("입력하신 단어가 없습니다 다시 입력하여 주세요")
elif choose == 3:
quiznum = random.randrange(len(quiz))
answer = input("{0}의 뜻은 무엇인가요? : ".format(str(quiz[quiznum])))
if answer == dictionary[str(quiz[quiznum])]:
print("정답!")
else:
print("오답")
else:
print("다시 입력해 주세요")
풀이 작성