Question: Number Classification Grid ( Python ) ~ Create a Python program that fills a 5 5 grid with numbers from 1 to 2 5 .

Number Classification Grid(Python) ~
Create a Python program that fills a 55 grid with numbers from 1 to 25. The program should classify each number in the grid as either even or odd using loops and conditionals, and print the grid with its classification.
Instructions:
Use loops to fill a 55 grid with numbers from 1 to 25.
Use nested loops and conditional statements (if, if-else-if, or match) to classify each number as "E" for even or "O" for odd.
Print the 55 grid showing each number along with its classification.
Sample Output:
1(O)2(E),3(O),4(E),5(O)
6(E),7(O),8(E),9(O),10(E)
11(O),12(E),13(O),14(E),15(O)
16(E)17(O),18(E),19(O),20(E)
21(O),22(E),23(O),24(E),25(O)
I was able to get the 5x5 number grid. I'm having trouble putting the letters beside the number while keeping it in grid form. Thanks for the help.
Here is my code:
for i in range(n):
for stars in range(n):
print(f"{number}", end="")
number +=1
number +=1
if number %2==0:
print("(O)")
else:
print("(E)")
print("")

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!