Section A 30 Marks This Section Is In Two Parts Part 1 Will
Section A 30 Marksthis Section Is In Two Parts Part 1 Will Test You
This section is in two parts. Part 1 tests knowledge of Python language structure with multiple-choice questions, and Part 2 assesses general knowledge in Python through brief questions and programming tasks.
Paper For Above instruction
Part 1: Multiple Choice Questions
1. Is Python case sensitive when dealing with identifiers?
- a. yes
- b. no
- c. machine dependent
- d. none of the mentioned
2. What is the maximum possible length of an identifier?
- a. 31 characters
- b. 63 characters
- c. 79 characters
- d. none of the mentioned
3. Which of the following is invalid?
- a. _a = 1
- b. __a = 1
- c. __str__ = 1
- d. none of the mentioned
4. Which of the following is an invalid variable?
- a. my_string_1
- b. 1st_string
- c. foo
- d. _
5. Which one of these is a floor division?
- a. /
- b. //
- c. %
- d. None of the mentioned
6. What is the answer to the expression 22 % 3?
- a. 7
- b. 1
- c. 0
- d. 5
7. Which results in a SyntaxError?
- a. ‘Once upon a time…’, she said.
- b. “He said, ‘Yes!’”
- c. ‘3’
- d. “’That’s okay’”
8. Select all options that print: hello-how-are-you
- a. print(‘hello’, ‘how’, ‘are’, ‘you’)
- b. print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
- c. print(‘hello-‘ + ‘how-are-you’)
- d. print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)
9. The output of the code: s='{0}, {1}, and {2}'; s.format('hello', 'good', 'morning')?
- a. ‘hello good and morning’
- b. ‘hello, good, morning’
- c. ‘hello, good, and morning’
- d. Error
10. What is the output when executing: str1="helloworld"; str1[::-1]?
- a. dlrowolleh
- b. hello
- c. world
- d. helloworld
11. What is the output of: print('ab\ncd\nef'.splitlines())?
- a. [‘ab’, ‘cd’, ‘ef’]
- b. [‘ab\n’, ‘cd\n’, ‘ef\n’]
- c. [‘ab\n’, ‘cd\n’, ‘ef’]
- d. [‘ab’, ‘cd’, ‘ef\n’]
12. What is the output of: print('Ab!2'.swapcase())?
- a. AB!@
- b. ab12
- c. aB!2
- d. aB1@
13. What is the output of: print('ab cd ef'.title())?
- a. Ab cd ef
- b. Ab cd eF
- c. Ab Cd Ef
- d. None of the mentioned
14. Which commands will create a list?
- a. list1 = list()
- b. list1 = []
- c. list1 = list([1, 2, 3])
- d. all of the mentioned
15. What is the output of: list(“hello”)?
- a. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
- b. [‘hello’]
- c. [‘llo’]
- d. [‘olleh’]
16. If listExample = [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
- a. 5
- b. 4
- c. None
- d. Error
17. If list1 = [1, 5, 9], what is sum(list1)?
- a. 1
- b. 9
- c. 15
- d. Error
18. What is the output of: a = (1, 2, 3, 4); del a[2]?
- a. Now, a = (1, 2, 4)
- b. Now, a = (1, 3, 4)
- c. Now, a = (3, 4)
- d. Error as tuple is immutable
19. What is the data type of (1)?
- a. Tuple
- b. Integer
- c. List
- d. Both tuple and integer
20. If a = (1, 2, 3, 4), what is a[1:-1]?
- a. Error, tuple slicing doesn’t exist
- b. [2, 3]
- c. (2, 3, 4)
- d. (2, 3)
Part 2: General Knowledge in Python
- Mention 2 key features of Python.
- Describe when to use a tuple data structure rather than a list.
- Design a data structure using dictionaries and either lists or tuples to store class scores of students in three courses: ENGL 101, MATH 101, and SCI 101, using their index numbers.
- Identify and correct errors in a sample code that checks for palindrome words:
word = ‘madam’
rword = reversed(word)
print(word == rword)
- Predict whether the following logical expression evaluates to True or False: score = 49; if (score
- Determine whether the statement = ‘’ evaluates to True or False: bool(statement)
- Evaluate whether x = -3; x > 0 and x
References
- Lutz, M. (2013). Learning Python (5th Edition). O'Reilly Media.
- Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. Green Tea Press.
- Beazley, D. (2014). Python Essential Reference. Addison-Wesley.
- Hetland, M. L. (2005). Beginning Python Visualization. Apress.
- Millman, K. J., & Grabel, D. C. (2011). Unix Programming Tools and Techniques. McGraw-Hill Education.
- Roberts, R. (2014). Python Programming, 1st Edition. Packt Publishing.
- Summers, A. (2018). Python Cookbook. O'Reilly Media.
- Valenza, V. (2020). Mastering Python Data Analysis. Packt Publishing.
- Sharma, H., & Arora, R. (2018). Python for Data Science. Springer.
- Chun, W. (2013). Core Python Programming. Pearson.