125k views
5 votes
Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat. Sample output with inputs: 2 3 1A 1B 1C 2A 2B 2C num_rows = int(input()) num_cols = int(input()) # Note 1: You will need to declare more variables # Note 2: Place end=' ' at the end of your print statement to separate seats by spaces ''' Your solution goes here ''' print()

1 Answer

2 votes

Here's a Python code snippet that takes num_rows and num_cols as input and prints a list of all seats in a theater:

num_rows = int(input("Enter the number of rows: "))

num_cols = int(input("Enter the number of columns: "))

This code uses nested loops to iterate over each row and column, combining the row number with the corresponding column letter using ASCII values.

The end=' ' argument in the print statement is used to separate each seat with a space. The Python code snippet that takes num_rows and num_cols as input and prints a list of all seats in a theater.

User Maximede
by
7.5k points