Last Updated on October 18, 2021 by Admin
PCAP Python Essentials — PE FINAL TEST Exam Answers: Python 2.0 _ 2021 2022
Python Essentials 1: BASICS | |
Answers | Online Test |
Module 1 Test | Online |
Module 2 Test | Online |
Module 3 Test | Online |
Module 4 Test | Online |
Part 1 Summary Test | Online |
Python Essentials 2: INTERMEDIATE | |
Answers | Online Test |
Module 1 Test | Online |
Module 2 Test | Online |
Module 3 Test | Online |
Module 4 Test | Online |
Part 2 Summary Test | Online |
Final Test | Online |
-
What is the expected output of the following piece of code?
x, y, z = 3, 2, 1 z, y, x= x, y, z print(x, y, z)
2 1 3
1 2 2
1 2 3
3 2 1
Options 3 is the correct answer.
-
Which of the following functions provided by the
os
module are available in both Windows and Unix? (Select two answers)mkdir()
getgroups()
getgid()
chdir()
-
What is the expected output of the following code?
import calendar c = calendar.Calendar(calendar.SUNDAY) for weekday in c.iterweekdays(): print(weekday, end=" ")
Su
Su Mo Tu We Th Fr Sa
6 0 1 2 3 4 5
7 1 2 3 4 5 6
Options 3 is the correct answer.
-
Select the true statements. (Select two answers)
- PyPI is the only exiting Python repository
- PyPI is short for Python Package Index
- PyPI is short for Python Package Installer
- PyPI is one of many existing Python repositories
-
What is true about the following line of code?
print(len((1), )))
- The code will output
2
- The code will output
0
- The code will output
1
- The code is erroneous
- The code will output
-
The
Exception
class contains a property namedargs
– what is it?- A list
- A tuple
- A string
- A dictionary
-
What is the expected result of executing the following code?
Class A: def _init_(self): pass def f(self): return 1 def g(): return self.f() a = A() print(a.g())
- The code will raise an exception
- The code will output
1
- The code will output
0
- The code will output
True
-
What is the expected result of executing the following code?
class A: pass class B: pass class C(A, B): pass print(issubclass(C, A) and issubclass(C, B))
- The code will print an empty line
- The code will raise an exception
- The code will print
True
- The code will print
False
-
What is the expected output of the following code?
t = (1, ) t = t[0] + t[0] print(t)
2
(1, 1)
(1,)
1
Options 1 is the correct answer.
-
What is the
sys.stdout
stream normally associated with?- The printer
- The screen
- The keyboard
- A
null
device
- How many stars (
*
) will the following snippet send to the console?i = 4 while i > 0 : i -= 2 print("*") if i == 2: break else: print("*")
- The snippet will enter an infinite loop, constantly printing one
*
per line - zero
- one
- two
- The snippet will enter an infinite loop, constantly printing one
-
What is true about the following snippet?
def fun(d, k, v) : d[k] = v my_dictionary = {} print(fun(my_dictionary, '1', 'v'))
- The code will output
v
- The code is erroneous
- The code will output
1
- The code will output
None
- The code will output
-
What is the expected output of the following snippet?
d = {'one': 1, 'three': 3, 'two': 2} for k in sorted(d.values()): print(k, end=' ')
1 2 3
2 3 1
3 1 2
3 2 1
Options 1 is the correct answer.
-
What is the expected behavior of the following piece of code?
x = 16 while x > 0: print('*', end='') x //=2
- The code will output
*****
- The code will output
*
- The code will enter an infinite loop
- The code will output
***
- The code will output
-
What is the expected behavior of the following code?
x = """ """ print(len(x))
- The code will output
2
- The code will cause an error
- The code will output
1
- The code will output
3
- The code will output
-
What is the name of the directory/folder created by Python used to store
pyc
files?_cache_
_pycfiles_
_pycache_
_pyc_
-
What is the expected output of the following code?
my_string_1 = 'Bond' my_string_2 = 'James Bond' print(my_string_1.isalpha(), my_string_2.isalpha()))
False False
True False
False True
True True
Options 2 is the correct answer.
-
The meaning of a keyword argument is determined by its:
- value only
- position within the argument list
- both name and value assigned to it
- connection with existing variables
-
What is the expected output of the following code, located in the file
module.py
?print(_name_)
main
module.py
_main_
_module.py_
-
Which line properly invokes the function defined as below?
def fun(a, b, c=0): # function body
fun(1, c=2)
fun(0)
fun(a=1, b=0, c=0)
fun(b=0, b= 0)
-
Which of the following sentences is true about the snippet below?
str_1 = 'string' str_2 = str_1[:]
- str_1 is longer than str_2
- str_2 is longer than str_1
- str_1 and str_2 are different (but equal) strings
- str_1 and str_2 are different names of the same string
-
What is the expected output of the following code?
from datetime import timedelta delta = timdelta(weeks = 1, days = 7, hours = 11) print(delta)
- 2 weeks, 11:00:00
- 14 days, 11:00:00
- 1 week, 7 days, 11 hours
- 7 days, 11:00:00
Options 2 is the correct answer.