COM219 Midterm

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What are the values of the following Python expression? 2**(3**2) (2**3)**2 2**3**2

512, 64, 512

What will be the output of the following Python code? print("abc. DEF".capitalize())

Abc. def

What will be the output of the following Python statement? >>>"a"+"bc"

abc

Python supports the creation of anonymous functions at runtime, using a construct called what?

lambda

Is Python code compiled or interpreted?

Python code is both compiled and interpreted

What arithmetic operators cannot be used with strings in Python?

-

Which of the following is the truncation division operator in Python?

//

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)

0 1 2

What will be the output of the following Python code? x = 'abcd' f or i in range(len(x)): print(i)

0 1 2 3

Who developed Python Programming Language?

Guido van Rossum

Which of these is the definition for packages in Python?

A folder of python modules

Which of the following characters is used to give a single line comment in Python?

#

What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp = tester(12) >>>print(temp.id)

12

What will be the output of the following Python function? min(max(False, -3, -4), 2,7)

False

Which of the following is the use of the id() function in Python?

Id returns the identity of the object

Which of the following is the use of id() function in python?

In Python Id function returns the identity of the object

Which of the following is a feature of Python DocString?

In Python all functions should have a docstring; Docstrings can be accessed by the __doc__ attribute on objects; It provides a convenient way of associating documentation with Python modules, functions, classes, and methods

Which of the following is used to define a block of code in Python language?

Indention

What is the order of precedence in Python?

Parenthesis, Exponential, Multiplication, Division, Addition, Subtraction

What does pip stand for in Python?

Preferred Installer Program

What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z

True

What will be the output of the following Python program? def foo(x): x[0] = ['def'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))

True

What will be the output of the following Python code? 1=[1, 0, 2, 0, 'hello', '', []] list(filter(bool, 1))

[1, 2, 'hello']

What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2)

[4, 3]

The process of pickling in Python includes what?

conversion of a Python object hierarchy into byte stream

Which module in the python standard library parses options received from the command line?

getopt

Which of the following statements is used to create an empty set in Python?

set()

What is the maximum possible length of an identifier in Python?

they can be any length

Which one of the following is the use of function in python?

Functions are reusable pieces of programs

What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

Hello foo and bin

What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),))

('[0] [1]',)

Which of the following is a Python tuple?

(1, 2, 3)

What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='')

*abcde *

What will be the output of the following Python expression if x=56.236? print("%.2f"%x)

56.24

To add a new element to a list we use which Python command?

list1.append(5)

Are keywords in Python are what?

nothing

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)

[1, 3, 5, 7, 8]

Which keyword is used for function in the Python language?

def

Which function is called when the following Python program is executed? f = foo() format(f)

__str__()

Which of the following is not a core data type in Python Programming?

Class

Which of the following Python statements will result in the output: 6? A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

A[1][2]

Which of the following is true for variable names in Python?

unlimited lenght

Which of the following is the correct extension of the Python file?

.py

What will be the output of the following Python code? def foo(): try: return 1 finally: return 2 k = foo() print(k)

2

What will be the output of the following Python function? len(["hello",2, 4, 6])

4

What will be the output of the following Python snippet if x=1? x<<2

4

What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i)

4 3 2 1

What will be the output of the following Python expression? round(4.576)

5

What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))

5

What is the value of the following Python expression? 4 + 3 % 5

7

What is output of print(math.pow(3, 2))?

9.0

What will be the output of the following Python code? x = 'abcd' for i in x: print(i.upper())

A B C D

What are the two main types of functions in Python?

Built-in function & User defined function

What is the order of namespaces in which Python looks for an identifier?

Python first searches the local namespace, then the global namespace and finally the built-in namespace

The following Python program can work with which perimeters? def f(x): def f1(*args, **kwargs): print("Sanfoundry") return x(*args, **kwargs) return f1

any perimeters

What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1

error

Which one of the following is not a keyword in Python language?

eval

Which type of Programming does Python support?

object-oriented programming, structured programming, functional programming

Which of the following functions is a built in function in Python?

print()

Which of the following functions can help us find the version of Python we are currently working on?

sys.version

Is Python case sensitive when dealing with identifiers?

yes

What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'])) z

{'a', 'b', 'c', 'p', 'q', 'san'}


Ensembles d'études connexes

Chemistry Notes Chapter 1, 2, 3 Exam Review

View Set

principles of marketing chapter 13

View Set

Measuring and Recording Apical Pulse

View Set

AP Psychology Operant Conditioning and Cognitive Learning

View Set

The Point: Chapter 22 Neurodevelopmental Disorders

View Set

Plantinga "The Free Will Defense"

View Set