General question!


#1

if i have got to create a nxn sized table of integers using randint how can i do that, i know i can create a list and append randint, but how to make so it's not in single line but rather n elements in each lines and n such lines!


#2

please explain this with code + how you want the output to look

You could use nested for loops:

for i in range(n):
     for i in range(n):

where n and n are the sizes you wish to have

Is this exercise related?


#3

so i was working on this problem :
no its not exercise related
am i not suppose to ask such questions
do we have a place in codecademy where i can discuss such general problem , since i have completed python now::::: sory for being lengthy

Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and ax, y ≠ 1, there should exist two indices s and t so that ax, y = ax, s + at, y, where ai, j denotes the integer in i-th row and j-th column.

Help Okabe determine whether a given lab is good!

Input
The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab.

The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is ai, j (1 ≤ ai, j ≤ 105).

Output
Print "Yes" if the given lab is good and "No" otherwise.

You can output each letter in upper or lower case.

Examples
input
3
1 1 2
2 3 1
6 4 1
output
Yes


#4

we have the corner bar, ideal for this kind of question, i moved this topic to corner bar

What? This instructions are very vague. where on earth do x, y ax,s and a whole bunch of other things come from?

x and y are the coordinates on the board? so 0,0 for top left corner? except they count top corner as 1,1?

How is the board generated? random numbers?

i mean, that is simple:

# python2
from random import randint
x = int(raw_input("number: "))
board = []
for a in range(x):
     row = []
     for b in range(x):
        row.append(randint(0,5)
     board.append(row)

for c in board:
     print " ".join(c)

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.