Almost all MCQs of Computer

2023


Algorithm and Flowcharts MCQs Set-1

Algorithm and Flowcharts MCQs Set-1 Contain the randomly compiled multiple choice Questions and answers from various reference books and Questions papers for those who is preparing for the various competitive exams and interviews.
 

1. Macro flowchart is also called as
  • Simple detailed flowchart
  • Less Detail flowchart
  • More detail flowchart
  • None
B. Less Detail flowchart
2. GUI stands for
  • Graphical User Interface
  • Graphical input Unit
  • Graph Under Instruction
  • None
A. Graphical User Interface
3. Terminal symbol in a flowchart indicates
  • End
  • processing
  • Input and Output
  • Decision
A. End
4. Continue Statement
  • Without Executing remaining statements takes control back to starting loop
  • Take control outside the loop
  • Continues to program end
  • None
A. Without Executing remaining statements takes control back to starting loop
5. Structured Programming is
  • Dividing the program into different program modules
  • Using Structures in the program
  • Using classes in the program
A. Dividing the program into different program modules
6. Pseodocode is used for
  • Denoting the program Flow
  • Program code
  • For coding the program
  • To write program steps
D. To write program steps
7. Macro flowchart shows the
  • Outline of the program
  • To make structure chart
  • Program Detail
  • None
A. Outline of the program
8. Indentation in a program
  • Improves its readability and understanding
  • Is compulsory
  • Both
  • None
A. Improves its readability and understanding
9. Which of the following is used to avoid infinite loops?
  • Sequentiol
  • For
  • While
  • Do while
A. Sequentiol
10. Which of the following is not necessarily a characteristic of a program module?
  • It performs a single task
  • It is self-contained
  • It contains Several sub modules
  • It is relatively small in size
D. It is relatively small in size



Algorithm and Flowcharts MCQs Set-2

 

1. Which of the following is not a benefit of modular programming?
  • It increases program readability
  • It increases programmer productivity
  • It allows for the creation of a library of common programming task
  • It allows one programmer to do the job of many in the same amount of time
D. It allows one programmer to do the job of many in the same amount of time
2. The main module of a program contains the following sequences of statements Call Module A —————— Call Module B —————— Call Module C —————— Which of the following statements is executed after Call Module B?
  • Call Module A
  • Call Module C
  • The first Statement in Module B
  • None
C. The first Statement in Module B
3. Which of the following statements is executed after all statements in ModuleB have been carried out in above Q ?
  • Call Module A
  • Call Module C
  • The first Statement in Module C
  • None
B. Call Module C
4. Which of the following is not a principle of structured programming?
  • Design the program in top-down manner
  • Write each program module as a series of control structures
  • Code the program so that it runs correctly without testing
  • Use good programming
A. Design the program in top-down manner
5. Which of the following is not a basic control structure
  • The process
  • The decision
  • The Loop  
  • The sequential
A. The process
6. Which of the following is not a principle of good programming style?
  • Use descriptive variable names
  • Provide a welcome message
  • Identify using text the numbers that are output
  • Test the program
B. Provide a welcome message


Algorithm and Flowcharts MCQs Set-3  

1. 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
  • Program
  • Flowchart
  • Algorithm
  • A & B
C. Algorithm
2. The chart that contains only function flow and no code is called as
  • flowchart
  • Structure chart
  • Both A and B
  • None
B. Structure chart
3. Which of the following is a program planning tool?
  • Sequential
  • decision
  • Pseudo code
  • Both B and C
D. Both B and C
4. Which of the following structures are used in computer programs?
  • sequential
  • decision
  • Timesharing
  • None
D. None
5. Execution of two or more programs by a single CPU is known as
  • Multiprogramming
  • Multiprocessing
  • Timesharing
B. Multiprocessing
6. A structured chart is
  • A statement of information processing requirements
  • A document of what has to be accomplished
  • A hierarchical Partitioning of the program
  • Beginners all purpose
  • All
C. A hierarchical Partitioning of the program
7. In structure charts modules are described as
  • Circle
  • Triangles
  • Rectangle
  • Ellipse
B. Triangles
8. The sequence logic will not be used while
  • Accepting input from user
  • Giving output to the user
  • Comparing two sets of data
  • Adding two numbers
B. Giving output to the user
9. Flowcharts and Algorithms are used for
  • Better Programming
  • Easy testing and Debugging
  • Efficient Coding
  • All
D. All
10. An Algorithm represented in the form of programming languages is _________
  • Flowchart
  • Pseudo code
  • Program
  • None
C. Program


Algorithm and Flowcharts MCQs Set-4 

1. Which of the following is a pictorial representation of an algorithm?
  • Pseudo code
  • Program
  • Flowchart
  • Algorithm
C. Flowchart
2. Which of the following symbol in a flowchart are used to indicate all arithmetic processes of adding, subtracting, multiplying and dividing ?
  • Input/output
  • terminal
  • Processing
  • Decision
C. Processing
3. A flowchart that outlines the main segments of program is called as
  • Micro flowchart
  • Macro flowchart
  • Flowchart
  • Algorithm
B. Macro flowchart
4. A flowchart that outlines with all detail is called as
  • Micro flowchart
  • Macro flowchart
  • Flowchart
  • Algorithm
A. Micro flowchart
5. Pseudo code is also known as
  • Program Design Language
  • Hardware Language
  • Software Language
  • Algorithm
A. Program Design Language
6. Pseudo code emphasizes on
  • Development
  • Coding
  • Design
  • Debugging
C. Design
7. In which of the following pseudo code instructions are written in the order or sequence in which they are to be performed?
  • Selection Logic
  • Sequence Logic
  • Iteration Logic
  • Looping Logic
B. Sequence Logic
8. Which of the following logic is used to produce loops in program logic when one or more instruction may be executed several times depending on some conditions?
  • Iteration Logic
  • Selection Logic
  • Sequence Logic
  • Decision Logic
A. Iteration Logic
9. Selection logic also called as
  • Decision Logic
  • Iteration Logic
  • Sequence Logic
  • Looping Logic
A. Decision Logic
10. Which of the following program planning tool allows the programmers to plan program logic by writing program instruction in an ordinary language?
  • Flowchart
  • Pseudo code
  • Program
  • Looping
B. Pseudo code

 

Algorithm and Flowcharts MCQs Set-5

 

1. Algorithm is
  • step by step execution of program
  • Object file
  • Executable file
  • Source file
D. Source file
2. Kite box in flow chart is used for
  • Connecter
  • Decision
  • Statement
  • All of the above
B. Decision
3. Which of the following is not a characteristic of good algorithm?
  • Precise
  • Ambiguous
  • Finite number of steps
  • Logical flow of control
C. Finite number of steps
4. Diagrammatic representation of an algorithm is
  • Flowchart
  • Data flow Diagram
  • Algorithm design
  • Pseudo code
A. Flowchart
5. Goto statement is ?
  • Used to jump the control of program
  • Used for user defined iteration
  • Same as switch case statement
  • None of above
A. Used to jump the control of program


Algorithm and Flowcharts MCQs Set-6

 

1. After a programmer plans the logic of a program ,she /he will next____
  • Understand the problem
  • Translate the program
  • Test the program
  • Code the program
D. Code the program
2. What symbol is used to represent output in a flowchart?
  • Square
  • Circle
  • Parallelogram
  • Triangle
C. Parallelogram
3. What is the standard terminal symbol for flowchart?
  • Circle
  • Parallelogram
  • Diamond
  • Square
A. Circle
4. The following pseudo code is an example of _______ structure: Get number While number is positive Add to sum
  • Sequence
  • Decision
  • Loop
  • Nested
C. Loop
5. The following pseudo code is an example of ______structure:Get number Get another number If first number is greater than second then Print first number Else print second number
  • Sequence
  • Decision
  • Loop
  • Nested
B. Decision
6. The following pseudo code is an example of ________structure: Get number Get another number Multiply numbers Print result
  • Sequence
  • Decision
  • Loop
  • Nested
A. Sequence
7. structured program can be easily broken down into routines or _______that can be assigned to any number of programmers
  • Segments
  • Modules
  • Units
  • Sequences
B. Modules
8. In a case structure of the loop, the loop body continues to execute as long as the answer to the controlling question is yes, or true.
  • Else
  • Then
  • Default
  • Loop
A. Else
9. In which of the following loop ,the loop body continues to executes as long as the answer to the controlling question is yes, or true.
  • do-then
  • do-when
  • do-until
  • do-while
D. do-while
10. Which of the following statement cause program control to end up almost anywhere in the program?
  • go to
  • for
  • while
  • do while
A. go to

 
 

Algorithm and Flowcharts MCQs Set-8

1. Which of the following can be replaced by if
  • switch
  • while
  • continue
  • for
A. switch
2. Which of the following statement is useful while writing menu driven programs
  • while
  • break
  • switch
  • if
A. while
3. Which of the following is self contained block of statements that perform a coherent task of some kind?
  • function
  • loop
  • statement
  • body of program
A. function
4. The function gets called when the function name is followed by
  • colon
  • semicolon
  • statement
  • braket
B. semicolon
5. The mechanism used to convey information to the function is the
  • Argument
  • commands
  • loops
  • statements
A. Argument



Web Fundamental Solved MCQs

Hello Friends,this section is specifically dedicated to those users who wants to clear the fundamental of computer science. Here we have included Web/Computer Fundamental Multiple Choice Questions and answers (MCQ) ,You can expect some questions from this section for sure in the respective competitive exams.so practice it well and enjoy with good score you expect.
 

1. The acronym w3c stands for _________
  • world web wide.
  • wide world web
  • world wide web
  • world wide web control
C. world wide web
2. HTML is a ______ language
  • procedural
  • markup
  • object oriented
  • object based
B. markup
3. HTML documents stored in the file in the form ______
  • .hxm
  • .html or .htm
  • .hm
  • .hml
B. .html or .htm
4. To change www.google.com to an IP address, we should use the _______ protocol
  • TELNET
  • DNS
  • NVT
  • none of the above
B. DNS
5. web-internet-fundamental-mcq-1
  • 1-d, 2-b, 3-a, 4-c
  • 1-d, 2-c, 3-b, 4-a
  • 1-d, 2-a, 3-b, 4-c
  • 1-b, 2-a, 3-d, 4-c
D. 1-b, 2-a, 3-d, 4-c
6. Which of the following is not a C2C business model?
  • Manufacturer’s website for selling home appliances online
  • Website for auctioning used goods
  • Website for posting content related to selling and/or buying houses
  • Website allowing anyone to publish advertisements related to selling and/or buying cars
A. Manufacturer’s website for selling home appliances online
7. Electronic wallets refer to
  • Website selling electronic appliances online
  • Mechanism for secure e-payments
  • Wallets housing smart/credit/debit cards
  • Wallets fitted with electronically operated locks
B. Mechanism for secure e-payments
8. web-internet-fundamental-mcq-2
  • 1-b, 2-d, 3-a, 4-c
  • 1-d, 2-c, 3-b, 4-a
  • 1-d, 2-a, 3-b, 4-c
  • 1-b, 2-a, 3-d, 4-c
A. 1-b, 2-d, 3-a, 4-c
9. Digital Library of India is a library with
  • printed books about e-Commerce, e-governance and ICT
  • computerized issue/renewal/return of books
  • library with collection of books in PDF format
  • computers with Internet facility for catalogue and web browsing
C. library with collection of books in PDF format
10. COBIT was an acronym for
  • Cost of Business in Information Technology
  • Control Objectives for Information and Related Technology
  • Computerization of Business Intelligence Techniques
  • Computerization of Information Related Technology
B. Control Objectives for Information and Related Technology


1. Which of the Following is correct special charecter Code
  • & code
  • & amp
  • & copy.
  • # code
B. & amp
2. By default, ordered list use _____ sequence of numbers
  • octal
  • hexadecimal
  • binary
  • decimal
D. decimal
3. The _____ element is used to insert a horizontal rule.
  • hr
  • rule
  • rh
  • line
A. hr
4. In ERP, data migration refers to
  • Upgrading ERP software
  • Upgrading both hardware and ERP software
  • backup of data on an ERP system
  • moving, copying and restructuring data from an existing system to the ERP system
D. moving, copying and restructuring data from an existing system to the ERP system
5. Which of the following depicts correct chronological order for scope of COBIT framework
  • Management, Audit, Control, IT Governance, Governance of Enterprise IT
  • Control, Audit, Management, IT Governance, Governance of Enterprise IT
  • Audit, Control, Management, IT Governance, Governance of Enterprise IT
  • Governance of Enterprise IT, Audit, Control, Management, IT Governance
C. Audit, Control, Management, IT Governance, Governance of Enterprise IT
6. HTTP is
  • Request-Response Protocol
  • Stateful
  • Secured
  • All of above
A. Request-Response Protocol
7. The default size of block in Apache HDFS is
  • 512 bytes
  • 64 MB
  • 1024 KB
  • None of the above
B. 64 MB
8. Payment Gateway refers to
  • a merchant service authorizing payments for e-businesses
  • a merchant service to resolve financial disputes
  • networking switch at a bank/financial institution
  • none of the above
A. a merchant service authorizing payments for e-businesses
9. “Collaborative application development” means
  • software development by a team of developers
  • software targeting many applications
  • opening the source code of application/components for other developers
  • outsourcing application code development
C. opening the source code of application/components for other developers
10. Electronic data interchange means
  • a software for copying data from one computer to another
  • a software for synchronizing data across many devices
  • import/export of electronic devices used for data storage
  • sets of formats/standards used for electronic exchange of business information
D. sets of formats/standards used for electronic exchange of business information

 


Important Python Solved MCQ

1. Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
View Answer

Answer: c
Explanation: Python language is designed by a Dutch programmer Guido van Rossum in the Netherlands.

2. Which type of Programming does Python support?
a) object-oriented programming
b) structured programming
c) functional programming
d) all of the mentioned
View Answer

Answer: d
Explanation: Python is an interpreted programming language, which supports object-oriented, structured, and functional programming.

3. Is Python case sensitive when dealing with identifiers?
a) no
b) yes
c) machine dependent
d) none of the mentioned
View Answer

Answer: b
Explanation: Case is always significant while dealing with identifiers in python.

4. Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
View Answer

Answer: c
Explanation: ‘.py’ is the correct extension of the Python file. Python programs can be written in any text editor. To save these programs we need to save in files with file extension ‘.py’.

5. 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
View Answer

Answer: a
Explanation: Many languages have been implemented using both compilers and interpreters, including C, Pascal, and Python.

6. All keywords in Python are in _________
a) Capitalized
b) lower case
c) UPPER CASE
d) None of the mentioned
View Answer

Answer: d
Explanation: True, False and None are capitalized while the others are in lower case.

7. What will be the value of the following Python expression?

4 + 3 % 5

a) 7
b) 2
c) 4
d) 1
View Answer

Answer: a
Explanation: The order of precedence is: %, +. Hence the expression above, on simplification results in 4 + 3 = 7. Hence the result is 7.

8. 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
View Answer

Answer: a
Explanation: In Python, to define a block of code we use indentation. Indentation refers to whitespaces at the beginning of the line.

9. Which keyword is used for function in Python language?
a) Function
b) def
c) Fun
d) Define
View Answer

Answer: b
Explanation: The def keyword is used to create, (or define) a function in python.

10. Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
View Answer

Answer: b
Explanation: To write single-line comments in Python use the Hash character (#) at the beginning of the line. It is also called number sign or pound sign. To write multi-line comments, close the text between triple quotes.
Example: “”” comment
text “””

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

i = 1
while True:
    if i%3 == 0:
        break
    print(i)
 
    i + = 1

a) 1 2 3
b) error
c) 1 2
d) none of the mentioned
View Answer

Answer: b
Explanation: SyntaxError, there shouldn’t be a space between + and = in +=.

12. 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
View Answer

Answer: d
Explanation: The function sys.version can help us to find the version of python that we are currently working on. It also contains information on the build number and compiler used. For example, 3.5.2, 2.7.3 etc. this function also returns the current date, time, bits etc along with the version.

13. Python supports the creation of anonymous functions at runtime, using a construct called __________
a) pi
b) anonymous
c) lambda
d) none of the mentioned
View Answer

Answer: c
Explanation: Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called lambda. Lambda functions are restricted to a single expression. They can be used wherever normal functions can be used.

14. 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
View Answer

Answer: d
Explanation: For order of precedence, just remember this PEMDAS (similar to BODMAS).

15. What will be the output of the following Python code snippet if x=1?

x<<2

a) 4
b) 2
c) 1
d) 8
View Answer

Answer: a
Explanation: The binary form of 1 is 0001. The expression x<<2 implies we are performing bitwise left shift on x. This shift yields the value: 0100, which is the binary form of the number 4.

16. What does pip stand for python?
a) Pip Installs Python
b) Pip Installs Packages
c) Preferred Installer Program
d) All of the mentioned
View Answer

Answer: c
Explanation: pip is a package manager for python. Which is also called Preferred Installer Program.

17. 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
View Answer

Answer: b
Explanation: Variable names can be of any length.

18. What are the values of the following Python expressions?

 2**(3**2)
 (2**3)**2
 2**3**2

a) 512, 64, 512
b) 512, 512, 512
c) 64, 512, 64
d) 64, 64, 64
View Answer

Answer: a
Explanation: Expression 1 is evaluated as: 2**9, which is equal to 512. Expression 2 is evaluated as 8**2, which is equal to 64. The last expression is evaluated as 2**(3**2). This is because the associativity of ** operator is from right to left. Hence the result of the third expression is 512.

19. Which of the following is the truncation division operator in Python?
a) |
b) //
c) /
d) %
View Answer

Answer: b
Explanation: // is the operator for truncation division. It is called so because it returns only the integer part of the quotient, truncating the decimal part. For example: 20//3 = 6.

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

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

a) [1, 0, 2, ‘hello’, ”, []]
b) Error
c) [1, 2, ‘hello’]
d) [1, 0, 2, 0, ‘hello’, ”, []]
View Answer

Answer: c
Explanation: The code shown above returns a new list containing only those elements of the list l which do not amount to zero. Hence the output is: [1, 2, ‘hello’].

21. Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
View Answer

Answer: b
Explanation: The function seed is a function which is present in the random module. The functions sqrt and factorial are a part of the math module. The print function is a built-in function which prints a value directly to the system output.

22. 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
View Answer

Answer: b
Explanation: Each object in Python has a unique id. The id() function returns the object’s id.

23. The following python program can work with ____ parameters.

def f(x):
    def f1(*args, **kwargs):
           print("Sanfoundry")
           return x(*args, **kwargs)
    return f1

a) any number of
b) 0
c) 1
d) 2
View Answer

Answer: a
Explanation: The code shown above shows a general decorator which can work with any number of arguments.

24. What will be the output of the following Python function?

min(max(False,-3,-4), 2,7)

a) -4
b) -3
c) 2
d) False
View Answer

Answer: d
Explanation: The function max() is being used to find the maximum value from among -3, -4 and false. Since false amounts to the value zero, hence we are left with min(0, 2, 7) Hence the output is 0 (false).

25. Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
View Answer

Answer: c
Explanation: Class is a user-defined data type.

26. What will be the output of the following Python expression if x=56.236?

print("%.2f"%x)

a) 56.236
b) 56.23
c) 56.0000
d) 56.24
View Answer

Answer: d
Explanation: The expression shown above rounds off the given number to the number of decimal places specified. Since the expression given specifies rounding off to two decimal places, the output of this expression will be 56.24. Had the value been x=56.234 (last digit being any number less than 5), the output would have been 56.23.

27. 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
View Answer

Answer: b
Explanation: A folder of python programs is called as a package of modules.

28. What will be the output of the following Python function?

len(["hello",2, 4, 6])

a) Error
b) 6
c) 4
d) 3
View Answer

Answer: c
Explanation: The function len() returns the length of the number of elements in the iterable. Therefore the output of the function shown above is 4.

29. 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
View Answer
Answer: d
Explanation: The instance of the string returned by upper() is being printed.

30. What is the order of namespaces in which Python looks for an identifier?
a) Python first searches the built-in namespace, then the global namespace and finally the local namespace
b) Python first searches the built-in namespace, then the local namespace and finally the global namespace
c) Python first searches the local namespace, then the global namespace and finally the built-in namespace
d) Python first searches the global namespace, then the local namespace and finally the built-in namespace
View Answer

Answer: c
Explanation: Python first searches for the local, then the global and finally the built-in namespace.

31. What will be the output of the following Python code snippet?

for i in [1, 2, 3, 4][::-1]:
    print (i)

a) 4 3 2 1
b) error
c) 1 2 3 4
d) none of the mentioned
View Answer

Answer: a
Explanation: [::-1] reverses the list.

32. What will be the output of the following Python statement?

  1. >>>"a"+"bc"

a) bc
b) abc
c) a
d) bca
View Answer

Answer: b
Explanation: + operator is concatenation operator.

33. Which function is called when the following Python program is executed?

f = foo()
format(f)

a) str()
b) format()
c) __str__()
d) __format__()
View Answer

Answer: c
Explanation: Both str(f) and format(f) call f.__str__().

34. Which one of the following is not a keyword in Python language?
a) pass
b) eval
c) assert
d) nonlocal
View Answer

Answer: b
Explanation: eval can be used as a variable.

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

  1. class tester:
  2.     def __init__(self, id):
  3.         self.id = str(id)
  4.         id="224"
  5.  
  6. >>>temp = tester(12)
  7. >>>print(temp.id)

a) 12
b) 224
c) None
d) Error
View Answer

Answer: a
Explanation: Id in this case will be the attribute of the instance.

36. What will be the output of the following Python program?

def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

a) Error
b) None
c) False
d) True
View Answer

Answer: d
Explanation: The same object is modified in the function.

37. Which module in the python standard library parses options received from the command line?
a) getarg
b) getopt
c) main
d) os
View Answer

Answer: b
Explanation: getopt parses options received from the command line.

38. What will be the output of the following Python program?

z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
z

a) {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}
b) {‘abc’, ‘p’, ‘q’, ‘san’}
c) {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
d) {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
View Answer

Answer: c
Explanation: The code shown first adds the element ‘san’ to the set z. The set z is then updated and two more elements, namely, ‘p’ and ‘q’ are added to it. Hence the output is: {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}

39. What arithmetic operators cannot be used with strings in Python?
a) *
b) –
c) +
d) All of the mentioned
View Answer

Answer: b
Explanation: + is used to concatenate and * is used to multiply strings.

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

print("abc. DEF".capitalize())

a) Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF
View Answer

Answer: a
Explanation: The first letter of the string is converted to uppercase and the others are converted to lowercase.

41. Which of the following statements is used to create an empty set in Python?
a) ( )
b) [ ]
c) { }
d) set()
View Answer

Answer: d
Explanation: { } creates a dictionary not a set. Only set() creates an empty set.

42. What will be the value of ‘result’ in following Python program?

list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

a) [1, 3, 5, 7, 8]
b) [1, 7, 8]
c) [1, 2, 4, 7, 8]
d) error
View Answer

Answer: a
Explanation: Here, ‘result’ is a list which is extending three times. When first time ‘extend’ function is called for ‘result’, the inner code generates a generator object, which is further used in ‘extend’ function. This generator object contains the values which are in ‘list1’ only (not in ‘list2’ and ‘list3’).
Same is happening in second and third call of ‘extend’ function in these generator object contains values only in ‘list2’ and ‘list3’ respectively.
So, ‘result’ variable will contain elements which are only in one list (not more than 1 list).

43. 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)
View Answer

Answer: c
Explanation: We use the function append to add an element to the list.

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

print('*', "abcde".center(6), '*', sep='')

a) * abcde *
b) *abcde *
c) * abcde*
d) * abcde *
View Answer

Answer: b
Explanation: Padding is done towards the right-hand-side first when the final string is of even length.

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

  1. >>>list1 = [1, 3]
  2. >>>list2 = list1
  3. >>>list1[0] = 4
  4. >>>print(list2)

a) [1, 4]
b) [1, 3, 4]
c) [4, 3]
d) [1, 3]
View Answer

Answer: c
Explanation: Lists should be copied by executing [:] operation.

46. Which one of the following is the use of function in python?
a) Functions don’t provide better modularity for your application
b) you can’t also create your own functions
c) Functions are reusable pieces of programs
d) All of the mentioned
View Answer

Answer: c
Explanation: Functions are reusable pieces of programs. They allow you to give a name to a block of statements, allowing you to run that block using the specified name anywhere in your program and any number of times.

47. Which of the following Python statements will result in the output: 6?

A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]

a) A[2][1]
b) A[1][2]
c) A[3][2]
d) A[2][3]
View Answer

Answer: b
Explanation: The output that is required is 6, that is, row 2, item 3. This position is represented by the statement: A[1][2].

48. What is the maximum possible length of an identifier in Python?
a) 79 characters
b) 31 characters
c) 63 characters
d) none of the mentioned
View Answer

Answer: d
Explanation: Identifiers can be of any length.

49. What will be the output of the following Python program?

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

a) error
b) 0 1 2 0
c) 0 1 2
d) none of the mentioned
View Answer

Answer: c
Explanation: The else part is not executed if control breaks out of the loop.

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

x = 'abcd'
for i in range(len(x)):
    print(i)

a) error
b) 1 2 3 4
c) a b c d
d) 0 1 2 3
View Answer

Answer: d
Explanation: i takes values 0, 1, 2 and 3.

51. 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
View Answer

Answer: c
Explanation: Built-in functions and user defined ones. The built-in functions are part of the Python language. Examples are: dir(), len() or abs(). The user defined functions are functions created with the def keyword.

52. What will be the output of the following Python program?

  1. def addItem(listParam):
  2.     listParam += [1]
  3.  
  4. mylist = [1, 2, 3, 4]
  5. addItem(mylist)
  6. print(len(mylist))

a) 5
b) 8
c) 2
d) 1
View Answer

Answer: a
Explanation: + will append the element to the list.

53. Which of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
View Answer

Answer: d
Explanation: Tuples are represented with round brackets.

54. What will be the output of the following Python code snippet?

z=set('abc$de')
'a' in z

a) Error
b) True
c) False
d) No output
View Answer

Answer: b
Explanation: The code shown above is used to check whether a particular item is a part of a given set or not. Since ‘a’ is a part of the set z, the output is true. Note that this code would result in an error in the absence of the quotes.

55. What will be the output of the following Python expression?

round(4.576)

a) 4
b) 4.6
c) 5
d) 4.5
View Answer

Answer: c
Explanation: This is a built-in function which rounds a number to give precision in decimal digits. In the above case, since the number of decimal places has not been specified, the decimal number is rounded off to a whole number. Hence the output will be 5.

56. Which of the following is a feature of Python DocString?
a) In Python all functions should have a docstring
b) Docstrings can be accessed by the __doc__ attribute on objects
c) It provides a convenient way of associating documentation with Python modules, functions, classes, and methods
d) All of the mentioned
View Answer

Answer: d
Explanation: Python has a nifty feature called documentation strings, usually referred to by its shorter name docstrings. DocStrings are an important tool that you should make use of since it helps to document the program better and makes it easier to understand.

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

print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

a) Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
b) Error
c) Hello foo and bin
d) None of the mentioned
View Answer

Answer: c
Explanation: The elements of the tuple are accessed by their indices.

58. What is output of print(math.pow(3, 2))?
a) 9.0
b) None
c) 9
d) None of the mentioned
View Answer

Answer: a
Explanation: math.pow() returns a floating point number.

59. 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
View Answer

Answer: b
Explanation: Each object in Python has a unique id. The id() function returns the object’s id.

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

x = [[0], [1]]
print((' '.join(list(map(str, x))),))

a) 01
b) [0] [1]
c) (’01’)
d) (‘[0] [1]’,)
View Answer

Answer: d
Explanation: (element,) is not the same as element. It is a tuple with one item.

61. 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
View Answer

Answer: a
Explanation: Pickling is the process of serializing a Python object, that is, conversion of a Python object hierarchy into a byte stream. The reverse of this process is known as unpickling.

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

def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
print(k)

a) error, there is more than one return statement in a single try-finally block
b) 3
c) 2
d) 1
View Answer

Answer: c
Explanation: The finally block is executed even there is a return statement in the try block.


MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget