Question: def row _ rotation ( exam _ week, current _ seat _ status ) : total _ rows = 6 total _ columns = 5

def row_rotation(exam_week, current_seat_status):
total_rows =6
total_columns =5
# Find the current row of "AA"
position_aa =-1
for i in range(total_rows):
for j in range(total_columns):
if current_seat_status[i][j]=='AA':
position_aa = i
break
if position_aa !=-1:
break
# Calculate new position after rotation (0-indexed)
new_row =(position_aa + exam_week)% total_rows
# Initialize a new seat status for the coming week
new_seat_status =[]
for i in range(total_rows):
row =[]
for j in range(total_columns):
row.append('')
new_seat_status.append(row)
# Shift rows according to the exam week
for i in range(total_rows):
new_row_index =(i + exam_week)% total_rows
for j in range(total_columns):
new_seat_status[new_row_index][j]= current_seat_status[i][j]
# Print the new seating arrangement
for i in range(total_rows):
for j in range(total_columns):
print(new_seat_status[i][j], end='')
print() # New line after each row
# Return the new row for "AA"(1-indexed for the output)
return new_row
# Example usage:
exam_week =3
current_seat_status =[
['A','B','C','D','E'],
['F','G','H','I','J'],
['K','L','M','N','O'],
['P','Q','R','S','T'],
['U','V','W','X','Y'],
['Z','AA','BB','CC','DD'],
]
new_row_for_aa = row_rotation(exam_week, current_seat_status)
print(f"Your friend AA will be on row {new_row_for_aa +1}.")
make this code more simple

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 Programming Questions!