-
Which of the following open modes allow you to perform read operations? (Select two answers)
-
What is the expected result of executing the code?
def I():
s = 'abcdef'
for c in s[::2]:
yield c
for x in I():
print(x, end=' ')
- It will print
abcdef
- It will print an empty line
- It will print
bdf
- It will print
ace
-
What keyword would you us to define an anonymous function?
-
Select the true statements. (Select two answers)
- The
lambda
function can accept a maximum of two arguments
- The
lambda
function can evaluate multiple expressions
- The
lambda
function can evaluate only one expressrion
- The
lambda
function can accept any number of arguments
-
Look at the code below:
my_list = [1, 2, 3]
# insert line of code here.
print(foo)
Which snippet would you insert in order for the program to output the following result (tuple):
1, 4, 27
foo = list(map(lambda x: x**x, my_list))
foo = tuple(map(lambda x: x*x, my_list))
foo = list(map(lambda x: x*x, my_list))
foo = tuple(map(lambda x: x**x, my_list))
-
What is the expected output of the following code?
from datetime import date
date_1 = date(1992, 1, 16)
date_2 = date(1992, 2, 5)
print(date_1 - date_2)
345
345 days
345, 0:00:00
345 days, 0:00:00
-
Which program will produce the following output:
Mo Tu We Th Fr Sa Su
-
import calendar
print(calendar.weekheader(3))
-
import calendar
print(calendar.weekheader(2))
-
import calendar
print(calendar.week)
-
import calendar
print(calendar.weekheader())
-
What is the expected result of executed the following code?
def o(p):
def q():
return'*' *p
return q
r = o(1)
s = o(2)
print(r9) + s())
- it will print
***
- it will print
***
- it will print
**
- it will print
*
-
Look at the code below:
my_tuple = (0, 1, 2. 3, 4, 5, 6)
# Insert line of code here.
print(foo)
Which snippet would you insert in order for he program to output the following result (list):
[2, 3, 4, 5, 6]
-
foo = list(filter(lambda x: x-0 and x-1, my_tuple))
-
foo - list(filter(lambda x: x==0 and x==1, my_tuple))
-
foo = tuple(filter(lambda x: x>1, my_tuple))
-
foo = tuple(filter(lambda x: x-0 and x-1, my_tuple))
-
What is the expected result of executed the following code?
def fun(n):
s = '+'
for i in range(n):
s += s
yield s
for x in fun(2):
print(x, end='')
- It will print
+++
- It will print
++
- It will print
++++++
- It will print
+
-
What is the meaning of the value represented by errno.EEXITS
?
- File doesn’t exist
- Bad file number
- Permission denied
- File exists
-
What is the expected result of the following code?
b = bytearray(3)
print(b)
3
bytearray(b'\x00\x00\x00')
bytearray(0, 0, 0)
bytearray(b'3')
-
What is the expected output of the following code?
from datetime import datetime
datetime = datetime(2019, 11, 27, 11, 27, 22)
perint(datetime.strftime('%y/%B/%d %H:%M:%s'))
19/November/27 11:27:22
2019/Nov/27 11:27:22
2019/11/27 11:27:22
19/11/27 11:27:22
-
What is the expected output of the following code?
import os
os.mkdir('pictures')
os.chdir('pictures')
os.mkdir('thumbnails')
os.chdir('thumbnails')
os.mkdir('tmp')
os.chdir('../')
print(os.getcwd())
- The orint to the
thumbnails
directory
- The path to the
pitcures
directory
- The path to the
tmp
directory
- The path to th root directory
-
What is the expected output of the following code?
import os
os.mkdir('thumbnails')
os.chdir('thumbnails')
sizes = ['small', 'medium', 'large']
for size in sizes:
os.mkdir(size)
print(os.listdir())
['.', '..', 'large', 'small', 'medium']
[]
['.', 'large', 'small', 'medium']
['large', 'small', 'medium']
-
What is the expected result of the following code?
import calendar
c = calendar.Calendar()
for weekday in c.iterweekdays():
print(weekday, end="")
1 2 3 4 5 6 7
Su Mo Tu We Th Fr Sa
0 1 2 3 4 5 6 7
Mo Tu We Th Fr Sa Su