This Python program generates a grid of numbers where each row starts with a specific value and increases by 2 across columns.
For example, the first row starts at 2 and continues: 2, 4, 6, 8, 10, 12
The second row starts at 6 and continues: 6, 8, 10, 12, 14, 16
And so on for the remaining rows.
# Starting values for each row
start_values = [2, 6, 10, 14]
columns = 6
print("Generated Number Grid:")
for start in start_values:
row = []
for i in range(columns):
row.append(start + 2 * i)
print('\t'.join(map(str, row)))
2 4 6 8 10 12
6 8 10 12 14 16
10 12 14 16 18 20
14 16 18 20 22 24
- The start_values list defines the starting number for each row
- Each row increases by 2 using the formula start + 2 * i
- map(str, row) converts numbers to strings for printing
- '\t'.join(...) formats the row with tab spacing