Saturday, 11 September 2021

PYTHON - TEST (Spoken Tutorial)

PYTHON TEST

 01. Given ``odd = set([1, 3, 5, 7, 9])``

         ``squares = set([1, 4, 9, 16])``.

        What is the value of ``odd ^ squares``?

Ans :  set([3, 4, 5, 7, 16])

02. What does  ones_like() function do?

Ans : Return an array of ones with the same shape and type as a given array

03. What is the output of following?

        x = 12345

        for i in x :

        print(i)

Ans : error

04. How do you save a figure in png format with the name sine-curve?

Ans : savefig(‘sine-curve.png’)

05. What is the output of following?

        list = [1,2,3,4,5,6,7,8,9,10]

        l = sum(list[::2])

        print(l)

Ans : 25

06. What error occurs when you execute?

        a = b

Ans : NameError

07. What is the value assigned as index to the first element in a list?

Ans : 0

08. You should keep open the plot while saving the it.

 

Ans : True

09. What is the output of following?

        print(“abcabcab”.split(‘c’, 0))

Ans :  [‘abcabcab’]

10. What is the output of the following?

        a1 = array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])

         print(a1[:,1])

Ans : Error

11. What arithmetic operators cannot be used with strings ?

Ans : -

12. What is the output of the expression,  7*1**7 ?

Ans : 7

13. Which of the following functions does exactly the opposite of split() function ?

Ans : join()

14. To use the loadtxt command, each row should have the same number of values?

Ans : True

15. What is the value assigned as index to the first element in a list?

Ans : 0

16. Which marker is used to get circles...?

Ans : "0"

17. Which of the following creates 100 equally spaced points between -pi/2 and pi/2?

Ans : linspace(-pi/2, pi/2, 100)

18. Which of the following imports the odeint function.?

Ans : from scipy.integrate import odeint

19. Given two arrays A and B where ``A`` which contains co-efficients of a system of equations and ``B`` which                    

         contains    it’s constants. How will you solve the given system of equations?

Ans : solve(A,B)

20. Given the list primes, ``primes = [2, 3, 5, 7, 11]``, Which of the following code will produce the reverse of the list      ``primes``:

       (A) primes.reverse()

       (B) primes[::-1] ?

Ans : Both (A) and (B) are correct

21. Whih command is used to clear the plot?

Ans : clf()

22. What is the output of the below code snippet?

        x=0

        for y in range(21):

        x+=y

        print x

Ans : Sum of numbers up to 20(including)

23. Given strings s and t, ``s = "Hello"`` and ``t = "World"`` and an  integer r, ``r = 2``. What is the output of s * r + s * t?

Ans : HelloHelloWorldWorld

24. ``x = array([1, 2, 3], [5, 6, 7])`` is a valid statement?

Ans : False

25. Indentation is not mandatory in Python?

Ans : False

26. What is the function to get both eigen values and eigen vectors of a matrix?

Ans : eig()

27. If ``a = [1, 1, 2, 3, 3, 6,6,4]``. What is set(a)

Ans : set([1, 2, 3, 6, 4])

28. What will be the output of the below code?

       list1  = [1, 2, 3]

       list1.append([4, 5, 6])

       print(len(list1))

Ans : 4

29. Given the array, ``A = array([12, 15, 18, 21])``, how do we access the element ``18``?

Ans : A[2]

30. The % in %hist exist in all python interpreters.

Ans : False



PYTHON TEST | BY :- NISHANT KUMAR

 


8 comments:

Unknown said...

Kab hai time show nahi kar Raha hai

Saurabh Mishra said...

Good keep going

Blogger Mandeep said...

πŸ‘ŒπŸ‘ŒπŸ‘πŸ‘

Unknown said...

πŸ€—πŸ€— good job sir ji 😌


Unknown said...

Good

Unknown said...

Thank you❤πŸ™

Unknown said...

AwesomeπŸ’–πŸ‘

Unknown said...

Please post for java

ARDUINO - TEST (Spoken Tutorial) ANSWER