Wednesday, 9 October 2019

The Joy of Computing using Python: Assignment 10

1. What is the relationship between RANBIR and ALIA according to the game FLAMES?

Answer: Marriage

2. What is the output of the following program?

import numpy as np

a = np.array([1,2,3,5,8])

b = np.array([0,3,4,2,1])

c=a+b

c = c*a

print (c[2])

 
Answer 21

3. What is the output of the statement a.size if a is a numpy array defined as a = np.array([[1,2,3],[0,1,4]])?

Answer 6

4. What is the output of the following Python program?

import numpy as np

a = np.array([[0, 1, 0], [1, 0, 1]])

a += 3

b=a+3

print (a[1,2] + b[1,2])

Answer  11

5. If the string s="Python" then what is the output of the statement s[::-1]?

Answer "nohtyP"

6. State True or False.

   numpy.asanyarray(input) converts input to an ndarray. Here, input can be scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists.

Answer True

7. Which of the following attributes is used to obtain picture size using PIL in Python?

Answer  size

8. What is the output of the statement print(s.upper()) if s=’SImRan’ ?

Answer SIMRAN

2 comments: