0% found this document useful (0 votes)
33 views7 pages

Python MCQs - 241211 - 133746

The document consists of multiple-choice questions (MCQs) covering various topics related to Python programming, including data structures, multithreading, CGI scripting, socket programming, Tkinter, SQLite, and exception handling. Each question presents four answer options, testing knowledge on syntax, functionality, and concepts within Python. The document serves as a quiz or study material for individuals looking to assess their understanding of Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views7 pages

Python MCQs - 241211 - 133746

The document consists of multiple-choice questions (MCQs) covering various topics related to Python programming, including data structures, multithreading, CGI scripting, socket programming, Tkinter, SQLite, and exception handling. Each question presents four answer options, testing knowledge on syntax, functionality, and concepts within Python. The document serves as a quiz or study material for individuals looking to assess their understanding of Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

MCQs

1) What will be the output of the following Python code snippet? 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")

2) What would be the impact of multithreading on a uni-processor system?

a. Degrade performance

b. Improve performance

c. Reduce execution time

d. Increase throughput

3) What is the method to retrieve the list of all active threads?

a. getThreads()

b. getList()

c. threads()

d. enumerate()

4) What is the exception raised for an error that doesn't fall in any of the categories?

a. ReferenceError

b. RuntimeError

c. SystemError

d. LookupError

5) How does global value mutation used for thread-safety?

a. via Mutex

b. None

c. via GIL(Global interpreter Lock)

d. via Locking

6) Which computer language generally used to write CGI scripts?

a. Perl scripts

b. C/C++ programs

c. Unix Scripts

d. All of the above


7) How does the form data get accessed in POST?

a. As a continuous stream of bytes from standard input, the number of bytes is


stored in the content length environment variable.

b. As a discreate stream of values from standard input, the number of bytes is stored in
the content length environment variable.

c. As a continuous stream of bytes from standard output.

d. As a continuous stream of bits from standard input.

8) CGI script is not

a. The protocol used to run programs on web servers.

b. Platform dependent

c. No provision for separation between the presentation and business logic

d. Object-oriented and secure

9) Which method of the socket module allows a server socket to accept requests from a client
socket from another host?

a. socket.accepts()

b. socket.sendto(address)

c. socket.acceptsocket

d. accept.socket()

10) Which method of the socket module allows you to send data to a given address?

a. socket.sendto(address, data)

b. socket.address()

c. socket.sendto(data, address)

d. socket.data

11) Which method of the socket module allows you to associate a host and a port with a
specific socket?

a. the socket.sendto(PORT) method

b. The bind(IP, PORT) method

c. The bind(PORT, IP) method

d. The socket.accept(PORT) method

12) What is the difference between the TCP and UDP protocols, and how do you implement
them in Python with the socket module?

a. TCP is compatible with python, while UDP is not

b. There are no differences


c. TCP is not connection-oriented, while UDP is connection-oriented

d. TCP is connection-oriented, while UDP is not connection-oriented

13) Which method of the socket module allows you to implement port scanning with sockets
and to check the port state?

a. The sock.connect_ex(ip_address, port)) method

b. The socket.accept() method

c. The sock.connect_ex(port, IP) method

d. The socket.connect(port) method

14) What protocol can be used to retrieve web pages using python?

a. urllib

b. bs4

c. HTTP

d. GET

15) What is a python library that can be user to send and receive data over HTTP?

a. http

b. urllib

c. port

d. header

16) Config() in Python Tkinter are used for

a. destroy the widget

b. place the widget

c. change property of the widget

d. configure the widget

17) Correct way to draw a line in canvas tkinter?

a. line()

b. canvas.create_line()

c. create_line(canvas)

d. create_line()

18) Essential thing to create a window screen using tkinter python

a. call tk() function

b. create a button
c. To define a geometry

d. delete a function

19) For what purpose, the bg is used in Tkinter widget

a. To change the direction of widget

b. To change the size of widget

c. To change the color of widget

d. To change the background of widget

20) Fow the place() function put the widget on the screen?

a. According to x,y coordinate

b. According to row and column vise

c. According to left,right,up,down

d. According to left and right only

21) Tkinter tool in python provide the

a. Database

b. OS commands

c. GUI

d. Sys command

22) By using sqlite3, we can store our data on

a. local

d. Global

c. Server

d. browser

23) close() function in sqlite3 is used for the

a. To close the query

b. To close the table

c. To close the database

d. To close the file

24) What is the name of the SQL database the comes distributed with Python?

a. SQLite

b. PostgreSQL

c. PySQL
d. MySQL

25) Who developed the Python language?

a. Zim Den

b. Guido van Rossum

c. Niene Stom

d. Wick van Rossum

26) The input() function takes user's input as a

a. integer

b. float

c. string

d. character

27) Which is the correct operator for power(XY)?

a. X^Y

b. X**Y

c. X^^Y

d. X***Y

28) Which one of these is floor division?

a. /

b. //

c. %

d. *

29) Which keyword is used for function?

a. Fun

b. Define

c. Def

d. Function

30) What are the two main type of functions?

a. Custom function

b. Build-in function $ User defined function

c. User function

d. System function
31) Python supports the creation of anonymous functions at runtime, using a construct called

a. pi

b. lambda

c. anonymous

d. synonymous

32) What is the output of this expression, 3*1**5?

a. 27

b. 9

c. 3

d. 1

33) What will be the output of the following Python expression? round(4.5676,3)?

a. 4.5

b. 4.6

c. 4.568

d. 4.57

34) Which of the following statements is true?

a. The standard exceptions are automatically imported into Python programs

b. All raised standard exceptions must be handled in Python

c. When there is a deviation from the rules of a programming language, a semantic error
is thrown

d. If any exception is thrown in try block, else block is executed

35) Which of the follwoing blocks will be executed wheather an exception is thrown or not?

a. except

b. else

c. finally

d. assert

36) Which of the following is not an exception handling keyword in Python?

a. except

b. try

c. accept

d. finally
37) How many except statements can a try-except block have?

a. zero

b. one

c. more than one

d. more than zero

38) Which of the following statements is wrong about inheritance?

a. Protected members of a class can be inherited

b. The inheriting class is called a subclass

c. Private members of a class can be inherited and accessed

d. Inheritance is one of the features of OOP

39) What is the method to retrieve the list of all active threads?

a. getThreads()

b. getList()

c. threads()

d. enumerate()

40) What is the exception raised for an error that doesn't fall in any of the categories?

a. ReferenceError

b. RuntimeError

c. SystemError

d. LookupError

You might also like