Keyword

Result: 213 questions

what gets printed? Assuming python version 2.x

print type(1/2)
Quiz

what gets printed? Assuming python version 3.x

print (type(1/2))
Quiz

If PYTHONPATH is set in the environment, which directories are searched for modules?

A) PYTHONPATH directory

B) current directory

C) home directory

D) installation dependent default path
Quiz

In python 2.6 or earlier, the code will print error type 1 if accessSecureSystem raises an exception of either AccessError type or SecurityError type

try:
  accessSecureSystem()
except AccessError, SecurityError:
  print "error type 1"

continueWork()
Quiz

Assuming python 2.6 what gets printed?

f = None

for i in range (5):
    with open("data.txt", "w") as f:
        if i > 2:
            break

print f.closed
Quiz

What gets printed?

Assume Python 2

print "hello" 'world'
Quiz

Assuming the filename for the code below is /usr/lib/python/person.py
and the program is run as:

python /usr/lib/python/person.py 

What gets printed?

class Person:
    def __init__(self):
        pass

    def getAge(self):
        print __name__

p = Person()
p.getAge()
Quiz

Asume Python 2
How do you create a package so that the following reference will work?

p = mytools.myparser.MyParser()
Quiz

Assuming python 2.x, what gets printed?

x = 0
y = 1

a = cmp(x,y)
if a < x:
    print "a"
elif a == x:
    print "b"
else:
    print "c"
Quiz

What gets printed (with python version 2.X) assuming the user enters the following at the prompt?
#: foo

a = input("#: ")

print a
Quiz

What gets printed (with python version 3.X) assuming the user enters 'foo' at the prompt?

a = input("#: ")

print (a)
Quiz

What is the type of b(Python 3)?

a = -1
b = a ** 0.5

 

Quiz

What is the type of a(Python 3)?

a = 10/5

 

Quiz

In the Django Template Language, the {% ... %} notation provides for the inclusion of arbitrary Python code, with structures like 'for', 'if', etc.

Quiz

Is There A Switch Or Case Statement In Python? If Not Then What Is The Reason For The Same?

Answer:

No, Python does not have a Switch statement, but you can write a Switch function and then use it.

View

What Are The Optional Statements That Can Be Used Inside A <Try-Except> Block In Python?

Answer:

There are two optional clauses you can use in the <try-except> block.

  • The <else> clause
    • It is useful if you want to run a piece of code when the try block doesn’t create any exception.
  • The <finally> clause
    • It is useful when you want to execute some steps which run, irrespective of whether there occurs an exception or not.
View

What Are Different Methods To Copy An Object In Python?

Answer:

There are two ways to copy objects in Python.

  • copy.copy() function
    • It makes a copy of the file from source to destination.
    • It’ll return a shallow copy of the parameter.
  • copy.deepcopy() function
    • It also produces the copy of an object from the source to destination.
    • It’ll return a deep copy of the parameter that you can pass to the function.
View

What Is The Purpose Of Doc Strings In Python?

Answer:

In Python, documentation string is popularly known as doc strings. It sets a process of recording Python functions, modules, and classes.

View

How Do You Debug A Program In Python? Is It Possible To Step Through Python Code?

Answer:

Yes, we can use the Python debugger (<pdb>) to debug any Python program. And if we start a program using <pdb>, then it let us even step through the code.

View

List Down Some Of The PDB Commands For Debugging Python Programs?

Answer:

Here are a few PDB commands to start debugging Python code.

  • Add breakpoint – <b>
  • Resume execution – <c>
  • Step by step debugging – <s>
  • Move to next line – <n>
  • List source code – <l>
  • Print an expression – <p>
View

© 2017 QuizBucket.org