What is the output of the following expression in Python? not(True or False)
False
Write the output of the given Python code:
print(4**2)
16
What is the output of the given python code:
fileName = [Janet, Smith]
print (fileName[1])
Smith
How many asterisks does the following code fragment print?
a = 0
while a < 10:
print('*', end='')
a += 1
10
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
What is a Local Scope?
The local objects available in the current function.
Write the output of the given Python code:
print (3 // 2) #floor division
1
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]
Write the output of the given python code:
print(range(5,10)
5
6
7
8
9
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]
What is the an easy to read, compact, and elegant way of creating a list from any existing iterable object?
List Comprehension
Write the output of the given Python code:
print (3 % 2) #Modulus
1
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
What is the output of the following python code:
color_list = ["Red","Green","White" ,"Black"]
print(color_list[0],color_list[-1])
Red
Black
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
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)
Write the output of the given python code:
def test(n):
n=[10]
x=[12]
test(x)
print(x)
12
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']
What is the output of the following python code:
lst=[1,[2,3],4]
Print(lst[1])
[2,3]
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
What is the name of the document that provides
guidelines for best practices of writing Python code?
PEP 8
What module would you import to print a calendar?
import calendar
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
What is the output of the following python code:
lst=[1,[2,3],4]
print(len(lst))
3
What is the output of the following python code?
Input1 = 23
Input2 = 22
print(Input1 + Input2)
(a) 2322
(b) 45
45