Question: fix this python code. there are some logical and syntax errors. class.text info is in last. from random import sample def read_classroll(filename = classroll.txt): Read

fix this python code. there are some logical and syntax errors. class.text info is in last.

from random import sample

def read_classroll(filename = "classroll.txt"):

"""Read classroll database file and return a list of students."""

with open(filename) as datafile:

students = [line.strip() for line in datafile]

return students

def assign_groups(students, n_groups=3):

"""Return the group assigment (list of lists) based on random sampling"""

groups=[]

group_size = len (students) // n_groups

#Random shuffle to avoid selection bias

shuffled = sample(students, len(students))

group_begin, group_end = 0, group_size

for i_group in range(n_groups):

group = shuffled[group_begin:group_end]

groups.append(group)

group_begin, group_end = group_end,group_end + group_size

return groups

def main():

days = "Monday", "Wednesday", "Friday"

groups = assign_groups(read_classroll(), len(days))

for day, group in zip(days, groups)

print(f" {day}")

for student in sorted( group):

print(f"\t{student}")

if __name__ = "__main__":

main()

class.text file names :-

Lucas Leadbetter

Emma Eatman

Janita Jaworski

Deon Drayton

Vernita Viers

Carmelo Copple

Donette Dewees

Laquita Loffredo

Shemika Sturgill

Marcel Murtagh

Dudley Delucca

Shea Stecker

Sid Sanks

Iola Ingles

Stanton Shankles

Asia Austin

Otha Oswalt

Glendora Gillespi

Jarvis Jewett

Claris Culbreth

Willard Weakley

Kristle Kayser

Erwin Echavarria

Beatris Briscoe

Elijah Eskridge

Kaye Krause

Stella Spain

Laci Loose

Willy Weimar

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!