General Python
Math Operations
Output
Code
Multiple Choice Questions
100

What is the output of the following expression in Python? not(True or False)

False

100

Write the output of the given Python code:

print(4**2)

16

100

What is the output of the given python code:

fileName = [Janet, Smith]

print (fileName[1])

Smith

100

How many asterisks does the following code fragment print?

a = 0

while a < 10:

    print('*', end='')

    a += 1


10

100

Which of the following will raise an error if the given key is not found in dict?
a. del statement
b. pop()
c. getitem()
d. all of these

d. all of these

200

What is a Local Scope?

The local objects available in the current function.

200

Write the output of the given Python code:

print (3 // 2) #floor division

1

200

What is the output of the following code?
a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)

[13, 56, 17, [87], 45, 67]

200

Write the output of the given python code:

print(range(5,10)

5

6

7

8

9

200

What is the output of the following python code?

lst=[i for i in range(1,2)]

print(lst)

(a) [1]

(b) [1,2]

[1]

300

What is the an easy to read, compact, and elegant way of creating a list from any existing iterable object?

List Comprehension

300

Write the output of the given Python code:

print (3 % 2) #Modulus

1

300

What is the output of the following code?
list1=[1,2,3]
list2=[1,2,3]
print(list1 is list2)
list3=list1
print(list1 is list3)

False
True              

300

What is the output of the following python code:
color_list = ["Red","Green","White" ,"Black"]

print(color_list[0],color_list[-1])

Red

Black

300

What is the output of the following python code?

def strange_function(n):

    if (n % 2 == 0):

        return True

print(strange_function(2))

(a) True

(b) None

True

400

Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.

a = (input("Input an integer : "))

n1 = int(a)

n2 = int(a + a)

n3 = int(a + a + a)

print (n1+n2+n3)

400

Write the output of the given python code:

def test(n):

    n=[10]

x=[12]

test(x)

print(x)

12

400

What is the output of the following code?
veggies = ['carrot', 'broccoli', 'potato', 'asparagus']
veggies.insert (veggies.index('broccoli'), 'celery')
print(veggies)

['carrot', 'celery', 'broccoli', 'potato', 'asparagus']

400

What is the output of the following python code:

lst=[1,[2,3],4]

Print(lst[1])

[2,3]

400

What is the output of the following python code?

def strange_function(n):

    if (n % 2 == 0):

        return True

print(strange_function(1))

(a) True

(b) None

None

500

What is the name of the document that provides
guidelines for best practices of writing Python code?

PEP 8

500

What module would you import to print a calendar?

import calendar

500

What is the output of the following Python code?

def difference(n):

    if n <= 17:

        return 17 - n

    else:

        return (n - 17) * 2 

print(difference(22))

print(difference(14))


10

3

500

What is the output of the following python code:

lst=[1,[2,3],4]

print(len(lst))

3

500

What is the output of the following python code?

Input1 = 23

Input2 = 22

print(Input1 + Input2)

(a) 2322 

(b) 45


45