0% found this document useful (0 votes)
8 views17 pages

Python Assignment Activity

The document is a Python assignment activity consisting of multiple-choice questions that assess knowledge of Python programming concepts, syntax, and functionalities. It covers topics such as data types, functions, file handling, and regular expressions. Each question requires the participant to select the correct answer from provided options.

Uploaded by

Shailendra
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)
8 views17 pages

Python Assignment Activity

The document is a Python assignment activity consisting of multiple-choice questions that assess knowledge of Python programming concepts, syntax, and functionalities. It covers topics such as data types, functions, file handling, and regular expressions. Each question requires the participant to select the correct answer from provided options.

Uploaded by

Shailendra
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

Name : ___________________________

PYTHON ASSIGNMENT ACTIVITY


Q1
The print function in Python 3 is enclosed in parentheses ().
A. True
B. False
Q2
Lists in Python can be delimited by square brackets ([]), with the first element
at index 0.
A. True
B. False
Q3
Python tuples are enclosed in parenthesis (()) and the internal elements are
separated by semicolons(;)
A. True
B. False
Q4
Continue statements in Python are used to skip the rest of the statements in
the body of loop for the current iteration and jump to the beginning of the
loop for next iteration
A. True
B. False
Q5
[Link]() function can measure the number of seconds since the epoch as a
floating point value.
A. True
B. False
Q6
Python author designed the restrictive syntax to filter out bad programming
(like failing to add an indentation on the right of the next line of the if
statement)
A. True
B. False
Name : ___________________________

Q7

(Single-Answer Question) Which of the following lines properly starts a


parameter less function definition?

A. function func():
B. def func:
C. fun function():
D. def func():

Q8
Functions are organised code segments which CANNOT be REUSED to
implement single or related operations.
A. True
B. False

Q9
(Single-Answer Question) Which of the following is not a Python re regular
expression module function?
A. Match
B. Compile
C. Update
D. Search
Q10
(Single-Answer Question) Knowing that a function named myFunc() resides in a
module named myMod, choose the proper way to import it:

A. import myFunc() from myMod


B. import myFunc()
C. from myMod import myFunc()
D. from myFunc() import myMod
Name : ___________________________

Q11
(Single-Answer Question) Which of the following Python identifier is INVALID?
A. 1var
B. var_1
C. Var_1
D. _var1
Q12
(Single-Answer Question) Which of the following is unchangeable in Python?
A. List
B. Tuple
C. Array
D. Set
Q13
(Multiple-Answer Question) Which of the following statements are TRUE?
A. Python is often nicknamed “glue language” because it can easily glue
together various modules developed in other languages.
B. It was created by Guido van Rossum, the Dutchman, in 1989, and it was
first released in 1991.
C. Python is a kind of free and open-source software.
D. The Python syntax is simple and clear, characterized by using blank
characters for indentation.
Q14
(Multi-Answer Question) Python is an object-oriented programming language.
Which of the following are Python objects?

A. Function
B. Module
C. Number
D. Character string
Name : ___________________________

Q15
(Multi-Answer Question) Which of the following statements about Python
index are true?

A. Default index from right to left is numbered from -1.


B. Default index from left to right is numbered from 0.
C. Default index from right to left is numbered from 0.
D. Default index from left to right is numbered from 1.
Q16
(Single-Answer Question) One of the following variables’ names is illegal –
which one?

A. true
B. tRUE
C. True
D. TRUE
Q17
(Single-Answer Question) An operator that is able to check whether two
values are equal is coded as

A. =
B. ==
C. ===
D. !=

Q18

(Single-Answer Question) Which of the following is not a Python operator?

A. Arithmetic operator
B. Inference operator
C. Logical operator
D. Comparison operator
Name : ___________________________

Q19

(Single-Answer Question) How many hashes will the following code snippet
send to the console?

i=0
while i <= 3 :
i += 2
print(“#”)

A. two
B. zero
C. one
D. three

Q20

(Single-Answer Question) Which of the following statements about Python


regular expression is NOT true? ()

A. re regular expression module was added in Python 1.5


B. re module grants all regular expression functions to Python.
C. re regular expression is a powerful tool to process strings
D. re regular expression can only process character string data, not
numerical data.
Q21

(Single-Answer Question) According to Python Enhancement Proposal (PEP)


8, how many spaces should the first line be indented by in Python? ()

A. 1
B. 2
C. 4
D. 8
Name : ___________________________

Q22

(Multi-Answer Question) What are the numeric types of Python?

A. int (integer type)


B. long (long integer type)
C. float (floating point type)
D. complex (complex number type)

Q23

(Single-Answer Question) When a file is opened in read mode, it ():

A. must exist (an exception will be raised otherwise)


B. cannot exist (it has to be created every time)
C. it will be deleted, if it exists
D. it doesn’t have to exist (it will be created if not present)

Q24

(Single-Answer Question) If you want to open a text file in append mode,


you would use the following mode string:

A. t+a
B. at
C. a+t
D. at+

Q25

(Single-Answer Question) Assuming that the open() invocation has gone


successfully, the following code snippet will:

for x in open(‘file’,’rt’):

print(x)

A. read the file line by line


B. read the file character by character
C. cause an exception error
D. read the whole file at once.
Name : ___________________________

Q26

(Single-Answer Question) What is WRONG description of the Python


module?

A. The Python module is a Python file that ends with .py and contains
Python object definitions and Python statements.
B. The Python module allows you to logically organize your Python code
snippets.
C. Python modules can define functions, classes, and variables, but the
module does NOT contain executable code.
D. Assigning relevant code to a module can make your code better and
easier to understand.

Q27
The commonly used functions for mathematical operations in Python are
basically in the math module and the cmath module.

A. True
B. False

Q28
(Single-Answer Question) What is WRONG with the introduction of Python
module time?

A. from time
B. import time
C. from time import*
D. import time as t

Q29
(Multi-Answer Question) What are the advantages of Python?

A. free
B. simple
C. high-level language
D. rich library
Name : ___________________________

Q30
(Multi-Answer Question) What are the Python language data types?

A. list
B. string
C. tuple
D. number
E. dictionary

Q31
(Single-Answer Question) What is NOT the difference between Python 2 and
Python 3?

A. import
B. print
C. unicode
D. xrange

Q32
(Multi-Answer Question) What operating systems does Python support?

A. linux
B. DOS
C. Windows
D. MacOS

Q33
Print in Python 3 must be used with ()

A. True
B. False
Name : ___________________________

Q34
The components of Python identifier include: numbers, letters, and
underscores

A. True
B. False

Q35
(Multi-Answer Question) The Python script execution model includes
interactive mode and script mode

A. True
B. False
C. 0
D. Null

Q36
Python tuples are identified by “()” and internal elements are separated by “:”

A. True
B. False

Q37
(Multi-Answer Question) What are the advantages of Python?

A. Beautiful
B. Expensive
C. Explicit
D. Simple
Name : ___________________________

Q38
(Single-Answer Question) What is the output of the following snippet if the
user enters two lines containing 3 and 6 respectively?
i = input()
j = input()
Print (i + j)

A. 9
B. 36
C. 6
D. 3

Q39
(Single-Answer Question) The print() function can output values of:

A. Any number of arguments (excluding zero)


B. Just one argument
C. Any number of arguments (including zero)
D. Not more than five arguments

Q40
(Single-Answer Question) What is the output of the following snippet if the
user enters two lines containing 2 and 4 respectively?
i = input()
j = int(input())
print(i * j)

A. 24
B. 8
C. 2222
D. 44
Name : ___________________________

Q41
(Single-Answer Question) What is the output of the following snippet if the
user enters two lines containing 3 and 5 respectively?
i = int(input())
j = int(input())
print(i + j)

A. 5
B. 3
C. 35
D. 8

Q42
(Single-Answer Question) Python regular expressions are a special sequence of
characters that makes it easy to check if a string matches pattern.

A. True
B. False

Q43
(Single-Answer Question) Python language can use multiple statements on the
same line, separated by commas.

A. True
B. False

Q44
(Multi-Answer Question) Python is a fully object-oriented language. Which of
the following options belong to the Python object?

A. Function
B. Module
C. Number
D. Character string
Name : ___________________________

Q45
(Multi-Answer Question) What quotation marks can the Python language use?

A. Single quotes
B. Double quotes
C. Three quotes
D. Four quotes

Q46
(Single-Answer Question) The Python list can be identified by “[]”, and the
default index of the first element from left to right is 1.

A. True
B. False

Q47
(Single-Answer Question) Which of the following is NOT the difference
between Python 2 and Python 3?

A. print
B. unicode
C. import
D. Xrange

Q48
(Single-Answer Question) The commonly used functions for mathematical
operations in Python are basically in the math module and the cmath module.

A. True
B. False

Q49
(Single-Answer Question) Python tuples are identified by “()” and internal
elements are separated by ;

A. True
B. False
Name : ___________________________

Q50
(Multi-Answer Question) Which of the following are the characteristics of the
Python language?

A. Explanatory
B. Process oriented
C. Object-oriented
D. Dynamic data type

Q51
(Single-Answer Question) The timestamps in the Python language are
represented by how long fin seconds elapsed from midnight (epoch) on
January 1, 1970

A. True
B. False

Q52
(Single-Answer Question) What are the results returned by the if conditional
statements in the Python language?

A. True
B. 0
C. False
D. Null

Q53
(Single-Answer Question) The Python language can use the “#” at the
beginning of a single line of code for code comments

A. True
B. False
Name : ___________________________

Q54
(Single-Answer Question) Python authors deliberately design very restrictive
grammars that make bad programming habits (such as the next line of if
statement not indented to the right) cannot be compiled.

A. True
B. False

Q55
(Single-Answer Question) What are the steps that are NOT part of the
operation of a Python file object?

A. open
B. delete
C. read
D. write
E. close

Q56
(Single-Answer Question) The for loop statement in the Python language can
iterate through the items in any sequence.

A. True
B. False

Q57
(Multi-Answer Question) About Python tuple which is CORRECT description?

A. The difference between a list and a tuple is that the elements of the
tuple CANNOT be modified.
B. The list uses square brackets, and the tuple uses parentheses.
C. Tuple creation is very simple, just and elements in parentheses and
separate them with comma.
D. When a tuple contains only one element, you need to add a comma
after the element.
Name : ___________________________

Q58
(Multi-Answer Question) Which is the correct description of the Python
creation function?

A. The function created starts with the def keyword followed by


B. delete
C. read
D. write
E. close

Q59
(Multi-Answer Question) What are the characteristics of Python code.

A. Legibility
B. Simplicity
C. Rapidity
D. Scalability

Q60
(Single-Answer Question) The constituent elements of the Python identifier
include numbers, letters and underscores.

A. True
B. False

Q61
(Single-Answer Question) Which description is WRONG about the lambda
function of the Python language.

A. Lambda is just an expression, and the function body is much simpler


than def
B. The body of a lambda can be an expression or a block of code.
C. The lambda function can access the parameters in the global
namespace.
D. The lambda function accepts only ONE parameter value.
Name : ___________________________

Q61
(Single-Answer Question) The time interval in the Python language is a floating-
point fraction in seconds.

A. True
B. False

Q62
(Multi-Answer Question) Which of the following descriptions about Python
program are correct?

A. The program consists of modules


B. Module contains statements
C. Statement contains an expression
D. Expressions create and process objects

Q63
(Multi-Answer Question) What are the ADVANTAGES of Python?

A. simple
B. free
C. high-level language
D. rich library

Q64
(Single-Answer Question) Python script execution mode includes interactive
mode and script mode.

A. True
B. False

Q65
(Multi-Answer Question) Which of the following features does Python
support?

A. inheritance
B. heavy load
C. derived
D. multiple inheritance
Name : ___________________________

Q66
(Single-Answer Question) Which of the following description about Python
regular expression is NOT correct?

A. Python has added the re regular expression module since version 1.5
B. re regular expression module gives the Python language all the regular
expression functionality.
C. re regular expressions are powerful tools for working with strings.
D. re regular expressions can only process string data, NOT numeric data.

Q67
(Multi-Answer Question) What are the application scenarios for the break
statement in the Python language?

A. Any Python statement


B. while loop statement
C. for loop statement
D. Nested loop statement

Q68
(Single-Answer Question) Python dictionary is identified by {} and the internal
data consists of the key and its corresponding value.

A. True
B. False

Q69
(Single-Answer Question) “print” in Python 3 must be used with “Queue”.

A. True
B. False

Q70
(Single-Answer Question) Which of the following is NOT a Python operator?

A. Arithmetic operator
B. Reasoning operator
C. Logical operator
D. Comparison operator

You might also like