Question

PYTHON Ask the user for a value N (0 ≤ N < 10) Create a 2-D...

PYTHON

Ask the user for a value N (0 ≤ N < 10)

Create a 2-D list in an N X N structure with integers 1-(N*N)

Print the list created

Reverse the list such that (1) each list in the 2D list is reversed and (2) the order of each list in the outer list is reversed (see example)

Print the reversed list

Example Execution

What size 2D list would you like to create?
N> 3

The original list is:
[ [1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]

The reversed list is:
[ [9, 8, 7],
[6, 5, 4],
[3, 2, 1]
]

Homework Answers

Answer #1
print("What size 2D list would you like to create?")
n = int(input("N> "))
value = 1
lst = []
for i in range(n):
    temp = []
    for j in range(n):
        temp.append(value)
        value += 1
    lst.append(temp)
print("\nThe original list is:")
print(lst)
reversedList = []
for i in range(len(lst)-1,-1,-1):
    reversedList.append(lst[i][::-1])
print("\nThe reversed list is:")
print(reversedList)

Know the answer?
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
Similar Questions
Flowchart + Python. Ask the user for a value. Then, ask the user for the number...
Flowchart + Python. Ask the user for a value. Then, ask the user for the number of expressions of that value. Use While Loops to make a program. So then, it should be so that 5 expressions for the value 9 would be: 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 Flowcharts and Python Code. Not just Python code.
In Python language: Create a function that takes as input two numbers, m and n, m<n,...
In Python language: Create a function that takes as input two numbers, m and n, m<n, and returns an m×n list-of-list-of-numbers. Each element of the outer list will be a list of consecutive integers, beginning with 1 and ending with n−1. If you're feeling bold, try to use list comprehension.
On python a) Create a dictionary with 5 to 10 key-values so that state is the...
On python a) Create a dictionary with 5 to 10 key-values so that state is the key and its capital is the value. Print the dictionary and its length. b) Create and print a list of states and a list of capitals. c) Ask the user for a state's name. Check to see if the state's name exists in the list of states. If it does, look up the state's name in the dictionary and print out its capital. If...
Write a Python program to ask how many elements do users want to create in a...
Write a Python program to ask how many elements do users want to create in a list, then let the user create 2 lists with the number of elements previously entered. Then create and display all combinations of letters, selecting each letter from a different key in a dictionary. Example: How many elements? 2 List 1 = ['a', 'b'] List 2 = ['c', 'd'] Output: ac ad bc bd
Write a Python program to ask user input of a string, then ask user input of...
Write a Python program to ask user input of a string, then ask user input of what letters they want to remove from the string. User can either put in "odd", "even" or a number "n" that is greater than 2. When user input "odd", it will remove the characters which have odd numbers in the sequence of the string. When user input "even", it will remove the characters which have even numbers in the sequence of the string. When...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
Question1: Write a Python Program that asks for the grades of 5 quizzes and then prints...
Question1: Write a Python Program that asks for the grades of 5 quizzes and then prints the highest grade. [6 Marks] Question2: Write a Python Program that does the following tasks. [8 Marks] Create an empty list Ask the user for 5 positive numbers and append them to the list Find and print the sum of all the numbers in the list Delete the last element from the list and then print the list Question3: Consider you have the following...
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for...
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for 5 bases and 5 heights (you can use an array), have a function to print the triangle bases, heights, and areas 2. Create a structure for the Triangle that holds the base and height of the triangles. Ask the user for 5 triangles, and print them. 3. Create an array of 5 structures - ask the user for 5 triangles, and then print the...
1) Create an interface to the keyboard (Scanner). Scanner is described in Chapter 2. 2) Prompt...
1) Create an interface to the keyboard (Scanner). Scanner is described in Chapter 2. 2) Prompt the user to enter their first and last name.. 3) Read the name into a String. 4) Print a person greeting such as “Hello FirstName LastName”. Print the users name in the greeting. 5) Prompt the user to enter 2 integers. 6) Read the integers into 2 variables into your program. 7) Prompt the user to enter a math operation – one of +,-,*,/...
Write a Python program that prompts a user for two integers and stores the two integers...
Write a Python program that prompts a user for two integers and stores the two integers the user types into the shell. Print the product, float division, integer division, remainder, sum, and difference of the two integers to the console. The entire equation must be printed (see below for formatting). Only display 2 digits after the decimal place for results that are floats. Include a module docstring that summarizes the program.. Sample Run 1: Enter an integer: 5 Enter another...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT