# Certified Associate in Python Programming (PCAP) Quiz Questions and Answers

### What is the output of print (0.1 + 0.2)?

• none of the above

Explanation :

Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3.

### If a={5,6,7}, what happens when a.add(5) is executed?

• a={5,6,7}

Explanation :

There exists add method for set data type. However 5 isn't added again as set consists of only non-duplicate elements and 5 already exists in the set. Execute in python shell to verify.

### Which of these about a set is not true?

• Allows duplicate values
• Immutable data type

Explanation :

A set is a mutable data type with non-duplicate, unordered values, providing the usual mathematical set operations.

### What is the result of round(0.5) - round(-0.5)?

• 0

Explanation :

Python rounds off numbers away from 0 when the number to be rounded off is exactly halfway through.

### Study the following program: try: if '2' != 2: raise "ERROR " else: print( "ERROR does not exist ") except "JavaTpoint ": print ( "ERROR does exist ") What will be the output of this statement?

• invalid code

Explanation :

A new exception class must inherit from a BaseException, and there is no such inheritance here.