# Python Test Answers » Spoken Tutorial

Python Test Answers Spoken Tutorial Quiz Answers:- We have provided 34 Questions and Answers of Python Test. Spoken Tutorial Provides certificate only if you passed the aggregate percentage fixed by Spoken Tutorial.

## Spoken Tutorial – Python Test Answers

Q1. What will be the output of following?

`x = ‘abcd’for i in range(len(x)):print(x[i])`
• (A) None of them
• (B) a b c d
• (C) error
• (D) a
`Ans:-  (B) a b c d `

Q2. Predict the output for ones_like([12, 13, 14, 15]) ?

• (A) array([12, 13, 14, 15])
• (B) array[12, 13, 14, 15]
• (C) array([1, 1, 1, 1])
• (D) array([1.0, 1.0, 1.0, 1.0])
`Ans:-  (C) array([1, 1, 1, 1]) `

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

• (A) set([1, 2, 3, 3, 6,6])
• (B) set([1, 2, 3, 6, 4])
• (C) Error
• (D) set([1, 1, 2, 3, 3, 6,6,4])
`Ans:-  (B) set([1, 2, 3, 6, 4])`

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

• (A) 7
• (B) 49
• (C) 1
• (D) 343
`Ans:-  (A) 7 `

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

• (A) import odeint from integration
• (B) import odeint from scipy.integrate
• (C) we can import from scipy import odeint
• (D) from scipy.integrate import odein
`Ans:-  (D) from scipy.integrate import odein `

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

• (A) concat()
• (B) merge()
• (C) join()
• (D) None of them
`Ans:-  (C) join() `

Q7. How do you set the title as x^2-5x+6 in LaTeX style formatting?

• (A) title(“x*2-5x+6”)
• (B) title(“#x^2-5x+6#”)
• (C) title(“x^2-5x+6”)
• (D) title(“\$x^2-5x+6\$”)
`Ans:- (D) title(“\$x^2-5x+6\$”) `

Q8. Which of the following syntax is wrong?

• (A) loglog(x, y, basex = e, basey = e)
• (B) pie(obs, explode = explode_sample, labels = variables, colors = colors, autopct = 1.1f)
• (C) scatter(x,y,c = “b”, mark = “^”, alpha = 0.5)
• (D) bar([1,3,5,7,9],[2,4,6,8,10], label = “Sample 1”, color = ‘b’)
`Ans:-  (B) pie(obs, explode = explode_sample, labels = variables, colors = colors, autopct = 1.1f) `

Q9. The following function is used to integrate a system of ODEs.

• (A) odeint
• (B) None of the Above
• (D) odepack
`Ans:-  (A) odeint `

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

• (A) A[18]
• (B) A[3]
• (C) A[0]
• (D) A[2]
`Ans:- (D) A[2]`

Q11. What is the output of following?

`print(“abcabcab”.split(‘c’, 0))`
• (A) Error
• (B) ‘abcabcab’
• (C) None of them
• (D) [‘abcabcab’]
`Ans:-  (D) [‘abcabcab’] `

Q12. The function `lstsq` returns the least-squares solution to an equation?

• (A) True
• (B) False
`Ans:- (A) True`

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

• (A) savefigure(‘sine-curve.png’)
• (B) savefig(‘sine-curve.png’)
• (C) save(‘sine-curve.png’)
• (D) savefig(‘sine-curve’, ‘png’)
`Ans:-  (B) savefig(‘sine-curve.png’) `

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

• (A) True
• (B) False

Ans:- (A) True

Q15. Consider the following statements. Which of the following are correct ?

``1. diff(f(x),x,3), first differentiates f(x) and then computes the differentiated function at 3.2. simply_trig(f) simplifies the trigonometric part of f(x)3. f_integral() computes the integral of f(x)4. f.substitute(theta = 45) computes the value of f(theta) at theta = 45``
• (A) 1, 2 and 4
• (B) 4
• (C) 1
• (D) 1 and 4
`Ans:-  (B) 4 `

Q16. Given `odd = set([1, 3, 5, 7, 9])`
`squares = set([1, 4, 9, 16])`.

What is the value of `odd ^ squares`?

• (A) set([1, 3, 4, 5, 7, 9, 16])
• (B) set([1, 3, 4, 5, 7, 9, 16])
• (C) set([3, 5, 7])
• (D) set([3, 4, 5, 7, 16])
`Ans:-  (D) set([3, 4, 5, 7, 16]) `

Q17. 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?

• (A) HelloHello WorldWorld
• (B) HelloWorldHelloWorld
• (C) HelloHelloWorldWorld
• (D) Hello Hello World World
`Ans:-  (C) HelloHelloWorldWorld `

Q18. Which marker is used to get circles…?

• (A) “^”
• (B) “-“
• (C) “–“
• (D) “0”
`Ans:- (D) “0”`

Q19. If “a = [1, 1, 2, 3, 3, 5, 5, 8]“
What is set(a)?

• (A) set([1, 2, 3, 5, 8])
• (B) set([1, 1, 2, 3, 3, 5, 5, 8])
• (C) set([1, 2, 3, 3, 5, 5])
• (D) Error
`Ans:-  (A) set([1, 2, 3, 5, 8]) `

Q20. What does ones_like() function do?

• (A) Return an array of ones with the same shape as a given array
• (B) Return an array of ones with the same type as a given array
• (C) None of them
• (D) Return an array of ones with the same shape and type as a given array
`Ans:- (D) Return an array of ones with the same shape and type as a given array`

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

• (A) 0
• (B) -1
• (C) None of them
• (D) 1
`Ans:- (A) 0`

Q22. Which command is used to clear the plot?

• (A) clear()
• (B) clr()
• (C) closefig()
• (D) clf()
`Ans:- (D) clf()`

Q23. How large can an integer in Python be?

• (A) 2^32
• (B) 2^32 for a 32-bit system and 2^64 for a 64-bit system
• (C) None of the above
• (D) Any Size
`Ans:- (D) Any Size`

Q24. What arithmetic operators cannot be used with strings ?

• (A) +
• (B) –
• (C) All of them
• (D) *
`Ans:- (B) –`

Q25. What is the output of following?

```list = [1,2,3,4,5,6,7,8,9,10]
l = sum(list[::2])
print(l)```
• (A) 30
• (B) 55
• (C) 2
• (D) 25
`Ans:- (D) 25`

Q26. I have a list sample_data = [1,2,3,4,5,6,7,8,9,10], and I want [1,4,9,16,25,36,49,64,81,100] from it. What should be the possible solution?

• (A) sq(sample_data)
• (B) sample_data.squared
• (C) sqaure(sample_data)
• (D) square(sample_data)
`Ans:- (C) sqaure(sample_data)`

Q27. Consider 4 statements. Which of the following is false regarding sage ?

```1. It is an open source software.
2. we can evaluate a cell using Ctrl+Enter
3. To make a HTML editable cell, on the blue line click Shift and Enter.
4. sage has auto completion option of commands.```
• (A) line number 1, 2 and 3
• (B) line number 1 and 3
• (C) line number 1 and 2
• (D) line number 2,3
`Ans:- (D) line number 2,3`

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

• (A) True
• (B) False

Ans:- (B) False

Q29. Indentation is not mandatory in Python?

• (A) True
• (B) False

Ans:- (B) False

Q30. What is the output of the following?

```a = array([1,2,3,’string’])
print(a)```
• (A) Error
• (B) 1 2 3 “string”
• (C) 1 2 3 string
• (D) None of them

Ans:- (A) Error

Q31. I made a .txt file containing squares of first 10 elements. Which of the following statements are correct ?

• (A) It can be loaded by command squares  = loadtext(‘/home/fossee/squares.txt’) and printed by print squares. This prints a list of integers.
• (B) It can be loaded by command squares = loadtxt(‘/home/fossee/squares.txt’) and printed by print squares. This prints a list of floating objects.
• (C) It can be loaded by command squares = load.text(‘/home/fossee/squares.txt’) and printed by print(squares). This prints a list of floating objects.
• (D) It can be loaded by command squares = load.txt(‘/home/fossee/squares.txt’) and printed by print’squares’. This prints a list of floating objects.
`Ans:- (B) It can be loaded by command squares = loadtxt(‘/home/fossee/squares.txt’) and printed by print squares. This prints a list of floating objects.`

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

```list1 = [1, 2, 3]
list1.append([4, 5, 6])
print(len(list1))```
• (A) 5
• (B) 6
• (C) 3
• (D) 4
`Ans:- (D) 4`

Q33. %hist command is used to

• (A) To retrieve the commands which we used till now
• (B) To retrieve the variables used till now
• (C) None of them
• (D) To make histograms
`Ans:- (A) To retrieve the commands which we used till now`

Q34. What should be the syntax if we want to flip coordinates of bar plot (variables on y and values in x )?
Select one:

• (A) barh()
• (B) bar(flip = True)
• (C)bar(coord_flip = True)
• (D) bary()
`Ans:- (A) barh()`