PE2 Python Essentials 2 Part 2 Summary Test Answers Full 100%

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

HOME (HTTPS://EXAMTUBE.

ORG/)

ExamTube
Search... 
(https://examtube.org/)

NDG LINUX ESSENTIALS 2.21 (HTTPS://EXAMTUBE.ORG/NDG-LINUX-ESSENTIALS-2-21/)

NDG LINUX II 2.21 (HTTPS://EXAMTUBE.ORG/NDG-LINUX-II-2-21/)

PE1 PYTHON ESSENTIALS 1 (HTTPS://EXAMTUBE.ORG/PE1-PYTHON-ESSENTIALS-1/)

PE2 PYTHON ESSENTIALS 2 (HTTPS://EXAMTUBE.ORG/PE2-PYTHON-ESSENTIALS-2/)

ETHICAL HACKER (HTTPS://EXAMTUBE.ORG/ETHICAL-HACKER-MODULE-QUIZ-EXAM-ANSWERS-2023-

2024/)

PE2: Python Essentials 2 – Part 2 Summary Test Answers Full


100%
Home (https://examtube.org/) » PE2 Python Essentials 2 (https://examtube.org/pe2-python-essentials-2/) » PE2: Pytho
PE2: Python Essentials 2 – Part 2 Summary Test Recent Posts
Answers Full 100% 2023 2024
Which two activities are

This is Cisco NetAcad SkillsForAll PE2: Python Essentials 2 – Part 2 normally controlled by the
Northbridge part of the chipset?
Summary Test and PE2 Course Final Exam Answers full 100% in 2023 and
(Choose two.)
2024. All answers have been verified by experts.
(https://examtube.org/which-
two-activities-are-normally-
1. The following code:
controlled-by-the-northbridge-
part-of-the-chipset-choose-
two/)
x = "\\\\"
Which of the following is not a
print(len(x))
valid command for variable
declaration?
(https://examtube.org/which-of-
will print 1
the-following-is-not-a-valid-
will print 2 command-for-variable-
will cause an error declaration/)
will print 3 A new environment variable can

2. What information can be read using the uname be exported and assigned a
value with a single command.
function provided by the os module? (Select two
(https://examtube.org/a-new-
answers)
environment-variable-can-be-
exported-and-assigned-a-value-

import os with-a-single-command/)
Which of the following is not a
os.mkdir('pictures')
valid variable name?
os.chdir('pictures') (https://examtube.org/which-of-
print(os.getcwd()) the-following-is-not-a-valid-
variable-name/)
Shell variables are case
Last login date. sensitive. True or False?
Current path (https://examtube.org/shell-
Operating system name variables-are-case-sensitive-
Hardware identifier true-or-false/)

3. The following statement: Which of the following is a valid


variable assignment?
(https://examtube.org/which-of-
assert var != 0 the-following-is-a-valid-variable-
assignment/)
3.2.3.4 Web Browsers
ia erroneous (https://examtube.org/3-2-3-4-
has no effect web-browsers/)

will stop the program when var == 0


will stop the program whrn var !=0 3.2.3.3 Productivity
(https://examtube.org/3-2-3-3-
4. What is he except output of the following code?
productivity/)
3.2.3 Desktop Applications |

class A: 3.2.3.1 Email | 3.2.3.2 Creative


(https://examtube.org/3-2-3-
A = 1
desktop-applications-3-2-3-1-
def __init__(self): email-3-2-3-2-creative/)
self.a = 0 3.2.2.5 File Sharing

print(hasattr(A, 'a')) (https://examtube.org/3-2-2-5-


file-sharing/)

0
Recent Comments
True
1 Kuba on NDG Linux Essentials
False 2.21 | Creating Users and

5. What is the excepted result of the following code? Groups Module 16 | Chapter 16
Exam Answers Full 100%
(https://examtube.org/ndg-
from datetime import timedelta linux-essentials-2-21/ndg-linux-
essentials-2-21-creating-users-
delta = timedelta(weeks = 1, days = 7, hours
and-groups-module-16-chapter-
print(delta * 2)
16-exam-answers-full-
100/#comment-16)

28 days, 22:00:00 Kuba on NDG Linux Essentials

2 weeks, 14 days, 22 hours 2.21 | Working with Text Module


10 | Chapter 10 Exam Answers
7 days, 22:00:00
Full 100%
The code will raise an exception
(https://examtube.org/ndg-
6. What is the excepted output of the following code? linux-essentials-2-21/ndg-linux-
essentials-2-21-working-with-
text-module-10-chapter-10-
class A: exam-answers-full-
def __init__(self, v=2) 100/#comment-14)
def set(self, v=1):
ExamTube
self.v +=v (https://examtube.org/author/e
return self.v xamtube/) on NDG Linux

a = A() Essentials 2.21 Operating


Systems Module 2 | Chapter 02
b = a
Exam Answers
b.set() (https://examtube.org/ndg-
print(a.v) linux-essentials-2-21/ndg-linux-
essentials-2-21-operating-
1 systems-module-2-chapter-02-
exam-answers/#comment-12)
0
2 Kuba on NDG Linux Essentials
2.21 Operating Systems Module
3
2 | Chapter 02 Exam Answers
7. What is the expected effect of running the following
(https://examtube.org/ndg-
code?
linux-essentials-2-21/ndg-linux-
essentials-2-21-operating-
systems-module-2-chapter-02-
class A:
exam-answers/#comment-11)
def __init__(self, v):
ExamTube
self.__a = v + 1
(https://examtube.org) on NDG
a = A(0)
Linux Essentials 2.21
print(a.__a) (https://examtube.org/ndg-
linux-essentials-2-
21/#comment-10)
The code will raise an AttributeError except
The code will print 2

The code will print 0

The code will print 1

8. Knowing that a function named fun() resides in a


module named mod , and was imported using the
following statement:

from mod import fun

choose the right to invoke the fun() function:

mod:fun()
mod::fun()

fun()
mod.fun()
9. What output will appear after running the following
snippet?

The number of all the entities residing in the math module


A string containing the fully qualified name of the module
An error message

A list of all the entities residing in the math module


10. Look at the code below:

import random
#
# Insert lines of code here.
#
print(a, b,

Which lines of code would you insert so that it is


possible for the program to output the following
result:

6 82 0

a = random.randint(0, 100)
b = random.randrange(10, 100, 3)
c = random.choice((0, 100, 3))

a = random.choice((0, 100, 3))


b = random.randrange(10, 100, 3)
c = random.randint(0, 100)

a = random.randrange(10, 100, 3)
b = random.randint(0, 100)
c = random.choice((0, 100, 3))

a = random.randint(0, 100)
b = random.choice((0, 100, 3))
c = random.randrange(10, 100, 3)
11. What is the expected result of the following code?

from datetime import datetime


datetime_1 = datetime(2019, 11, 27, 11, 27,
datetime_2 = datetime(2019, 11, 27, 0, 0, 0)
print(datetime_1 - datetime_2)

o days
0 days, 11:27:22
11:27:22
11 hours, 27 minutes, 22 seconds
12. What is the expected result of the following code?

import calendar
calendar.setfirstweekday(calendar.SUNDAY)
print(calendar.weekheader(3))

Su Mo Tu We Th We Fr Sa
Sun Mon Tue Wed Thu Fri Sat
Tu
Tue
13. what is the expected result of executing the following
code?

class A:

The code will print c


The code will raise an excepion

The code will print b

The code will print a


14. Look at the following code:

numbers [0, 2, 7, 9, 10]


# Insert line of code here.
print(list(foo))

Which line would you insert in order for the program to


produce the expected output?

[0, 4, 49, 81, 100]

foo = lambda num: num ** 2, numbers


foo = lambda num: num * 2, numbers)
foo = filter(lambda num: num ** 2, numbers)

foo = map(lambda num : num ** 2, numbers)


15. What is the expected result of executing the following
code?

class I:
def __init__(self):
self.s = 'abc'
self.i = 0
def __init__(self):
return self
def __next__(self):
if self.i == len(self.s):
raise StopIteration
v = self.s[self.i]
self.i +=1
return v
for x in I():
print(x, end='')

The code will print 210


The code will print abc

The code will print 012


The code will print cba

16. The complied Python bytecode is stored in files which


have their names ending with:

py
pyb
pc
pyc
17. Which pip command would you use to uninstall a
previously install package?

pip delete packagename


pip –uninstall packagename
pip –remove packagename
pip uninstall packagename
18. What is the excepted result of executed the following
code?

try:
raise Exception(1, 2, 3)
except Exception as e:
print(len(e.args))

The code will raise an unhandled exception

The code will print 2

The code will print 3

The code will print 1

19. What is the excepted result of executed the following


snippet?

try:
raise Exception
except BaseException:
print("a")
except Exception:
print("b")
except:
print("c")

a
An error message
1
20. What is the expected result of executing the following
code?

class A:
pass
class B(A):
pass
class C(B):
pass
print(issubclass(A, C))

The code will print Ture

The code will print 1

The code will print False


The code will raise an exception
21. If you want to fill a byte array with data read in from a
stream, which method you can use?

The read() method

The readbytes() method

The readfrom() method

The readinto() method


22. The following code:

print(float("1.3"))

will print 1.3

will print 13

will print 1,3

will raise a ValueError exception

23. The following code:

print(chr(ord('p) + 2))

will print:

q
s
r
t
24. If there are more than one except: branch after
the try: clause, we can say that:

exactly one except: block will be executed


one or more except: blocks will be executed
not more than one except: block will be executed

none of the except: blocks will be executed


25. If the class constructor is declared in the following
way:

class Class:
def __init__(self, vla = 0):
pass

which one of the assignments is invalid?

object = Class(1)
object = Class(None)
object = Class(1, 2)
object = Class()
26. What is the expected result of the following snippet?

try:
raise Exception
except:
print("c")
except BaseException:
print("a")
except Exception:
print("b")

The code will cause a syntax error

1
b
a
27. What is the expected result of the following code?

def my_fun(n):
s = '+'
for i in range(n):
s += s
yield s
for x in my_fun(2):
print(x, end='')

The code will print +

The code will print +++

The code will print ++

The code will print ++++++


28. Look at the following code:

numbers = [i*i for i in range(5)]


# Insert line of code here.
print(foo)
Which line would you insert in order for the program to
produce the expected output?

[1, 9]

foo = list(filter(lambda x: x % 2,
numbers))
foo = list(filter(lambda x: x / 2, numbers))
foo = list(map(lambda x: x % 2, numbers))
foo = list(map(lambda x: x // 2, numbers))
29. What is the expected result of executing the following
code?

def o(p):
def q():
return '*' * p
return q
r = o(1)
s = o(2)
print(r() + s())

The code will print ***

The code will print ****

The code will print *

The code will print **


30. The following statement:

from a.b import c

causes the import of:

entity a from module b from package c


entity b from module a from package c

entity c from module a from package b

entity c from module b from package a


31. The sys.stderr stream is normally associaated with:

the keyboard
the printer
a null device
the screen
32. What will be the output of the following code, located
in the p.py file?

print(__name__)

main
p.py
__main__
__p.py__
33. Assuming that the​ open() invocation has gone
successfully, the following snippet:

for x in open('file', 'rt'))


print(x)

will:

read the file character by character


read the file line by line
read the whole file at once
cause an exception
34. If a is a stream opened in read mod, the following
line:

q = s.read(1)

will read:

one line from the stream


one kilobyte from the stream
one buffer from the stream
one character from the stream
35. The following line of code:

for line in open('text.txt', 'rt'):

in invalid because open returns nothing

is invalid because open returns a non-iterable object

is invalid because open returns an iterable object


may be valid if line is a list
36. What is the expected result of the following code?

import os
os.mkdir('pictures')
os.chdir('pictures')
print(os.getcwd())

The code will print the owner of the created directory


The code will print the content of the created directory
The code will print the name of the created directory
The code will print the path to the created directory
37. Assuming that the following three files a.py
,and c.py reside in the same directory, what will be
the output produce after running the c.py file?

# file a.py
print("a", end='')
# file b.py
import a
print("b", end='')
# file c.py
print("c", end='')
import a
import b

cab
cab
abc
bac
38. What is the expected result of executing the followinf
code?

class A:
def __init__(self):
pass
a = A(1)
print(hasattr(a, 'A'))

The code will print 1


The code will raise an exception

The code will print False

The code will print True


39. The following code:

x = " \\"
print(len(x))

will print 1
will print 3

will print 2
will cause an error
40. Which of the following commands would you use to
check pip ‘s version? (Select two answers)

pip version

pip --version
pip–version

pip3 --version

5
Article Rating
 Subscribe 
 Login (https://examtube.org/wp-login.php?
redirect_to=https%3A%2F%2Fexamtube.org%2Fpe2-python-essentials-
2%2Fpe2-python-essentials-2-part-2-summary-test-answers-full-100%2F)

Be the First to Comment!

0 COMMENTS  

Copyright © 2023 ExamTube

You might also like