#twoDarray.py import random import math num_rows = int(input("Enter number of rows: ")) num_columns = int(input("Enter number of columns: ")) cell_type = input("Cells * or digit? : ") if cell_type == '*': density = float(input("Enter probability of a cell being occupied (0.0-1.0): ")) mat = [] for row_i in range(num_rows): mat.append([]) for col_j in range(num_columns): if cell_type == '*': if random.random() <= density: mat[row_i].append('*') else: mat[row_i].append(' ') else: mat[row_i].append(random.randint(0,9)) for row in mat: for col in row: print(col, end="") print()