Question

IN PYTHON

Problem 2: (20pt) Use nested list to create a grid as follows, 100001 100001 100001 011110 011110 011110

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Initialize the python list as follows

list1= [[1,0,0,0,0,1],[1,0,0,0,0,1],[1,0,0,0,0,1],[0,1,1,1,1,0],[0,1,1,1,1,0],[0,1,1,1,1,0]]

This creates a nested list.

Alternatively, using for loop, the grid can be created as follows:

matrix = []   

for i in range(3):
matrix.append([1,0,0,0,0,1])
for j in range(3):
matrix.append([0,1,1,1,1,0])
  
  
print(matrix)

Add a comment
Know the answer?
Add Answer to:
IN PYTHON Problem 2: (20pt) Use nested list to create a grid as follows, 100001 100001...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Python programming, create a 2-by-3 list, then use a nested loop to: 1) Set each...

    Using Python programming, create a 2-by-3 list, then use a nested loop to: 1) Set each element's value to an integer indicating the order in which it was processed by the nested loop (1, 2, 3, 4, 5, 6). 2) Display the elements in tabular format. Use the column indices as headings across the top, and the row indices to the left of each row.

  • 1. Use Turtle Graphics to create a tic tac toe grid in Python. Write a Python...

    1. Use Turtle Graphics to create a tic tac toe grid in Python. Write a Python program that prints a tic tac toe grid. Use Turtle Graphics to create the graphic.

  • Use python to write a code Problem 1: Environmental Monitoring You are given a nested list...

    Use python to write a code Problem 1: Environmental Monitoring You are given a nested list in which the sublists contain tuples! Example: samples = [ [('frog','H'), ('toad','D') ], [('trout','H'), ('salmon','S'), ('catfish','H')] ] Here each species is either healthy H, dead D or sick S. Access the health status of a specified animal using multi-indexing. Count how many are healthy using two nested for loops. List will be bigger and different on each version.

  • PA 9-1 (25 points) Use nested loops to create a 11x11 grid like the one below....

    PA 9-1 (25 points) Use nested loops to create a 11x11 grid like the one below. Tab in to start each row. Each cell is one row tall and three spaces wide. Dash (-) characters (45) were used to construct the horizontal lines. Using the rand function (hint: rand()%15) fill in all the cells in the grid with characters from ASCII number 33 (!) to 47(/). For full credit, use nested loops and center the digits in cells. Hint: for...

  • create anything in python. Make sure your code covers all of the following things: • Use...

    create anything in python. Make sure your code covers all of the following things: • Use the concepts of object-based programming—classes, objects, and methods • Draw two-dimensional shape • Use the RGB system to create colors in graphics applications and modify pixels in images • Develop recursive algorithms to draw recursive shapes • Write a nested loop to process a two-dimensional grid • Perform simple transformations of images, such as conversion of color to gray-scale

  • PYTHON Define a function reverseNestedList(...) which receives one possibly nested list (lst1) and returns the reverse...

    PYTHON Define a function reverseNestedList(...) which receives one possibly nested list (lst1) and returns the reverse of both the given list and any nested lists inside it. Note that the testing inputs will not include lists that are nested more than twice (a list in a list in a list ++...) [[[...],1], 1] Good luck! As an example, the following code fragment: lst1 = [[1, 2], [3, 4]] print(reverseNestedList(lst1)) should produce the output: [[4, 3], [2, 1]]

  • Problem 1. Write a Python function times_i_at_odd(L) that takes as arguments a list L and returns...

    Problem 1. Write a Python function times_i_at_odd(L) that takes as arguments a list L and returns a list consisting of the elements of L multiplied by the index number of the element at odd positions. (Use list comprehensions) >>> times_i_at_odd([1,2,3,4,5,6,7,8,9,10]) [2, 12, 30, 56, 90] Problem 2. Write a recursive function sum_cols(grid, n) that takes a list of lists of integers grid and integer n and returns the sum of column n in grid. For example, the call sum_cols([[1,2,3,4], [10,20,30,40],...

  • Using python, create a program using nested loops to write a function called substring(s,b) that returns...

    Using python, create a program using nested loops to write a function called substring(s,b) that returns True or False depending on whether or not b is a substring of s. For example: String: "Diamond" Substring: "mond" The code will then state that this is true and "mond" is a substring of "Diamond". Example of what the program should output: Enter string: Tree Enter substring: Tre Yes, 'Tre' is a substring of 'Tree' Limitation: This program cannot use "find()" and "in"...

  • I want to write a python function to find the minimum I have an nested list:...

    I want to write a python function to find the minimum I have an nested list: list = [[0,2,3], [1,6],[4,7]] I want to find out in minimum of each list and compare between each other then return the final minimum result for example: above the nested_list [[0,2,3], [1,6],[4,7,11]], for each set of the list the minimum would be [1,5,3] -> final return would be [1]

  • write in python Create a program that will ask the user for a list of integers,...

    write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT