please code in python MCQ are a very popular form of assessment because they can be automatically graded…and the students can choose an answer at random if they don’t know. The goal of this exercise is to write a function scoreMCQ(attempt, correct), where attempt is a string that contains the answers of the student and correct is a string with the correct answers. The function should return the number of correct answers. Check first that both strings have the same length, otherwise raise an exception. If both strings are empty the score should be 0 of course. To test your code, you can copy paste the following assert statements as your main function: assert(scoreMCQ("","")==0), "First test failed" assert(scoreMCQ("TFTF","TTTT")==2), "Second test failed" assert(scoreMCQ("TTTT","TTTT")==4), "Third test failed" assert(scoreMCQ("CCCC","ABCD")==1), "Fourth test failed" print("All tests succesfull")
please code in python
MCQ are a very popular form of assessment because they can be automatically graded…and the
students can choose an answer at random if they don’t know.
The goal of this exercise is to write a function scoreMCQ(attempt, correct), where attempt is
a string that contains the answers of the student and correct is a string with the correct answers.
The function should return the number of correct answers.
Check first that both strings have the same length, otherwise raise an exception.
If both strings are empty the score should be 0 of course.
To test your code, you can copy paste the following assert statements as your main function:
assert(scoreMCQ("","")==0), "First test failed"
assert(scoreMCQ("TFTF","TTTT")==2), "Second test failed"
assert(scoreMCQ("TTTT","TTTT")==4), "Third test failed"
assert(scoreMCQ("CCCC","ABCD")==1), "Fourth test failed"
print("All tests succesfull")
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)