 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  The Exam (Posted on 2023-08-31) Five students Adele, Betty,Carol, Doris, and Ellen- answered five questions on an exam consisting of two multiple-choice (a,b,c) questions and three true-or-false questions.

(1) They answered the questions as follows:

```       I     II.    III.    IV.     V
Adele. a      a      t       t      t
Betty. b      b      t       f      t
Carol. a      b      t       t      f
Doris. b      c      t       t      f
Ellen. c      a      f       t      t```
(2) No two students got the same number of correct answers.
Who got the most correct answers?

 See The Solution Submitted by K Sengupta Rating: 5.0000 (1 votes) Comments: ( Back to comment list | You must be logged in to post comments.) Computer solution | Comment 1 of 5
Doris got the most correct answers.

The scores are [1, 3, 2, 4, 0]
Doris achieved the highest score of 4

-----------------
students = ['aattt','bbtft','abttf','bcttf','caftt']
for v in ['a','b','c']:
for w in ['a','b','c']:
for x in ['t','f']:
for y in ['t','f']:
for z in ['t','f']:

def matches(r,s):
""" for 2 strings, r and s, how many spots with the same character? """
if len(r) != len(s):
print('not the same length')
return None
same = 0
for i,v in enumerate(r):
if r[i] == s[i]:
same += 1
return same

correctscores = []
scores = []
for student in students:
if len(set(scores)) == 5:
correctscores.append(scores)

print('The scores are', correctscores)
highestscore = max(correctscores)
print( names[ correctscores.index(highestscore) ] ,'achieved the highest score of', highestscore )
 Posted by Larry on 2023-08-31 08:47:44 Please log in:

 Search: Search body:
Forums (0)