[go: up one dir, main page]

0% found this document useful (0 votes)
51 views30 pages

BFC505 - Python

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 30

Python Descriptive Questions

1. What is the data type? List out the types of data types with example
2. Differentiate between C++ and Python
3. Explain in detail about Control flow structures in python
4. Explain break and continue statement with the help of for loop with an example
5. Illustrate the use of input and output statements with the necessary syntax and write
example program
6. Differentiate global and local variables
7. Explain about the import statement in modules
8. Write short note on variable scope and lifetime
9. Explain briefly constant, variables, expression, keywords and statements available in
python
10. Explain how to create a dictionary in python?
11. Write a few methods that are used in Python Lists
12. What is indexing and negative indexing in Tuple?
13. Explain what is dictionary and how it is created in Python?
14. Explain the purpose of loop structure in a programming language Describe the syntax
and semantics of any two loop structures provided by Python
15. With the necessary examples describe the use of continue and break statement
16. Write code snippets in Python to perform the accessing elements of a tuple, modifying
elements of a tuple, and deleting elements of a tuple
17. Explain input function with the help of an example
18. What is Sequence in Python? Explain its operations with suitable examples
19. What is the purpose of else clause for a loop? Explain how else works with while and for
loops, with examples
20. List Explain various types of errors with an example
21. Differentiate between Top down and Bottom up approach
22. Explain a) Documentation b) Structured programming
23. List and explain elements of python
24. List and explain different tools used in program design with example
25. Explain structure of Python program with example
26. What is an algorithm? Explain characteristics of an algorithm
27. What are the features and applications of Python?
28. Explain about the input and output statements or methods with example
29. What is Indentation? Explain with example
30. What is data type? List out the types of data types with example
31. Describe an algorithm for the following
32. i) prime number or not ii) Odd or even
33. Define Flowchart and explain symbols used in flowchart with example
34. Enumerate the list and its methods with example
35. What is dictionary? Explain the methods available in dictionary
36. Differentiate between the tuple and sets in python
37. Define Variable and mention rules for choosing names of Variable
38. Implement the python program to calculate total and average marks based on input

39. What is the difference between algorithm and flowchart


40. Differentiate between C++ and Python
41. List various types of operators in Python and write any 4 types of operators
42. Explain in detail about Control flow structures in python
43. Outline with an example the assignment and bitwise operators supported in Python

44. Explain break and continue statement with the help of for loop with an example
45. Explain the syntax of the following statements
a. for loop
b. while loop
c. if-else
d. if-elif-else
46. Explain expressions in python with order of evaluation with example
47. Illustrate the use of input and output statements with the necessary syntax and write
example programs
48. Simulate the difference between nested for and for loop Python
49. Explain about different types of control structure?
50. What are membership operators? Give examples for usage
51. Define function? Write its syntax
52. Write functions to do all arithmetic operations
53. Explain lambda function
54. Write recursive function to find factorial of a number
55. Differentiate global and local variables
56. Explain about the import statement in modules
57. Write short note on variable scope and lifetime
58. What is tuple ? What is the difference between list and tuple?
59. Explain briefly constant, variables, expression, keywords and statements available in
python
60. What is len function and explain how it is used on strings with an example
61. Explain how to create a dictionary in python?
62. Write a few methods that are used in Python Lists
63. What is indexing and negative indexing in Tuple?
64. Explain what a dictionary is and how it is created in Python?
65. Explain the purpose of loop structure in a programming language Describe the syntax
and semantics of any two loop structures provided by Python
66. With the necessary examples describe the use of continue and break statements
67. Write code snippets in Python to perform the accessing elements of a tuple, modifying
elements of a tuple, and deleting elements of a tuple
68. Give a comparison between lists, tuples, dictionaries and sets
69. Explain input function with the help of an example
70. What is Sequence in Python? Explain its operations with suitable examples
71. What is the purpose of the else clause for a loop? Explain how else works with while and
for loops, with examples
72. Explain different steps of problem solving techniques
73. Explain the tools which are used to design a program
74. Write a note on algorithms with examples
75. Write advantages and disadvantages of flowchart
76. Create a flowchart to find the largest number among 3 numbers
77. Write a flowchart to find the factorial of a number
78. Write a note on the decision table with an example Write advantages and disadvantages
79. Explain pseudo code with examples
80. Define debugging? Explain Types of error in python with examples
81. Explain debugging techniques in python
82. Write a note on documentation?
83. Explain two classes of documentation?
84. Write different categories of process documentation?
85. Explain structured programming?
86. Write advantages and disadvantages of structured programming
87. Define programming methodology?
88. Explain different types of programming methodologies?
89. Explain top down and bottom up approach?
90. Write advantages and disadvantages of top down and bottom up approach?
91. Explain the structure of python with examples
92. Define function? Explain syntax of function definition
93. Write a note on program statements in python
94. What is a return statement , explain with an example
95. What are multi line statements in python, explain with examples
96. Explain python compound statements with examples
97. Explain 4 components of python
98. Explain elements of python
99. Write a note on the python interpreter
100. What is the difference between a python compiler and interpreter
101. How python is used as a calculator explains
102. Explain python shell
103. Define Atoms Explain with examples
104. Explain identifiers with examples
105. Define keywords
106. Define variables Write the characteristics of variables in python
107. Explain different data types available in python
108. Define Literals Explain different Literals in python
109. Explain relational operators with examples
110. Define assignment operators?
111. Explain different assignment operators present in python
112. Explain ternary operators with examples
113. Define bitwise operators Explain different types with examples
114. Explain python increment/decrement operators with examples
115. Write a note on Input/Output statements in python
116. Explain three types of control statements with suitable examples
117. Write a short note conditional control structure with an example
118. Explain two types of looping control structure of python
119. Write a note on break and continue statements in python
120. Why Pass statement is used in python program, explain with example
121. What is the use of default arguments in function definitions? Explain with
examples
122. Explain basic array operations with examples
123. Explain different string methods with examples
124. What are the strings in python? How we declare strings in python
125. Explain array concatenations with examples
126. How we create python , explain with examples

Multiple Choice Questions


1. Which of the following statements create a dictionary?
a) d = {}
b) d = {“john”:40, “peter”:45}
c) d = {40:”john”, 45:”peter”}
d) All of the mentioned
2. Read the code shown below carefully and pick out the keys?
d = {"john":40, "peter":45}
a) “john”, 40, 45, and “peter”
b) “john” and “peter”
c) 40 and 45
d) d = (40:”john”, 45:”peter”)
3. What will be the output?
d = {"john":40, "peter":45}
"john" in d
a) True
b) False
c) None
d) Error
4. What will be the output?
d1 = {"john":40, "peter":45}d2 = {"john":466, "peter":45}
d1 == d2
a) True
b) False
c) None
d) Error
5. What will be the output?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
a) True
b) False
c) Error
d) None
6. What is the output?
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
7. Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use
a) d.delete(“john”:40)
b) d.delete(“john”)
c) del d[“john”].
d) del d(“john”:40)
8. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary
which command do we use?
a) d.size()
b) len(d)
c) size(d)
d) d.len()
9. What will be the output?
d = {"john":40, "peter":45}
print(list(d.keys()))
a) [“john”, “peter”].
b) [“john”:40, “peter”:45].
c) (“john”, “peter”)
d) (“john”:40, “peter”:45)
10. Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a
value using the expression d[“susan”]?
a) Since “susan” is not a value in the set, Python raises a KeyError exception
b) It is executed fine and no exception is raised, and it returns None
c) Since “susan” is not a key in the set, Python raises a KeyError exception
d) Since “susan” is not a key in the set, Python raises a syntax error
11. Which of these about a dictionary is false?
a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c) Dictionaries aren’t ordered
d)Dictionaries are mutable
12. Which of the following is not a declaration of the dictionary?
a) {1: ‘A’, 2: ‘B’}
b) dict([[1,”A”],[2,”B”]])
c) {1,”A”,2”B”}
d){ }
13.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
for i,j in a.items():
print(i,j,end=" ")
a) 1 A 2 B 3 C
b) 1 2 3
c) A B C
d)1:”A” 2:”B” 3:”C”
14.What is the output of the following piece of code?
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
a) 1
b) A
c) 4
d) Invalid syntax for get method
15.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))
a) Error, invalid syntax
b) A
c) 5
d)4
16.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
print(a.setdefault(3))
a){1: ‘A’, 2: ‘B’, 3: ‘C’}
b)C
c){1: 3, 2: 3, 3: 3}
d)No method called setdefault() exists for dictionary
17.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)
a) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}.
b) None.
c) Error.
d)[1,3,6,10].
18.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
b={4:"D",5:"E"}
a.update(b)
print(a)
a) {1: ‘A’, 2: ‘B’, 3: ‘C’}
b) Method update() doesn’t exist for dictionaries
c) {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’}
d){4: ‘D’, 5: ‘E’}
19.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
b=a.copy()
b[2]="D"
print(a)
a) Error, copy() method doesn’t exist for dictionaries
b) {1: ‘A’, 2: ‘B’, 3: ‘C’}
c) {1: ‘A’, 2: ‘D’, 3: ‘C’}
d)“None” is printed
20.What is the output of the following code?
a={1:"A",2:"B",3:"C"}
a.clear()
print(a)
a) None
b) {None:None, None:None, None:None}
c) {1:None, 2:None, 3:None}
d){ }

21. Which of the following is a Python tuple?


a) [1, 2, 3].
b) (1, 2, 3)
c) {1, 2, 3}
d) {}
22. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))
23. What will be the output?
>>>t=(1,2,4,3)
>>>t[1:3]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
24. What will be the output?
>>>t=(1,2,4,3)
>>>t[1:-1]a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
25. What will be the output?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
a) [2, 3, 9].
b) [1, 2, 4, 3, 8, 9].
c) [1, 4, 8].
d) (1, 4, 8)
26. What will be the output?
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
27. What will be the output?
>>>t = (1, 2)
>>>2 * t
a) (1, 2, 1, 2)
b) [1, 2, 1, 2].
c) (1, 1, 2, 2)
d) [1, 1, 2, 2].
28. What will be the output?
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2
a) True
b) False
c) Error
d) None
29. What will be the output?
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
30. What will be the output?
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
a) 30
b) 24
c) 33
d) 12
31. What is the data type of (1)?
a) Tuple
b)Integer
c)List
d)Both tuple and integer
32.If a=(1,2,3,4), a[1:-1] is
a) Error, tuple slicing doesn’t exist
b) [2,3].
c) (2,3,4)
d)(2,3)
33.What is the output of the following code?
>>> a=(1,2,(4,5))
>>> b=(1,2,(3,4))
>>> a<b
a) False
b) True
c) Error, < operator is not valid for tuples
d)Error, < operator is valid for tuples but not if there are sub-tuples
34.What is the output of the following piece of code when executed in Python shell?
>>> a=("Check")*3
>>> a
a) (‘Check’,’Check’,’Check’)
b) * Operator not valid for tuples
c) (‘CheckCheckCheck’)
d) Syntax error
35. What is the output of the following code?
>>> 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
36. What is the output of the following code?
>>> a=(2,3,4)
>>> sum(a,3)
a) Too many arguments for sum() method
b) The method sum() doesn’t exist for tuples
c) 12
d)9
37.Is the following piece of code valid?
>>> a=(1,2,3,4)
>>> del a
a) No because tuple is immutable
b) Yes, first element in the tuple is deleted
c) Yes, the entire tuple is deletedPage No 39
d) No, invalid syntax for del method
38.What type of data is: a=[(1,1),(2,4),(3,9)]?
a) Array of tuples
b) List of tuples
c) Tuples of lists
d)Invalid type
39.What is the output of the following piece of code?
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]
a) Invalid syntax for slicing
b) [0,2].
c) (0,1)
d) (0,2)
40.Is the following piece of code valid?
>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=zip(a,b)
a) Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
b) Yes, c will be ((1,2,3),(‘A’,’B’,’C’))
c) No because tuples are immutable
d) No because the syntax for zip function isn’t valid
41. Which of the following is the correct extension of the Python file?
a. .python b. .pl
c. .py d. .p

42. Is Python code compiled or interpreted?


a. Python code is both compiled and interpreted
b. Python code is neither compiled nor interpreted
c. Python code is only compiled
d. Python code is only interpreted
43. Which of the following is used to define a block of code in Python language?
a. Indentation b. Key c. Brackets d. All of the mentioned
44. Which keyword is used for function in Python language?
a. Function b. Def c. Fun d. Define
45. Which of the following character is used to give single-line comments in Python?
a. // b. # c. ! d. /*
46. What is the order of precedence in python?
a. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c. Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
47. Which of the following functions is a built-in function in python language?
a. val() b. print() c. None of these d. def
48. Which of the following is true for variable names in Python?
a. underscore and ampersand are the only two special characters allowed
b. unlimited length
c. all private members must have leading and trailing underscores
d. none of the mentioned
49. Which one of the following is not a keyword in Python language?
a. pass b. eval c. assert d. nonlocal
50. What arithmetic operators cannot be used with strings in Python?
a.+ b. - c.* d. All of the mentioned
51. Which of the following statements is used to create an empty set in Python?
a.() b.{} c.[] d.set()
52. Which type of Programming does Python support?
a. object-oriented programming
b. structured programming
c. functional programming
d. all of the mentioned
53. Is Python case sensitive when dealing with identifiers?
e. No
f. Yes
g. machine dependent
h. none of the mentioned
54. Which of the following is the correct extension of the Python file?
a. .python
b. .pl
c. .py
d. .p
55. Is Python code compiled or interpreted?
a. Python code is both compiled and interpreted
b. Python code is neither compiled nor interpreted
c. Python code is only compiled
d. Python code is only interpreted
56. All keywords in Python are in _________
a. Capitalized
b. lower case
c. UPPER CASE
d. None of the mentioned
57. What will be the value of the following Python expression: 4 + 3 % 5
a. 7
b. 2
c. 4
d. 1
58. Which of the following is used to define a block of code in Python language?
a. Indentation
b. Key
c. Brackets
d. All of the mentioned
59. Which keyword is used for function in Python language?
a. Function
b. Def
c. Fun
d. Define
60. Which of the following functions can help us to find the version of python that we are
currently working on?
a) sys.version(1)
b) sys.version(0)
c) sys.version()
d) sys.version
61. Python supports the creation of anonymous functions at runtime, using a construct called
__________
a. Pi
b. Anonymous
c. Lambda
d. none of the mentioned
62. What is the order of precedence in python?
a. Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b. Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c. Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d. Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
63. What does pip stand for python?
a. pip Installs Python
b. Pip Installs Packages
c. Preferred Installer Program
d. All of the mentioned
64. Which of the following is true for variable names in Python?
a. underscore and ampersand are the only two special characters allowed
b. unlimited length
c. all private members must have leading and trailing underscores
d. none of the mentioned
65. Which of the following is the truncation division operator in Python?
a. |
b. //
c. /
d. %
66. Which of the following functions is a built-in function in python?
a. factorial()
b. print()
c. seed()
d. sqrt()
67. Which of the following is the use of id() function in python?
a. Every object doesn’t have a unique id
b. Id returns the identity of the object
c. All of the mentioned
d. None of the mentioned
68. Which of the following is not a core data type in Python programming?
a. Tuples
b. Lists
c. Class
d. Dictionary
69. Which of these is the definition for packages in Python?
a. A set of main modules
b. A folder of python modules
c. A number of files containing Python definitions and statements
d. A set of programs making use of Python modules
70. Which one of the following is not a keyword in Python language?
a. Pass
b. Eval
c. Assert
d. Nonlocal
71. Which module in the python standard library parses options received from the command
line?
e. Getarg
f. Getopt
g. Main
h. Os
72. Which of the following statements is used to create an empty set in Python?
a. ( )
b. [ ]
c. { }
d. set()
73. What is the maximum possible length of an identifier in Python?
a. 9 characters
b. 31 characters
c. 63 characters
d. none of the mentioned
74. What are the two main types of functions in Python?
a. System function
b. Custom function
c. Built-in function & User defined function
d. User function
75. Which of the following is a Python tuple?
a. {1, 2, 3}
b. {}
c. [1, 2, 3]
d. (1, 2, 3)
76. What is output of print(math.pow(3, 2))?
a. 9.0
b. None
c. 9
d. None of the mentioned
77. Which of the following is the use of id() function in python?
a. Every object in Python doesn’t have a unique id
b. In Python Id function returns the identity of the object
c. None of the mentioned
d. None of the mentioned
78. The process of pickling in Python includes ____________
a. conversion of a Python object hierarchy into byte stream
b. conversion of a datatable into a list
c. conversion of a byte stream into Python object hierarchy
d. conversion of a list into a datatable)
79. What is the maximum possible length of an identifier?
a. 16
b. 32
c. 64
d. None of the above
80. What is the method inside the class in python language?
1. Object
2. Function
3. Attribute
4. Argument
81. Which of the following is not a keyword in Python language?
a) Val
b) Raise
c) Try
d) With
82. In which year was the Python 3.0 version developed?
a. 2008
b. 2000
c. 2010
d. 2005
83. Why does the name of local variables start with an underscore discouraged?
a. To identify the variable
b. It confuses the interpreter
c. It indicates a private variable of a class
d. None of these
86. Which of the following statements is correct for variable names in Python language?
a. All variable names must begin with an underscore
b. Unlimited length
c. The variable name length is a maximum of 2
d. All of the above
87. Which of the following words cannot be a variable in python language?
a. _val
b. Val
c. .try
d. _try_
88. Which of the following operators is the correct option for power(ab)?
a. a^b
b. a**b
c. a^^b
d. a^*b
89. Which one of the following has the highest precedence in the expression?
a. Division
b. Subtraction
c. Power
d. Parentheses
90. As what datatype are the *args stored, when passed into a function?
a. List
b. Tuple
c. Dictionary
d. None of the above
91. Which of the following blocks will always be executed whether an exception is encountered
or not in a program?
a. Try
b. Except
c. Finally
d. None of these
92. Which of the following are valid string manipulation functions in Python?
a. Count()
b. Upper()
c. Strip()
d. All of the above
93. Which of the following modules need to be imported to handle date time computations in
Python?
a. Date time
b. Time
c. Date
d. time date
94. What will be the result of the following expression in Python “2 ** 3 + 5 ** 2”?
a. 65535
b. 33
c. 169
d. None of these
95. Which module in the python standard library parses options received from the command
line?
a. Getarg
b. Getopt
c. Getopt
d. Getopt
96. What are the two main types of functions in Python?
a. System function
b. Custom function
c. Built –in function & User defined function
d. User function
97. Which of the following is a Python tuple?
a. {1, 2, 3}
b. {}
c. [1,2,3]
d. (1,2,3)
98. Which of the following is the use of id() function in python?
a. Every object in Python doesn’t have a unique id
b. In Python Id function returns the identity of the object
c. None of the mentioned
d. All of the mentioned
99. The process of pickling in Python includes ____________
a. conversion of a Python object hierarchy into byte stream
b. conversion of a data table into a list
c. conversion of a byte stream into Python object hierarchy
d. conversion of a list into a data table
100.As what datatype are the *kwargs stored, when passed into a function?
a. Lists
b. Tuples
c. Dictionary
d. None of the above
101.What is the maximum length of a Python identifier?
a. 32
b. 16
c. 128
d. No fixed length is specified
102.Which of the following concepts is not a part of Python?
a. Pointers
b. Loops
c. Dynamic typing
d. All of the above
103.Which of the following is the proper syntax to check if a particular element is present in a
list?
a. If ele in list
b. If not ele not in list
c. Both A& B
d. None of the above
104.Who developed Python Programming Language?
a. Wick van Rossum
b. Rasmus Lerdorf
c. Guido van Rossum
d. Niene Stom
105.All keywords in Python are in _________
a. Capitalized
b. lower case
c. UPPER CASE
d. None of the mentioned
106.Which of the following character is used to give single-line comments in Python?
a. //
b. #
c. !
d. /*
107.What arithmetic operators cannot be used with strings in Python?
a. *
b. –
c. +
d. All of the mentioned
108.To add a new element to a list we use which Python command?
a. list1.addEnd(5)
b. list1.addLast(5)
c. list1.append(5)
d. list1.add(5)
109.Which of these is not a fundamental features of OOP?
a. Encapsulation
b. Inheritance
c. Instantiation
d. Polymorphism
110.Which of the following is the most suitable definition for encapsulation?
a. Ability of a class to derive members of another class as a part of its own definition
b. Means of bundling instance variables and methods in order to restrict access to certain
class members
c. Focuses on variables and passing of variables to functions
d. Allows for implementation of elegant software that is well designed and easily modified
111.In which language is Python written?
a. English
b. PHP
c. C
d. All of the above
112.What is the method inside the class in python language?
a. Object
b. Function
c. Attribute
d. Argument
113.Which of the following declarations is incorrect?
a. _x = 2
b. __x = 3
c. __xyz__ = 5
d. None of these
114.Study the following function: round(4.576). What will be the output of this function?
a. 4
b. 5
c. 576
d. 5
115.Which of the following option is not a core data type in the python language?
a. Dictionary
b. Lists
c. Class
d. All of the above
116.Which is the correct operator for power(xy)?
a. X^y
b. X**y
c. X^^y
d. None of the mentioned
117.What is the answer to this expression, 22 % 3 is?
a. 7
b. 1
c. 0
d. 5
118.Which of the following functions is a built-in function in python?
a. seed()
b. sqrt()
c. factorial()
d. print()
119._____ is used to create an object.
a. Class
b. Constructor
c. User-definedfunctions
d. In-built functions
120.Which of the following best describes inheritance?
a. ability of a class to derive members of another class as a part of its own definition
b. Means of bundling instance variables and methods in order to restrict access to certain
class members
c. Focuses on variables and passing of variables to functions
d. Allows for implementation of elegant software that is well designed and easily modified
121.What type is the object below? L = [1, 23, ‘hello’, 1]
a. List
b. Dictionary
c. Tuple
d. Array
122.Which of the following statements is used to create an empty set in Python?
a. ()
b. []
c. {}
d. set()
123.What is the maximum possible length of an identifier?
a. 31 characters
b. 63 characters
c. 79 characters
d. None of the mentioned
124.What does the following code do? Def fun(a,b,c): pass
a. Defines a list and initialize it.
b. Defines a function, which does nothing
c. Defines a function, which passes its parameters through.
d. Defines an empty class
125.What is the output of the following code? Print type([1,2])
a. <type ‘tuple’>
b. <type ‘int’>
c. <type ‘set’>
d. <type ‘list’>
126.All keywords in Python are written in_____
a. Upper case
b. Lower case
c. Capitalized
d. None of the mentioned
127.Which of the following data types is not supported in python?
a. String
b. Numbers
c. Slice
d. List
128.Which of the following keywords mark the beginning of the class definition?
a. Return
b. Class
c. Def
d. All of the above
129.The format function , when applied on a string returns.
a. List
b. Bool
c. Int
d. Str
130.Which one of the following is not a python’s predefined data types?
a. List
b. Dictionary
c. Tuples
d. Class

131.What is the difference between a flowchart and pseudocode?


a. A flowchart is diagrammatic whilst pseudocode is written in a programming language
(e.g. Pascal or Java).
b. A flowchart is textual, but pseudocode is diagrammatic.
c. A flowchart is a diagrammatic description of an algorithm, whilst pseudocode is a textual
description of an algorithm.
d. A flowchart and pseudocode are the same thing.
132. In a flowchart, an input or output instruction is represented by
a. rectangle
b. rhombus
c. parallelogram
d. A circle
133. A flowchart needs to represent a situation where for each mark a student is awarded 'Pass'
or 'Fail'...the system will consider the mark, and if it's 50 or over, award 'Pass,' else it awards
'Fail.' This is an example of which of the algorithm constructs?
a. Decision
b. Loop
c. Sequence
d. All of the above
134. Which of the following is not an advantage of a flowchart?
a) Better communication
b) Efficient coding
c) Systematic testing
d) Improper documentation
135. How many keyword arguments can be passed to a function in a single function call?
A. Zero
B. One
C. Zero or more
D. None of the above
136. What arithmetic operators cannot be used with strings?
A. +
B. *
C. -
D. None of the above
137. Any function which calls itself again and again is a_____
A. Recursion
B. Function Composition
C. Function definition
D. Function Call
138. What will be the output of the following Python code?
for i in range(1,10,2):
print(i)
A. 13579
B. 1357911
C. 123456789
D. 123456
139. The action performed by a ______________ structure must eventually cause the loop to
terminate.
a) sequence
b) case
c) repetition
d) process
140. Which of the following is not a keyword?
a) Read
b) Write
c) start
d) endif
141. _____________ is used to show hierarchy in a pseudo code.
a) Indentation
b) Curly Braces
c) Round Brackets
d) Semicolon
142. ______________ begins with lower case letters.
a) Keywords
b) Variables
c) Tokens
d) Functions
143. A statement used to close the IF block.
a) ELSE
b) ELSEIF
c) END
d) ENDIF
144. Which of the following is an invalid statement?
a) abc = 1,000,000
b) a b c = 1000 2000 3000
c) a,b,c = 1000, 2000, 3000
d) a_b_c = 1,000,000
145. What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Multiplication
iv) Division
v) Addition
vi) Subtraction
a) i,ii,iii,iv,v,vi
b) ii,i,iii,iv,v,vi
c) ii,i,iv,iii,v,vi
d) i,ii,iii,iv,vi,v
146. What is the average value of the following Python code snippet?
1. >>>grade1 = 80
2. >>>grade2 = 90
3. >>>average = (grade1 + grade2) / 2

a) 85.0
b) 85.1
c) 95.0
d) 95.1
147. What will be the output of the following Python code snippet if x=1?
x<<2
a) 8
b) 1
c) 2
d) 4
148. What will be the output of the following Python expression if x=15 and y=12?
x&y
a) b1101
b) 0b1101
c) 12
d) 1101
149. The one’s complement of 110010101 is:
a) 001101010
b) 110010101
c) 001101011
d) 110010100
150. What will be the output of the following Python code?
x = "abcdef" while i in x:
print(i, end=" ")

a) a b c d e f
b) abcdef
c) i i i i i i …
d) error
151.Which of the following commands will create a list?
a) list1 = list()
b) list1 = []
c) list1 = list([1, 2, 3])
d) all of the mentioned
152. Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
a) 5
b)4
c)None
d)Error
153. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?
a) 3
b) 5
c) 25
d) 1
154. To add a new element to a list we use which command?
a) list1.add(5)
b) list1.append(5)
c) list1.addLast(5)
d) list1.addEnd(5)
155. Which of the following is a Python tuple?
a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) {}
156. Why is a flowchart required?
a). To plan a program before making it.
b). To execute a program.
c). It is easy to use.
d). To analyze the program.
157. Terminal symbol in a flowchart indicates
a) End
b) Input and Output
c) processing
d) Decision
158. Structured Programming is
a) Dividing the program into different program modules
b) Using Structures in the program
c) Using classes in the program
d) None of the above
159. Pseudocode is used for
a) Denoting the program Flow
b) For coding the program
c) To make structure chart
d) To write program steps
160. Indentation in a program
a) Improves its readability and understanding
b) Is Compulsory
c) Both
d) None of the above
161. Method which uses a list of well defined instructions to complete a task starting from a
given initial state from a given initial state to end state is calls as
a) Program
b) Flowchart
c) Algorithm
d) A & B
162. Which of the following is a program planning tool?
a) Sequential
b) Decision
c) Pseudocode
d) Both b and c
163. Which of the following symbol in a flowchart are used to indicate all arithmetic processes
of adding, subtracting, multiplying and dividing ?
a) Input/output
b) terminal
c) Processing
d) Decision
164. Which of the following is a pictorial representation of an algorithm?
a) Pseudo code
b) Program
c) Flowchart
d) Algorithm
165. Pseudo code emphasizes on
a) Development
b) Coding
c) Design
d) Debugging
166. Which of the following program planning tool allows the programmers to plan program
logic by writing program instruction in an ordinary language?
a) Flowchart
b) Pseudo code
c) Program
d) Looping
167. A decision table is
a. a truth table
b. a table which facilitates taking decisions
c. a table listing conditions and actions to be taken based on the testing of conditions
d. a table in a Decision Support System
168. A decision tree does not include:
a) statements
b) condition stubs
c) action stubs
d) rules
169. The part of a decision table that links conditions to actions is the section that contains the:
a) action statements
b) rules
c) condition statements
d) decision stubs
170. Python function always returns a value
a) False
b) True
171. Which of the following is the use of function in python?
a) Functions are reusable pieces of programs
b) Functions don’t provide better modularity for your application
c) you can’t also create your own functions
d) All of the mentioned
172. If return statement is not used inside the function, the function will return:
A. None
B. 0
C. Null
D. Arbitary value
173. What is a recursive function?
A. A function that calls other function.
B. A function which calls itself.
C. Both A and B
D. None of the above
174. Which operator is used in Python to import modules from packages?
A. .
B. *
C. ->
D. &
175. Lambda is a function in python?
A. True
B. False
C. Lambda is a function in python but user can not use it.
D. None of the above
176. Which one of the following is the correct way of calling a function?
A. function_name()
B. call function_name()
C. ret function_name()
D. function function_name()
177. Which one of the following is incorrect?
A. The variables used inside function are called local variables.
B. The local variables of a particular function can be used inside other functions, but these
cannot be used in global space
C. The variables used outside function are called global variables
D. In order to change the value of the global variable inside the function, keyword global is
used.
178. Which of the following would NOT work as a variable name?
A. a
B. len
C. length
D. x
179. Which is the correct operator for power(xy)?
a) X^y
b) X**y
c) X^^y
d) None of the mentioned
180. What is the output of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1

You might also like