Certified Associate in Python Programming v1.0

Page:    1 / 5   
Exam contains 73 questions

Is it possible to safely check if a class/object has a certain attribute?

  • A. yes, by using the hasattr attribute
  • B. yes, by using the hasattr ( ) method
  • C. yes, by using the hassattr ( ) function
  • D. no, it is not possible


Answer : B

Reference:
https://stackoverflow.com/questions/610883/how-to-know-if-an-object-has-an-attribute-in-python

The first parameter of each method:

  • A. holds a reference to the currently processed object
  • B. is always set to None
  • C. is set to a unique random value
  • D. is set by the first argument's value


Answer : D

Reference:
https://pythontips.com/2013/08/07/the-self-variable-in-python-explained/

The simplest possible class definition in Python can be expressed as:

  • A. class X:
  • B. class X: pass
  • C. class X: return
  • D. class X: { }


Answer : A

Reference:
https://docs.python.org/3/tutorial/classes.html

If you want to access an exception object"™s components and store them in an object called e, you have to use the following form of exception statement:

  • A. except Exception (e) :
  • B. except e= Exception :
  • C. except Exception as e:
  • D. such an action is not possible in Python


Answer : C

Reference:
https://stackoverflow.com/questions/32613375/python-2-7-exception-handling-syntax

A variable stored separately in every object is called:

  • A. there are no such variables, all variables are shared among objects
  • B. a class variable
  • C. an object variable
  • D. an instance variable


Answer : A

Reference:
https://dev.to/ogwurujohnson/distinguishing-instance-variables-from-class-variables-in-python-81

There is a stream named s open for writing. What option will you select to write a line to the stream?

  • A. s. write ("Hello\n")
  • B. write (s, "Hello")
  • C. s.writeln ("Hello")
  • D. s. writeline ("Hello")


Answer : A

Reference:
https://en.wikibooks.org/wiki/Python_Programming/Input_and_Output

You are going to read just one character from a stream called s. Which statement would you use?

  • A. ch = read (s, 1)
  • B. ch= s.input (1)
  • C. ch= input (s, 1)
  • D. ch= s.read (1)


Answer : D

Reference:
https://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user

What can you deduce from the following statement? (Select two answers)


  • A. str is a string read in from the file named file.txt
  • B. a newline character translation will be performed during the reads
  • C. if file. txt does not exist, it will be created
  • D. the opened file cannot be written with the use of the str variable


Answer : AD

The following class hierarchy is given. What is the expected out of the code?


  • A. BB
  • B. CC
  • C. AA
  • D. BC


Answer : D

Python"™s built in function named open () tries to open a file and returns:

  • A. an integer value identifying an opened file
  • B. an error code (0 means success)
  • C. a stream object
  • D. always None


Answer : A

Reference:
https://www.programiz.com/python-programming/file-operation

Which of the following words can be used as a variable name? (Select two valid names)

  • A. for
  • B. True
  • C. true
  • D. For


Answer : AB

Reference:
https://www.pluralsight.com/guides/python-basics-variables-assignment

Python strings can be "glued" together using the operator:

  • A. .
  • B. &
  • C. _
  • D. +


Answer : D

Reference:
https://docs.python.org/3/tutorial/introduction.html

(Select two answers)

  • A. can be used as an identifier
  • B. is defined by Python"™s lexis
  • D. cannot be used in the user"™s code


Answer : BC

Reference:
https://www.programiz.com/python-programming/keywords-identifier

How many stars (*) does the snippet print?


  • A. the code is erroneous
  • B. five
  • C. four
  • D. two


Answer : A

Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Select two answers)
Expected output:
1 2 3
Code:


  • A. c, b, a = b, a, c
  • B. c, b, a = a, c, b
  • C. a, b, c = c, a, b
  • D. a, b, c = a, b, c


Answer : AC

Page:    1 / 5   
Exam contains 73 questions

Talk to us!


Have any questions or issues ? Please dont hesitate to contact us

Certlibrary doesn't offer Real Microsoft Exam Questions.
Certlibrary Materials do not contain actual questions and answers from Cisco's Certification Exams.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Certlibrary. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.