Menu

[Solved]Python Create Second Grid Following Code Far Don T Know Change Won T Print Number Next O S Q37119821

Python: I have create the (second) grid belowand I have the following code so far but I don’t know how to changeit so that it won’t print the number next to the/o and still count correctly, also as you see inthe picture, my formatting is a little off (the numbers are too farfrom the symbol).

CURRENT CODE:

#the row and col numbers are chosen randomly

def table(col,row):
#col is width and row is height

count=1
for indexrow in range(row):
for indexcol in range(col):

if indexrow %2 == 0 and indexcol %2 == 0:
print(‘{:^3s}{:^3d}’.format(‘-‘,count),end=” “)

elif indexrow%2 != 0 and indexcol %2!= 0:

print(‘{:^3s}{:^3d}’.format(‘/o’,count), end =’ ‘)
elif indexrow %2 ==0 and indexcol %2 != 0:
  
print(‘{:^3s}{:^3d}’.format(‘+’,count),end=’ ‘)
elif indexrow%2 != 0 and indexcol %2 ==0:
  
print(‘{:^3s}{:^3d}’.format(‘*’,count),end=’ ‘)
count+=1
print()

CURRENT OUTPUT:

*7 /o8 9 /o110 11 /o112 - 13 1415 16 - 17 18 *19 o20 *21 /o22 23 /o24 - 25 26 2728 - 29 30 *31 o32 33 /o34 35 /o136 -37 3

What the output SHOULD be:

05050 511223 4-4 01020 4 +-○ 3838 2 22 01020 2 *16 161 -1616 1

*7 /o8 9 /o110 11 /o112 – 13 1415 16 – 17 18 *19 o20 *21 /o22 23 /o24 – 25 26 2728 – 29 30 *31 o32 33 /o34 35 /o136 -37 38 39 40 – 41 42 * 43 /o 4445 /o 46 * 47/o48 05050 511223 4-4 01020 4 +-○ 3838 2 22 01020 2 *16 161 -1616 1 Show transcribed image text *7 /o8 9 /o110 11 /o112 – 13 1415 16 – 17 18 *19 o20 *21 /o22 23 /o24 – 25 26 2728 – 29 30 *31 o32 33 /o34 35 /o136 -37 38 39 40 – 41 42 * 43 /o 4445 /o 46 * 47/o48
05050 511223 4-4 01020 4 +-○ 3838 2 22 01020 2 *16 161 -1616 1

Expert Answer


Answer to Python: I have create the (second) grid below and I have the following code so far but I don’t know how to change it so … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *