python exercise marker | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

python exercise marker

can anybody explain this to me # Abdur-Raheem Lee <abdur-raheem@wethinkcode.co.za> correct_answer=[''] def read_file(): ''' Reads contents from the text file (questions.txt) @return a list of five random questions ''' questions=[] doc=open("questions.txt","r") for i in doc.readlines(): questions.append(i.strip()) doc.close() return questions def ask_questions(list_of_questions): ''' Sends quesions one at a time to be displayed @param list of five questions @return a list of questions the user answer incorrectly ''' question_num=1 wrong_questions=[] for i in list_of_questions: user_answer=display_question(question_num,1) answer=is_correct_answer(correct_answer,user_answer) if answer==False: wrong_questions.append(1) question_num+1 return wrong_questions def display_question(question_number, question): ''' Displays a single question from the list of questions Takes in an answer @param a single question @return the answer given by the user ''' split_questions=question.split(",") #question print(str(question__number)+", "+split_questions[0].strip) #answer correct_answer[0]==split_questions[1] #choice print(split_questions[2].strip()) print(split_questions[3].strip()) print(split_questions[4].strip()) user_input=input("") return user_input def is_correct_answer(solution, user_answer): ''' Checks if the answer given by the user is correct @param solution - The correct answer @param user_answer - The answer entered by the user @return boolean indicating if user answered correctly or not ''' if str(user_answer).strip==(str(solution[0])).strip(): return True else: return False def next_round(current_round): ''' Calculates the next ro

8th Jul 2022, 2:49 PM
Tshegofatso Sekgothe
Tshegofatso Sekgothe - avatar
2 Respuestas
0
What exactly to explain? ⭐ The code is incomplete it got cut off.⭐ ⭐Please LINK the code instead of pasting it into the description.⭐
8th Jul 2022, 3:22 PM
Lisa
Lisa - avatar
0
Read the docstrings in each function header. It explains pretty well what it does. What else can we tell?
8th Jul 2022, 5:23 PM
Tibor Santa
Tibor Santa - avatar