Python interview questions part 33

Python interview questions part 33

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Which of the following matrices will throw an error in Python?

Correct Answer is : B = [[3, 3, 3]

2. Which of the following matrices will throw an error in Python?

Correct Answer is : B = [[3, 3, 3]

3. What is the output of the snippet of code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] A[1]

Correct Answer is : [4, 5, 6]

4. What is the output of the snippet of code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] A[1]

Correct Answer is : [4, 5, 6]

5. Which of the following statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Correct Answer is : A[1][2]

6. Which of the following statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Correct Answer is : A[1][2]

7. What is the output of the code shown? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[row][1] for row in (0, 1, 2)]

Correct Answer is : [2, 5, 8]

8. What is the output of the code shown? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[row][1] for row in (0, 1, 2)]

Correct Answer is : [2, 5, 8]

9. What is the output of the code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][i] for i in range(len(A))]

Correct Answer is : [1, 5, 9]

10. What is the output of the code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][i] for i in range(len(A))]

Correct Answer is : [1, 5, 9]

11. What is the output of the following code? l=[[1, 2, 3], [4, 5, 6]] for i in range(len(l)): for j in range(len(l[i])): l[i][j]+=10 l

Correct Answer is : [[11, 12, 13], [14, 15, 16]]

12. What is the output of the following code? l=[[1, 2, 3], [4, 5, 6]] for i in range(len(l)): for j in range(len(l[i])): l[i][j]+=10 l

Correct Answer is : [[11, 12, 13], [14, 15, 16]]

13. What is the output of the code shown? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]   [[col + 10 for col in row] for row in A]

Correct Answer is : [[11, 12, 13], [14, 15, 16], [17, 18, 19]]

14. What is the output of the code shown? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]   [[col + 10 for col in row] for row in A]

Correct Answer is : [[11, 12, 13], [14, 15, 16], [17, 18, 19]]

15. What is the output of the code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][len(A)-1-i] for i in range(len(A))]

Correct Answer is : [3, 5, 7]

16. What is the output of the code shown below? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] [A[i][len(A)-1-i] for i in range(len(A))]

Correct Answer is : [3, 5, 7]

17. The service in which the cloud consumer does not manage the underlying cloud infrastructure nor the application(s) contained in the instances as the service provides user with all of it is: A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B = [[3, 3, 3], [4, 4, 4], [5, 5, 5]] [B[row][col]*A[row][col] for row in range(3) for col in range(3)]

Correct Answer is : [0, 30, 60, 120, 160, 200, 300, 350, 400]

18. The service in which the cloud consumer does not manage the underlying cloud infrastructure nor the application(s) contained in the instances as the service provides user with all of it is: A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B = [[3, 3, 3], [4, 4, 4], [5, 5, 5]] [B[row][col]*A[row][col] for row in range(3) for col in range(3)]

Correct Answer is : [0, 30, 60, 120, 160, 200, 300, 350, 400]

19. What is the output of the code shown? r = [11, 12, 13, 14, 15, 16, 17, 18, 19] A = [[0, 10, 20], [30, 40, 50], [60, 70, 80]] for row in A: for col in row: r.append(col+10) r

Correct Answer is : [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40, 50, 60, 70, 80, 90]

20. What is the output of the code shown? r = [11, 12, 13, 14, 15, 16, 17, 18, 19] A = [[0, 10, 20], [30, 40, 50], [60, 70, 80]] for row in A: for col in row: r.append(col+10) r

Correct Answer is : [11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 20, 30, 40, 50, 60, 70, 80, 90]

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon