Skip to content
  • Home
  • CCNA Labs
    • CCNA 1 LAB Activities (v6 & v7)
    • CCNA 2 LAB Activities (v6 & v7)
    • CCNA 3 LAB Activities (v6 & v7)
    • CCNA 4 Lab Activities
  • Linux
    • Linux Unhatched
    • Linux Essentials 2.0
    • Linux Essentials
    • Introduction to Linux I
    • Introduction to Linux II
  • Programming
    • PCAP – Programming Essentials in Python
    • CLA – Programming Essentials in C
    • CPA Programming Essentials in C++
  • About
    • Contact Us
    • Privacy Policy

CCNA 7 Exam Answers 2023

Go with our CCIE, Passed 100%

  • ITE
    • ITE - IT Essentials v7.0
    • ITE - IT Essentials v6.0
      • IT Essentials Lab 2019
    • ITE v5.0 Exam
    • Virtual Activity Laptop
    • Virtual Activity Desktop
  • NE
    • MF
  • CCNA
    • CCNA1
      • CCNA1 v7.0 – ITN
      • CCNA1 v6.0
    • CCNA2
      • CCNA2 v7.0 – SRWE
      • CCNA2 v6.0
    • CCNA3
      • CCNA3 v7.0 – ENSA
      • CCNA3 v6.0
    • CCNA4
      • CCNA4 v6.0
  • Cyber-Security
    • ITC – Introduction to Cybersecurity 2.1 (Level 1)
    • CE – Cybersecurity Essentials 1.1 (Level 2)
    • CCNA CyberOps 1.1 (Level 3)
  • Security
    • CCNA Security v2
  • DevNet
  • CCNA PT Lab 2023

PCAP – Programming Essentials in Python Quizzes Summary Test 2 Answers

Last Updated on May 20, 2021 by Admin

PCAP – Programming Essentials in Python Quizzes Summary Test 2 Answers

  1. Knowing that a function named f() resides in a module named m, and was imported using the following statement

     

       from mod import fun

     

    choose the right way to invoke it:

    • fun()
    • mod.fun()
    • mod::fun()
    • mod:fun()
  2. What output will appear after running the following snippet?

     

       import math

       print(dir(math))

    • an error message
    • a string containing the fully qualified name of the module
    • a list of all the entities residing in the math module
    • the number of all the entities residing in the math module
  3. The compiled Python bytecode is stored in files having names ending with:

    • py
    • pyb
    • pc
    • pyc
  4. Assuming that all three files, a.py, b.py, and c.py reside in the same folder, what will be the output produced by 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

    • cba
    • abc
    • bac
    • cab
  5. What will be the output of the following code, located in file p.py?

     

       print(__name__)

    • p.py
    • main
    • __p.py__
    • __main__
  6. 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 b from package a
    • entity c from module a from package b
  7. If there are more than one except: branches after the try:, we can say that:

    • one or more of the try: blocks will be executed
    • none of the try: blocks will be executed
    • not more than one try: block will be executed
    • exactly one of the try: blocks will be executed
  8. What will be the output of the following snippet?   try:      raise Exception   except BaseException:

          print(“a”)

       except Exception:

          print(“b”)

       except:

          print(“c”)

    • c
    • b
    • it will cause an error
    • a
  9. The following line of code:

     

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

    • is valid as open returns an iterable object
    • is invalid as open returns a non-iterable object
    • is invalid as open returns nothing
    • may be valid if line is a list
  10. What will be the output of the following snippet?

       try:

          raise Exception

       except:

          print(“c”)

       except BaseException:

          print(“a”)

       except Exception:

          print(“b”)

    • a
    • c
    • b
    • it will cause an error
  11. The following statement:

     

    assert var != 0

    • will stop the program when var == 0
    • is erroneous
    • has no effect
    • will stop the program when var != 0
  12. The following code prints:

     

       x = “\\\\”

       print(len(x))

    • 2
    • 1
    • 3
    • the code will cause an error
  13. The following code prints:

     

       x = “\\\”

       print(len(x))

    • 3
    • the code will cause an error
    • 1
    • 2
  14. The following code prints:

       print(chr(ord(‘p’) + 2))

    • s
    • t
    • q
    • r
  15. The following code:

        print(float(“1.3”))

    • raises a ValueError exception
    • prints 13
    • prints 1,3
    • 1.3
  16. If the class’s constructor is declared as below, which one of the assignments is invalid?

        class Class:

           def __init__(self,val=0):

               pass

    • object = Class(None)
    • object = Class(1)
    • object = Class()
    • object = Class(1,2)
  17. What will be output of the following code?

       class A:

          def __init__(self,v = 2):

             self.v = v

          def set(self,v = 1):

             self.v += v

              return self.v

       a = A()

       b = a

       b.set()

       print(a.v)

    • 0
    • 3
    • 1
    • 2
  18. What will be output of the following code?

        class A:

            A = 1

            def __init__(self):

               self.a = 0

        print(hasattr(A,’a’))

    • 1
    • False
    • 0
    • True
  19. What will be the result of executing the following code?

       class A:

          pass

       class B(A):

          pass

       class C(B):

          pass

       print(issubclass(A,C))

    • it will print False
    • it will print True
    • it will print 1
    • it will raise an exception
  20. The sys.stderr stream is normally associated with:

    • the keyboard
    • a null device
    • the screen
    • the printer
  21. What will be the effect of running the following code?

       class A:

          def __init__(self,v):

              self.__a = v + 1

       a = A(0)

       print(a.__a)

    • it will print 1
    • it will print 2
    • it will raise an AttributeError exception
    • it will print 0
  22. What will be the result of executing the following code?

       class A:

          def __init__(self):

             pass

       a = A(1)

       print(hasattr(a,’A’))

    • it will print True
    • it will raise an exception
    • it will print False
    • it will print 1
  23. What will be the result of executing the following code?

       class A:

          def a(self):

             print(‘a’)

       class B:

          def a(self):

             print(‘b’)

       class C(B,A):

          def c(self):

             self.a()

       o = C()

       o.c()

    • it will print c
    • it will raise an exception
    • it will print b
    • it will print a
  24. What will be the result of executing the following code?

       try:

          raise Exception(1,2,3)

       except Exception as e:

          print(len(e.args))

    • it will print 2
    • it will print 1
    • it will raise an unhandled exception
    • it will print 3
  25. What will be the result of executing the following code?

       def I(n):

          s = ‘+’

          for i in range(n):

             s += s

             yield s

       for x in I(2):

          print(x,end=”)

    • it will print ++
    • it will print ++++++
    • it will print +
    • it will print +++
  26. What will be the result of executing the following code?

       class I:

          def __init__(self):

             self.s = ‘abc’

             self.i = 0

          def __iter__(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=”)

    • 012
    • abc
    • cba
    • 210
  27. What will be the result of executing the following code?

       def o(p):

          def q():

             return ‘*’ * p

          return q

       r = o(1)

       s = o(2)

       print(r() + s())

     

    • it will print ****
    • it will print **
    • it will print ***
    • it will print *
  28. If s is a stream opened in read mode, the following line will:

       q = s.read(1)

    • read 1 character from the stream
    • read 1 kilobyte from the stream
    • read 1 line from the stream
    • read 1 buffer from the stream
  29. Assuming that the open() invocation has gone successfully, the following snippet will:

       for x in open(‘file’,’rt’):

          print(x)

    • read the file character by character
    • cause an exception
    • read the whole file at once
    • read the file line by line
  30. If you want to fill a byte array with data read in from a stream, you’d use:

    • the readinto() method
    • the read() method
    • the readbytes() method
    • the readfrom() method
  • CCNA1 v7
  • CCNA2 v7
  • CCNA3 v7
System Test Exam Answers
Modules 1 – 3 Exam Answers
Modules 4 – 7 Exam Answers
Modules 8 – 10 Exam Answers
Modules 11 – 13 Exam Answers
Modules 14 – 15 Exam Answers
Modules 16 – 17 Exam Answers
Practice Final – ITN Answers
Course Feedback
ITN Practice PT Skills Assessment (PTSA)
Final Exam Answers
Modules 1 – 4 Exam Answers
Modules 5 – 6 Exam Answers
Modules 7 – 9 Exam Answers
Modules 10 – 13 Exam Answers
Modules 14 – 16 Exam Answers
ITN Practice Skills Assessment – PT Answers
SRWE Practice Skills Assessment – PT Part 1 Answers
SRWE Practice Skills Assessment – PT Part 2 Answers
SRWE Hands On Skills Exam Answers
SRWE Practice Final Exam Answers
SRWE Final Exam Answers 
Modules 1 – 2 Exam Answers
Modules 3 – 5 Exam Answers
Modules 6 – 8 Exam Answers
Modules 9 – 12 Exam Answers
Modules 13 – 14 Exam Answers
ITN Practice PT Skills Assessment (PTSA) Answers
SRWE Practice PT Skills Assessment (PTSA) – Part 1 Answers
SRWE Practice PT Skills Assessment (PTSA) – Part 2 Answers
ENSA Practice PT Skills Assessment (PTSA) Answers
ENSA Hands On Skills Exam Answers
Practice Final – ENSA Answers
ENSA Final Exam Answers
CCNA Certification Practice Exam Answers

Copyright © 2023 PressExam.