0% found this document useful (0 votes)
2 views

Python English. - January 2023

The document contains a series of multiple-choice questions related to programming concepts, Python syntax, and flowchart symbols. It covers topics such as control structures, built-in functions, data types, and error handling. Each question provides four answer options, testing knowledge in programming and software development.

Uploaded by

ncapilani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python English. - January 2023

The document contains a series of multiple-choice questions related to programming concepts, Python syntax, and flowchart symbols. It covers topics such as control structures, built-in functions, data types, and error handling. Each question provides four answer options, testing knowledge in programming and software development.

Uploaded by

ncapilani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

January 2023

1. Which of the following is not a control structure\


(A) Loop
(B) Process
(C) Decision
(D) None of these
2. For performing the addition of two numbers, which of the following symbol in a flow chart are used?
(A) Control flow
(B) Terminal
(C) Processing
(D) Decision
3. Which of the following functions is a built-in function in Python\
(A) factorial ()
(B) print ()
(C) seed ()
(D) sqrt ()
4. NumPY stands for
(A) Numbering Phthon
(B) Number in Phthon
(C) Numerical Phthon
(D) None of above
5. Which symbol is used as a flowline to connect two blocks in a flow chart?
(A) arrow
(B) circle
(C) box
(D) parallelogram
6. Choose the correct function declaration of fun1() so that we can execute the following two function
calls successfully.
fun1(25,75,55)
fun1(10,20)
(A) def fun1(**kwargs)
(B) def fun1(args*)
(C) No, it is not possible in Python
(D) def fun1(*data)
7. Which of the following symbols is used to represent output in a flow chart?
(A) Square
(B) Circle
(C) Parallalogram
(D) Triangle
8. Which statement will return one line from a file (file object is ‘f’)?
(A) f.readlines()
(B) f.readline()
(C) f.read ()
(D) f.lines()

9. ………….. function returns the current position of file pointer.


(A) get()
(B) tell()
(C) seek()
(D) cur()

10. What is the output of the following code snippet?


print([i.lower()for i in “HELLO”])
(A) hello
(B) [‘h’,’e’,’I’,’I’,’o’]
(C) hel
(D) HELLO

11. Structured program can be broken into ………. To assign to more than one developer.
(A) Segments
(B) Modules
(C) Units
(D) All of the above

12. What will be the output of the following pseudo code\


Integer a, b
Set a = 10, b = 5
a=a mod (a-6)
b=b mod (b-2)
Print a-b
(A) 4
(B) 0
(C) 1
(D) 8

13. What does readlines() method return?


(A) Dictionary
(B) String
(C) Tuple
(D) List
14. What will be the output of the following pseudo code, where & represent ANd operation?
Integer a, b, c,
Set b = 5, a =1
c= a & b
Print c
(A) 1
(B) 3
(C) 5
(D) 7

15. What is the output of the following code \


import numpy as np
a= np.array([1,2,3,5,8])
b= np.array([0,3,4,2,1])
c=a+b
c=c*a
Print (c[2])
(A) 10
(B) 21
(C) 12
(D) 28

16. What is the output of the following code \


a= np.array([[1,2,3],[4,5,6]])
Print (a.shape)
(A) (2,3)
(B) (3,2)
(C) (1,1)
(D) None of the above

17. What is ‘f’ in the following statement \


F=open(“Data.txt”, “r”)
(A) ) File Name
(B) ) File Handle
(C) ) Mode of file
(D) ) File Handling

18. Python supports the creation of anonymous functions at runtime, using a construct called ………….?
(A) Pi
(B) anonymous
(C) lambda
(D) None of the above
19. What is the output of the following code?
M=[’b’ *x for x in range(4)]
Print(M)
(A) [‘’,‘b’,’bb’’bbb’]
(B) [‘b’,’bb’’bbb’’bbbb’]
(C) [‘b’,’bb’’bbb’]
(D) None of these

20. What is the output of the following code?


import numpy as np
a= np.array([1,2,3,])
Print (a.ndim)
(A) 1
(B) 2
(C) 3
(D) 0

21. The brain of computer system is ………..?


(A) RAM
(B) CPU
(C) ROM
(D) Control Unit

22. Which of the following is a valid arithmetic operator in Python?


(A) //
(B)?
(C) <
(D) and

23. What will be output for the following code?


import numpy as np
a= np.array([[1,2,3],[0,1,4]])
Print (a.size)
(A) 1
(B) 5
(C) 6
(D) 4
24. The sequence logic will not be used while …………… .
(A) Subtracting two numbers
(B) Comparing two data values
(C) Providing output to the user
(D) Adding two numbers
25. What will be the output of following\
Y= [2,5j,6]
Y.sort()
(A) [2,6,5j]
(B) [5j,2,6]
(C) Error
(D) [6,5j2]

26. Which function is used to write data in binary mode\


(A) write
(B) writelines
(C) dump
(D) pickle

27. To use a module in another module, you most import it using an …….. statement.
(A) import
(B) include
(C) both (A) and (B)
(D) none of the above

28. Which of the following declarations is incorrect?


(A) _x = 2
(B) x = 3
(C) _xyz_ = 5
(D) none of these

29. A ………. Statement is used when a statement is required syntactically but you do not want any code
to execute.
(A) break
(B) pass
(C) continue
(D) none of these

30. What is a variable defined outside a function referred to as ?


(A) A static variable
(B) A global variable
(C) A local variable
(D) An automatic variable

31. Kite/ diamond symbol in flow chart is used for ………… .


(A) Execution
(B) Decision
(C) Statement
(D) All of the above

32. What is the datatype of x \


import numpy as np
a= np.array([[1,2,3,4])
x= a.tolist()
(A) int
(B) array
(C) tuple
(D) list

33. f.read(5) will read………… from a file (file object ‘f’).


(A) 5 characters
(B) 5 words
(C) 5 lines
(D) None of the above

34. What will be the output of the following Python code \


<<<list1 = [1,3]
<<<list2 = list1
<<<list[0] = 4
<<<print(list2)
(A) [1,4]
(B) [1,3,4]
(C) [4,3]
(D) [1,3]

35. What will be the output of the following statement\


<<<”m”+”nl”
(A) ‘m+nl’
(B) ‘mnl’
(C) ‘m nl’
(D) ‘m’

36. Choose the correct option with respect to Python.


(A) Both tuples and lists are immutable
(B) Tuples are immutable while lists are mutable
(C) Both tuples and lists are mutable
(D) Tuples are mutable while lists are immutuble

37. What will be the output of the following code snippect\


d= {3,4,5}
for k in d:
Print(k)
(A) {3,4,5} {3,4,5} {3,4,5}
(B) 3 4 5
(C) Syntax Error
(D) None of the above

38. Flow charts and Algorithms are used for …………… .


(A) Better Programming
(B) Optimized Coding
(C) Systematic testing
(D) All of the above

39. A ………. Stores information in the form of a stream of ASCII or Unicode characters i.e. human
readable.
(A) Text file
(B) Binary file
(C) Both (A) and (B)
(D) None of these

40. What will following code segment print\


If True is True:
If False and True or False:
Print(‘A’)
elif False and False or True and True:
Print(‘B’)
else:
Print(‘C’)
else:
Print(‘D’)
(A) A
(B) B
(C) C
(D) D

41. In Python language, which of the following operators option for raising k to the power 1 ?
(A) K^1
(B) K**1
(C) K^^1
(D) K^*1

42. What will be the output of the following Python code?


Example = “hello”
Example.rfind(“e”)
(A) 1
(B) 2
(C) 4
(D) 5

43. Which of the following is not an advantage of using modules?


(A) Provides a means of reuse of program code
(B) Provides a means of dividing up tasks
(C) Provides a means of reducing the size of the program
(D) Provides a means of testing individual parts of the program

44. What is the output of following Python code?


<<<ptint(*5(2//3))
(A) 3
(B) 3.3
(C) 0
(D) error

45. What will be output for the following code?


import numpy as np
a = np.array([1,2,3,5,8])
Print (a.ndim)
(A) 0
(B) 1
(C) 2
(D) 3

46. Which of the following are valid string manipulation functions in Python?
(A) count()
(B) upper()
(C) strip()
(D) All of the above

47. What will be the output of the following Python code


From math import *
Floor(11.7)

(A) 12
(B) 11
(C) 11.0
(D) None of these
48. Which statement will move file pointer 10 bytes backward from current position?
(A) f.seek(-10,0)
(B) f.seek(10,0)
(C) f.seek(-10,1)
(D) None of the above

49. Which of the following error is returned when we try to open a file in write mode which does not
exist?
(A) File Found Error
(B) File Not Exist Error
(C) File Not Found Error
(D) None of the above

50. What will be the output of the following Algorithm for a=5, b=8, c=6\
Step 1 : Start
Step 2 : Declare variables a, b and c.
Step 3 : Read variables a, b and c.
Step 4 : If a < b
If a < c
Display a is the smallest Number.
Else
Display c is the smallest Number.
Else
If b< c
Display b is the smallest Number.
Else
Display c is the smallest Number.
Step 5 : Stop

(A) a is the smallest number


(B) b is the smallest number
(C) c is the smallest number
(D) stop

51. Which of the following error is returned by the given code?


<<< f = open(“test.txt”,”w”)
<<< f write(345)
(A) Syntax Error
(B) Type Error
(C) String Error
(D) Run Time Error
52. In which format Binary file contains information ?
(A) Quick response code
(B) Same format in which the data is held in memory
(C) ASCII format
(D) Unicode format

53. What will be the output of the following Python code \


from math import factorial
print(math.factorial(5))
(A) 120
(B) Nothing is printed
(C) Error, method factorial doesn't
(D) Error, the statement should be: print(factorial(5))

54. Which of the following words is not a keyword of Python language?


(A) val
(B) raise
(C) try
(D) with

55 Which function is use to add an element in the list1 \


(A) list1.sum(5)
(B) list1.add(5)
(C) list1.append(5)
(D) list1.addelement(5)

56. What is the output of the following?


y= ‘klmn’
for i in range(len(y)):
print(y)
(A) klmn klmn klmn klmn
(B) k
(C) k k k
(D) None of these

57 . Which of the following software is required to run the hardware\


(A) Task manager
(B) Taskbar
(C) Program manager
(D) Device Driver

58. In which of the following, data is stored permanently \


(A) Variable
(B) File
(C) Both of the above
(D) None of these

59. In which of the software development phase quality of software is documented \


(A) Tasting
(B) Delivery
(C) Idea
(D) Development

60. What is the use of the zeros () function in numpy array in Python\
(A) To make a Matrix with all element 0
(B) To make a Matrix with all diagonal element 0
(C) To make a Matrix with first row 0
(D) None of the above

61. What will be the output of the following Python code \


x= ‘abcd’
for i in x:
print(i.upper())

(A) a B C D
(B) a b c d
(C) error
(D) A B C D

62. Recursive function is……………………..


(A) A function that calls itself
(B) A function that calls other functions
(C) Both (A) and (B)
(D) None of these

63. Which mode creates a new file if the file does not exist \
(A) Right mode
(B) Read mode
(C) Append mode
(D) Both (A) and (B)

64. What will be the output of the following code snippet \


from math import *
a = 2.19
b = 3.999999
c = -3.30
print(int(a), floor(b), ceil(c)’ fabs())
(A) 2 3 -3 3.3
(B) 3 4 -3 3
(C) 2 3 – 3 3
(D) 2 3 -3 -3.3

65. What type of data is arr = [(1,1), (2,2), (3,3)]?


(A) List of tuples
(B) Tuples of lists
(C) Array of tuples
(D) Invalid type

66. In Python language, which of the following cannot be defined as variable \


(A) _val
(B) val
(C) try
(D) _ try

67. What will be output for the following code\


import numpy as np
ary = np.array([1,2,3,5,8])
ary = +1
print (ary[1])
(A) 0
(B) 1
(C) 2
(D) 3

68. What is the output of the following code \


a = set(‘abc’)
b = set(‘cdef’)
print(a&b)
(A) {‘c’}
(B) {‘a’,’b’,’c’,’d’,’e’,’f’}
(C) {c}
(D) None of these

69. Which of the following will delete key-value pair for key=”tiger” in dictionary?
dic = {“lion”:”wild”,”tiger”:”wild”,”cat”:”domestic”,”dog”.”domestic”}
(A) del dic[“tiger”]
(B) dic [“tiger”].delete()
(C) delete(dic.[“tiger”])
(D) del (dic.[“tiger”])

70. What is the value of the following Python code\


<<<print(36 / 4)
(A) 9
(B) 4
(C) 9.0
(D) 4.0

71. Debugging is the process of fixing a …………… in the software.


(A) Procedure
(B) Function
(C) Bug
(D) None of these

72. What will be the output of the following\


print(sum(1,2,3))
(A) error
(B) 6
(C) 1
(D) 3

73. What is the output of the following\


n=5
while n>0:
n-=1
if n ==2:
coutinue
print(n)
(A) 5 4 3 1 0
(B) 4 3 1 0
(C) 4 3 2
(D) None of these

74. What is the output of the following\


print(max([1,2,3,4], [4,5,6],[7[))
(A) [4,5,6]
(B) [7]
(C) [1,2,3,4]
(D) 7
75. Pictorial representation of an algorithm is called as…………..
(A) Statement
(B) Program
(C) Flow chart
(D) All of these

76. Which statement is correct to import all modules from the package?
(A) From package import all
(B) From package import *
(C) From package include all
(D) From package include *

77. What is the output of the following\


m=0
while m < 5:
print(m)
m += 1
if m == 3:
break
else:
print(0)

(A) 0 1 2 0
(B) 0 1 2
(C) 0 0 1 0 2
(D) error

78. When we open file in append mode the file pointer is at the ………. Of the file.
(A) Anywhere in between the file
(B) End
(C) Beginning
(D) Second line of the file

79. What will be the output of the following expression\


x = 14
print(x>>2)
(A) 14
(B) 1
(C) 3
(D) 2

80. The content inside the “for loop” are separated by:
(A) Colon
(B) Comma
(C) Semicolon
(D) Hyphen

81. What is the output of the following code \


def s(n1):
print(n1)
n1 =n1 +2
n2=4
s(n2)
print(n2)
(A) 6 4
(B) 4 6
(C) 4 4
(D) 6 6

82. Which one of the following is immutable data type\


(A) list
(B) set
(C) tuple
(D) dict

83. What will be the output of the following Python code\


def func(a, b=5, c=1):
print(‘a is’, a, ‘and b is’, b, ‘and c is’, c)
func(13,17)
func(a=2, c=4)
func(5,7,9)

(A) a is 13 and b is 15 and c is 10


a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9
(B) a is 13 and b is 17 and c is 10
a is 2 and b is 4 and c is 4
a is 5 and b is 9 and c is 7
(C) a is 13 and b is 17 and c is 10
a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9
(D) None of these

84. What will be the output of the following code snippet\


number = (4,7,19,2,89,45,72,22)
sorted_numbers = sorted(numbers)
odd_numbers =[x for x in sorted_numbers if x % 2 ! =0]
print(odd_numbers)
(A) [7,19,45,89]
(B) [2,4,22,72]
(C) [4,7,19,2,89,45,72,22]
(D) [2,4,7,19,22,45,72,89]

85. Which of the following is used to define a block of code in Python language?
(A) Try
(B) Brackets
(C) Indentation
(D) Catch

86. Which of the following will read entire content of file (file object ‘f’)?
(A) f.reads()
(B) f.read()
(C) f.read(all)
(D) f.read(*)

87. The connector symbol for flow chart is ………….


(A) Circle
(B) Parallelogram
(C) Diamond
(D) All of the above

88. Python is written in ……………


(A) Java
(B) C
(C) PHP
(D) All of the above

89. What will be the Output of the following Python code\


d1={“abc”:5,”def”:6,”ghi”:7}
print(d1[0])
(A) abc
(B) 5
(C) {“abc”:5}
(D) error

90 . What will be the Output of the following Python code \


Len([“hello”,2, 4, 6])
(A) Error (B) 6
(C) 4 (D) 3

91. The correct extension of the Python file is …………


(A) .py
(B) .pyth
(C) .python
(D) None of the above

92. What will be the Output of the following Python code \


def display(b, n):
while n>0:
print(b, end=””)
n=n-1
display(‘z’,3)
(A) z z z
(B) z z
(C)Infinite loop
(D) An exception is thrown

93. What will be the Output of the following Python code \


import numpy as np
a = np.array( [2, 3, 4, 5] )
print(a.dtype)
(A) int 32
(B) int
(C) float
(D) None of the above

94. Given a string x=”hello” What is the output of x. count(‘1’) \


(A) 2 (B) 1
(C) 0 (D) None of these

95. A detailed flow chart is called as …………


(A) stack
(B) macro
(C) micro
(D) Union

96. Which translator is used to convert assembly language into machine language\
(A) Compiler
(B) Interpreter
(C) Assembler
(D) None of these

97. What is the Output of the following \


x=123
for I in x:
print(i)
(A) 1 2 3
(B) 123
(C) Error
(D) None of these

98. What will be the Output of the following Python code\


tuple1=(5,1,7,6,2)

tuple1.pop(2)

print(tuple1)
(A) (5,1,6,2)
(B) (5,1,7,6)
(C) (5,1,7,6,2)
(D) Error

99. Hierarchy in a pseudo-code can be shown by:


(A) Curly Braces
(B) Round Brackets
(C) Indentation
(D) Semicolon

100. What will be the Output of the following Python code \


def power(x, y =2):
r=1
for i in range(y):
r=r*x
return r
print (power(3))
print (power(3,3))
(A) 212
32
(B) 9
27
(C) 527
98
(D) None of these

You might also like