Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
MSDA Computer Programming Bridge Course Fall 2016 Test Name:________________________ 1. Which of the following is correct about Python? A. Python is a high-level, interpreted, interactive and object-oriented scripting language. B. Python is designed to be highly readable. C. It can be used as a scripting language or can be compiled to byte-code for building large applications. D. All of the above. 2. Is Python a case sensitive language? A. Yes B. No 3. Which of the following data types is not supported in Python? A. B. C. D. 4. Which of the following data types is not supported in Python? A. B. C. D. 5. Numbers String List Slice Tuple Dictionary Generics List What is the output of print str[2:] if str = 'Hello World!'? A. B. C. D. Hello World! llo llo World! None of the above. 6. What is the output of print str * 2 if str = 'Hello World!'? A. B. C. D. 7. What is the output of print list[:3] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]? A. B. C. D. 8. A tuple is another sequence data type that is similar to the list A tuple consists of a number of values separated by commas. Unlike lists, tuples are enclosed within parentheses. All of the above. What is the output of print tuple[1:3] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )? A. B. C. D. 11. Error [123, 'john', 123, 'john'] [123, 'john'] * 2. None of the above. Which of the following is correct about tuples in Python? A. B. C. D. 10. [ 'abcd', 786 , 2.23, 'john', 70.2 ] ['john', 70.2] ‘john’ ['abcd', 786 , 2.23] What is the output of print tinylist * 2 if tinylist = [123, 'john']? A. B. C. D. 9. Hello World!Hello World! Hello World! * 2. Hello World! None of the above. ( 'abcd', 786 , 2.23, 'john', 70.2 ) abcd (789, 2.23) None of the above. Which of the following is correct about dictionaries in Python? A. B. C. D. They are immutable. Keys must be unique. The values must be unique All of the above. 12. Which of the following function convert an object to a string in Python? E. F. G. H. 13. Which of the following function convert a String to a list in Python? A. B. C. D. 14. randrange (0,10) random() choice(seq) seed([x]) What is the output of len([1, 2, 3])? A. B. C. D. 17. choice(seq) randrange ([start,] stop [,step]) random() seed([x]) Which of the following function returns a random float number between 0 and 1? A. B. C. D. 16. repr(x) eval(str) tuple(s) list(s) Which of the following function returns a random item from a list, tuple, or string? A. B. C. D. 15. int(x [,base]) long(x [,base]) float(x) str(x) 1 2 3 4 What is the output of [1, 2, 3] + [4, 5, 6]? A. B. C. D. [1, 2, 3, 4, 5, 6] [1, 2, 3], [4, 5, 6] [5,7,9] 21 18. What is the output of for x in [1, 2, 3]: print x? A. B. C. D. 19. What is the output of L[-2] if L = [1,2,3]? A. B. C. D. 20. list.index(obj) list.insert(index, obj). list.pop(obj=list[-1]) list.remove(obj) Which one of the following data types is mutable? E. F. G. H. 22. Error -2 2. 1 What is the following function removes an object from a list? A. B. C. D. 21. xxx 123 error 6 number string list tuple What is the output of the following statement? house=[['hallway', 11.25], ['kitchen', 18.0], ['living room', 20.0], ['bedroom', 10.75], ['bathroom', 9.5]] C=[i[-2] for i in house] Print(C) A. B. C. D. [‘bedroom’,10.75] [‘hallway’, ‘kitchen’,’living room’,’bedroom’, bathroom’] [11.25, 18.0, 20.0, 10.75, 9.5] [‘living room’, 20.0] 23. What is the output of set('spam')==set('pams')? A. true B. false C. error 24. Which of the following is correct about sets in Python? A. B. C. D. 25. What will be the output of the following code: a = np.array([1, 2, 3, 4, 5]) b = a[1:4] b[0] = 200 print(a[1]) A. B. C. D. 26. 200 1 2 error Given the two dimentional array m, which statement will cut of the first and the last row and the first and the last column. m = np.array([ [11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34]])? A. B. C. D. 27. Unordered. Contains unique objects Immutable All of the above. m[1:-1,1:-1] m[::,::-1] m[::-1] m[::-1,::-1] What is the output of the following? c=numpy.array([25, 35, 15]) print(c*2+c/5) A. [55, 77, 33] B. [55, 35, 15] C. Error D. [[55, 35, 15],[25, 77, 15],[25, 35, 33]] 28. Which module must be imported if we want to compute with arrays? A. B. C. D. 29. Which explanation explains best what is wrong with this program? import numpy s = sin([0, 1]) print s A. B. C. D. 30. array scitools.all math Numpy sin must be imported from math sin must take a number, not a list, as argument sin must be replaced by numpy.sin The list [0, 1] must be a numpy array, not a list With the following code import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) plt.plot(x, np.sin(x) + x) the result is A. An error B. A plot with 1000 elements C. A plot with 2000 elements as "np.sin(x)" and "x" is concatenated