Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

PYTHON QUESTIONS : PART 12

Which of these is a private data field?

def demo:

    def __init__(self):

        __a=1

        self.__b=1

        self.__c=1

        __d__=1

__a

__b

__c__

__d__

SHOW ANSWER

Which of the following is not an exception handling keyword in Python?

try

except

accept

finally

SHOW ANSWER

What is the output of the code shown below?

g=(i for i in range(5))

print(type(g))

class<'loop'>

class <'iteration'>

class <'range'>

class <'generator'>

SHOW ANSWER

What is the output of the code shown below?

Ist = [1,2,3]

Ist[3]

NameError

ValueError

IndexError

TypeError

SHOW ANSWER

The output of the code shown below is:

int('65.43')

ImportError

ValueError

TypeError

NameError

SHOW ANSWER

What is the output of the code shown below?

def getMonth(m):

    if m>1 or m<12:

        raise ValueError('invalid')

        print(m)

getMonth(6)

ValueError

No answer

6

ValueError("Invalid")

SHOW ANSWER

Which of the following statements is true?

The standard exceptions are automatically imported into Python programs

All raised standard exceptions must be handled in Python

When there is a deviation from the rules of a programming language, a semantic error is thrown

If any exception is thrown in try block, else block is executed 

SHOW ANSWER

Which of the following is not a standard exception in Python?

NameError

IOError

AssignmentError

ValueError 

SHOW ANSWER

Syntax errors are also known as parsing errors. Is this statement true or false?

True

False

SHOW ANSWER

How many except statements can a try-except block have?

zero

one

more than one

more than zero

SHOW ANSWER

When will the else part of try-except-else be executed?

always

when an exception occurs

when no exception occurs

when an exception occurs in to except block 

SHOW ANSWER

Is the following code valid?

try:

          # Do something

except:

          # Do something

else:

          # Do something

no, there is no such thing as else

no, else cannot be used with except

no, else must come before except

yes 

SHOW ANSWER

What is the output of the following code?

def foo():

          try:

                   return 1

          finally:

                   return 2

k=foo()

print(k)

1

2.

3

error, there is more than one return statement in a single try-finally block

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in