Question

Which option will print all the elements of rown where n is given as input and n is less than or equal to 100, from a 100 x 2
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here, the table is stored as a list-of-lists, of the form :

a[

[a0,0, a0,1, .... a0,99],

[a1,0, a1,1, .... a1,99],

..

..

a99,0, a99,1, .... a99,99]

]

For iterating over row n, we first need to find the number of columns, which in turn is equal to length of row n.

Also, since length of all rows are equal, length of row n = length of row 0, given by :

len(a[0])

We then iterate over list a[n], for the range of length given by above.

Thus, the 2nd option is the correct option :

for i in range (len(a[0])):

print(a[n][i])

Add a comment
Know the answer?
Add Answer to:
Which option will print all the elements of rown where n is given as input and...
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
  • What is the result of the following: print(input("Enter a number")* 2) if you entered 9. oooo...

    What is the result of the following: print(input("Enter a number")* 2) if you entered 9. oooo 13 Error What is the result of t = (1, 3.5): t.append(7) O (1,3,5,7) O (1,3,5) O (7) Error To check if there is a WIN in a tic-tac-toe game, the program has to check * O 6 lines of 3 boxes O 8 lines of 3 boxes O 9 boxes O The Center What is the result of print( int("3" + "5") +...

  • Create a graph in python for a given input series without using any libraries

    I was asked this question:Given any input series a corresponding graph must be generated without the use of any libraries.After, trying my best, I arrived at this solution to which they replied it had a logical issue.# Create the matrix print("Enter the sequence with spaces: ") arr = list(map(int, input().split())) count = len(arr) rows = int(sum(arr))  cols = int(sum(arr) + 4) content = [[" "]*cols for _ in range(rows)] maxq = 0 maxp = 0 content[0][0] = "/" # Apply the positions in the matrix p = 0 q = arr[0] k = 0 for l in range(q):     if (k != q):         content[k][p] = "/"         p = p + 1         k = k + 1 p = q flag = 1 i = 0 j = 0 k = 0 c = 0 temp = 0 r = 0 flag = 1 for i,j in enumerate(arr):     c = c + 1     if c < count:         k = arr[i+1]     else:         k = 0     if arr[i]:         if flag == 1:             content[q][p] = "/\\"             if maxq < q:                 maxq = q                 maxp = p             qori = q             pori = p             p = p + k             temp = q - k...

  • For all questions inputs are given. User Input is not required. For all output: Print using...

    For all questions inputs are given. User Input is not required. For all output: Print using a print() statement 1. Answer the following questions by writing a separate code for each part but submit as a single .py file: Months = [‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘June’, ‘Jul’, ‘Aug’, ‘Sep’, ‘Oct’, ‘Nov’, ‘Dec’]. a. Write code to show/illustrate 3 different list methods that can be used to remove ‘Dec’ from the list Months. (10 points) b. Output a list that...

  • Using python 3.6 How do I incorporate 0 or negative input to raise an error and...

    Using python 3.6 How do I incorporate 0 or negative input to raise an error and let the user try again? like <=0 #loop to check valid input option. while True: try: choice = int(input('Enter choice: ')) if choice>len(header): print("Invalid choice!! Please try again and select value either:",end=" ") for i in range(1,len(header)+1): print(i,end=",") else: break choice = int(input('\nEnter choice: ')) except ValueError as ve:print('Invalid response, You need to select the number choice from the option menu') # Catch your...

  • Write a program that first gets a list of integers from input. The input begins with...

    Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75....

  • IN JAVA Write a program that first gets a list of integers from input. The input...

    IN JAVA Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75...

  • need help on all parts please and thank you (e) What is the correct output of...

    need help on all parts please and thank you (e) What is the correct output of this code? (2 pts) >>> def func(x): >>> res = 0 >>> for i in range (len (x)): res i >>> return res >>> print (func(4)) ( 4 5 ) 6 ()7 ( What could be described as an immutable list? (2 pts) () a dimple ( ) a tuple ( ) a truffle () a dictionary (g) What is the result of the...

  • 3.6.x10 every other We are passing in 3 inputs A list of numbers A multiplier value,...

    3.6.x10 every other We are passing in 3 inputs A list of numbers A multiplier value, M A value, N You should multiply every Nth element ( do not multiply the 0th element)by M. So if N is 3 you start with the 3rd element which is index 2 If there are less than N elements then you should output the unchanged input list Get our input from the command line port sys İnt(sys.argv [2] ) int (sys.argv[3]) Collape) Challengs...

  • In java please :-) 12 values have been input into array yearlyValues. Output all 12 elements,...

    In java please :-) 12 values have been input into array yearlyValues. Output all 12 elements, with 4 per line. If the elements are 10 20 30 40 50 60 70 80 90 100 110 120, the output is: 10 20 30 40 50 60 70 80 90 100 110 120 Hints: • Use a for loop with increment i += 4, rather than ++i. • Inside the for loop, just print all four elements using four print statements. An...

  • (a) Write a C program to print a list of all integers between 1 and 1,000...

    (a) Write a C program to print a list of all integers between 1 and 1,000 (inclusive) which are divisible by 7 but not by 13. The list should be printed to a file called "output.dat". Remember to close the file after use. (35%) (b) Explain what is meant by the C preprocessor. Explain the effect of the following line of code: #define SQUARE (x) (x) * (x) (25%) (c) Explain the concept of an array in C. Write down...

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
ADVERTISEMENT