661. What is the type of sys.argv?
List
662. What is the value stored in sys.argv[0]?
The program’s name
663. How are default arguments specified in the function heading?
Identifier followed by an equal to sign and the default value
664. How are required arguments specified in the function heading?
Identifier
665. Which of the following data structures is returned by the functions globals() and locals()?
Dictionary
666. On assigning a value to a variable inside a function, it automatically becomes a global variable.
False
667. What happens if a local variable exists with the same name as the global variable you want to access?
The global variable is shadowed
668. Which is the most appropriate definition for recursion?
A function execution instance that calls another execution instance of the same function
669. Only problems that are recursively defined can be solved using recursion.
False
670. Which of these is false about recursion?
Recursive functions run faster than non-recursive function
671. What is tail recursion?
A function where the recursive call is the last thing executed by the function
672. Which of the following statements is false about recursion?
Every recursive function must have a return value
673. Recursion and iteration are the same programming approach.
False
674. What happens if the base condition isn’t defined in recursive programs?
Program gets into an infinite loop
675. Which of these is not true about recursion?
Recursive calls take up less memory
676. Which of these is not true about recursion?
Recursive functions are easy to debug
677. In _______________ copy, the base address of the objects are copied. In _______________ copy, the base address of the objects are not copied.
Shallow, deep
678. The nested list undergoes shallow copy even when the list as a whole undergoes deep copy.
True
679. In ____________________ copy, the modification done on one list affects the other list. In ____________________ copy, the modification done on one list does not affect the other list.
Shallow, deep
680. What is the base case in the merge sort algorithm when it is solved recursively?
A list of length one
681. Which of these definitions correctly describes a module?
Design and implementation of specific functionality to be incorporated into a program
682. Which of the following is not an advantage of using modules?
Provides a means of reducing the size of the program
683. Program code making use of a given module is called a ______ of the module.
Client
684. ______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.
Docstring
685. Which of the following is true about top-down design process?
The overall design of the program is addressed before the details
686. In top-down design every module is broken into same number of submodules.
False
687. All modular designs are because of a top-down design process.
False
688. Which of the following isn’t true about main modules?
Other main modules can import main modules
689. Which of the following is not a valid namespace?
Public namespace
690. Which of the following is false about “import modulename” form of import?
The namespace of imported module becomes part of importing module
691. Which of the following is false about “from-import” form of import?
This form of import prevents name clash
692. Which of the statements about modules is false?
In the “from-import” form of import, all identifiers regardless of whether they are private or public are imported
693. What is the order of namespaces in which python looks for an identifier?
Python first searches the local namespace, then the global namespace and finally the built-in namespace
694. What is the list comprehension equivalent for: list(map(lambda x:x**-1, [1, 2, 3]))?
[x**-1 for x in [1, 2, 3]]
695. Write a list comprehension to produce the list: [1, 2, 4, 8, 16……212].
[(2**x) for x in range(0, 13)]
696. What is the list comprehension equivalent for?
{x : x is a whole number less than 20, x is even} (including zero)
[x for x in range(0, 20) if (x%2==0)]
697. Which of the following is a python tuple?
(1, 2, 3)
698. Suppose t = (1, 2, 4, 3), which of the following is incorrect?
T[3] = 45
699. What is the data type of (1)?
Integer
700. If a=(1,2,3,4), a[1:-1] is _________
(2,3)
701. What type of data is: a=[(1,1),(2,4),(3,9)]?
List of tuples
702. Tuples can’t be made keys of a dictionary.
False
703. Which of these about a set is not true?
Immutable data type
704. Which of the following is not the correct syntax for creating a set?
Set([[1,2],[3,4]])
705. If a={5,6,7,8}, which of the following statements is false?
A[2]=45
706. If a={5,6,7}, what happens when a.add(5) is executed?
A={5,6,7}
707. Which of these about a frozenset is not true?
Mutable data type
708. The sleep function (under the time module) is used to ___________
Pause the code for the specified number of seconds
709. To include the use of functions which are present in the random library, we must use the option:
Import random
710. Which of the following functions helps us to randomize the items of a list?
Shuffle
711. What is the interval of the value generated by the function random.random(), assuming that the random module has already been imported?
[0,1)
712. Both the functions randint and uniform accept ____________ parameters.
2
713. The randrange function returns only an integer value.
True
714. What the does random.seed(3) return?
None
715. Which of the following cannot be returned by random.randrange(4)?
2.3
716. Which of the following is equivalent to random.randrange(3)?
Random.choice(range(0, 3))
717. The function random.randint(4) can return only one of the following values. Which?
Error
718. Which of the following is equivalent to random.randint(3, 6)?
3 + random.randrange(4)
719. Which of the following will never be displayed on executing print(random.choice({0: 1, 2: 3}))?
0
720. What does random.shuffle(x) do when x = [1, 2, 3]?
Shuffle the elements of the list in-place
721. Which type of elements are accepted by random.shuffle()?
Lists
722. What is the range of values that random.random() can return?
[0.0, 1.0)
723. Which of the following functions can help us to find the version of python that we are currently working on?
Sys.version
724. Which of the following functions is not defined under the sys module?
Sys.readline
725. The output of the functions len(“abc”) and sys.getsizeof(“abc”) will be the same.
False
726. To obtain a list of all the functions defined under sys module, which of the following functions can be used?
Print(dir(sys))
727. The output of the function len(sys.argv) is ____________
1
728. What does os.name contain?
The name of the operating system dependent module imported
729. What does print(os.geteuid()) print?
The user id of the current process
730. What does os.getlogin() return?
Name of the current user logged in
731. What does os.close(f) do?
Close the file descriptor f
732. What does os.fchmod(fd, mode) do?
Change permission bits of the file
733. Which of the following functions can be used to read data from a file using a file descriptor?
Os.read()
734. Which of the following returns a string that represents the present working directory?
Os.getcwd()
735. What does os.link() do?
Create a hard link
736. Which of the following can be used to create a directory?
Os.mkdir()
737. Which of the following can be used to create a symbolic link?
Os.symlink()
738. Which of the following functions does not accept any arguments?
Position
739. In which direction is the turtle pointed by default?
East
740. The command used to set only the x coordinate of the turtle at 45 units is:
Setx(45)
741. Which of the following functions returns a value in degrees, counterclockwise from the horizontal right?
Heading()
742. The function used to alter the thickness of the pen to ‘x’ units:
Turtle.width(x)
743. The process of pickling in python includes:
Conversion of a python object hierarchy into byte stream
744. To sterilize an object hierarchy, the _____________ function must be called. To desterilize a data stream, the ______________ function must be called.
Dumps(), loads()
745. Pick the correct statement regarding pickle and marshal modules.
The pickle module keeps track of the objects that have already been sterilized whereas the marshal module does not do this
746. Which of the following functions can be used to find the protocol version of the pickle module currently being used?
Pickle.default_protocol
747. Which of the following functions can accept more than one positional argument?
Pickle.dumps
748. Which of the following functions raises an error when an unpicklable object is encountered by pickler?
Pickle.picklingerror
749. The pickle module defines ______ exceptions and exports _______ classes.
3, 2
750. Which of the following cannot be pickled?
Functions which are defined at the top level of a module with lambda
751. If __getstate__() returns _______________ the __setstate__() module will not be called on pickling.
False value
752. Lambda functions cannot be pickled because:
All lambda functions have the same name, that is, <lambda>
753. The module _______________ is a comparatively faster implementation of the pickle module.
Cpickle
754. The copy module uses the ___________________ protocol for shallow and deep copy.
Pickle
755. To open a file c:\scores.txt for reading, we use _____________
Infile = open(“c:\\scores.txt”, “r”)
756. To open a file c:\scores.txt for writing, we use ____________
Outfile = open(“c:\\scores.txt”, “w”)
757. To open a file c:\scores.txt for appending data, we use ____________
Outfile = open(“c:\\scores.txt”, “a”)
758. To read two characters from a file object infile, we use ____________
Infile.read(2)
759. To read the entire remaining contents of the file as a string from a file object infile, we use ____________
Infile.read()
760. To read the next line of the file from a file object infile, we use ____________
Infile.readline()
761. To read the remaining lines of the file from a file object infile, we use ________
Infile.readlines()
762. The readlines() method returns ____________
A list of lines
763. Which are the two built-in functions to read a line of text from standard input, which by default comes from the keyboard?
Raw_input & input
764. Which one of the following is not attributes of file?
Rename
765. What is the use of tell() method in python?
Tells you the current position within the file
766. What is the current syntax of rename() a file?
Rename(current_file_name, new_file_name)
767. What is the current syntax of remove() a file?
Remove(file_name)
768. What is the use of seek() method in files?
Sets the file’s current position at the offset
769. What is the use of truncate() method in file?
Truncates the file size
770. Which is/are the basic i/o connections in file?
All of the mentioned
771. Which of the following mode will refer to binary data?
B
772. What is the pickling?
It is used for object serialization
773. What is unpickling?
It is used for object deserialization
774. What is the correct syntax of open() function?
File = open(file_name [, access_mode][, buffering])
775. Correct syntax of file.writelines() is?
776. Fileobject.writelines(sequence)
777. Correct syntax of file.readlines() is?
Fileobject.readlines( sizehint );
778. In file handling, what does this terms means “r, a”?
Read, append
779. What is the use of “w” in file handling?
Write
780. What is the use of “a” in file handling?
Append
781. Which function is used to read all the characters?
Read()
782. Which function is used to read single line from file?
Readlines()
783. Which function is used to write all the characters?
Write()
784. Which function is used to write a list of string in a file?
Writeline()
785. Which function is used to close a file in python?
Close()
786. Is it possible to create a text file in python?
Yes
787. Which of the following are the modes of both writing and reading in binary format in file?
Wb+
788. Which of the following is not a valid mode to open a file?
Rw
789. What is the difference between r+ and w+ modes?
In r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+
790. How do you get the name of a file from a file object (fp)?
Fp.name
791. Which of the following is not a valid attribute of a file object (fp)?
Fp.size
792. How do you close a file object (fp)?
Fp.close()
793. How do you get the current position within the file?
Fp.tell()
794. How do you rename a file?
Os.rename(existing_name, new_name)
795. How do you delete a file?
Os.remove(‘file’)
796. How do you change the file position to an offset value from the start?
Fp.seek(offset, 0)
797. What happens if no arguments are passed to the seek function?
Error
798. Which function overloads the + operator?
__add__()
799. Which operator is overloaded by __invert__()?
~
800. Which function overloads the == operator?
__eq__()
801. Which operator is overloaded by __lg__()?
None of the mentioned
802. Which function overloads the >> operator?
None of the mentioned
803. Let a and b be objects of class foo. Which functions are called when print(a + b) is executed?
B) __add__(), __str__()
804. Which operator is overloaded by the __or__() function?
|
805. Which function overloads the // operator?
__floordiv__()
806. _____ represents an entity in the real world with its identity and behaviour.
An object
807. _____ is used to create an object.
Constructor
808. What is setattr() used for?
To set an attribute
809. What is getattr() used for?
C) to access the attribute of the object
810. What is instantiation in terms of oop terminology?
Creating an instance of class
811. The assignment of more than one function to a particular operator is _______
Operator overloading
812. Which of the following is not a class method?
Non-static
813. What are the methods which begin and end with two underscore characters called?
E) special methods
814. Special methods need to be explicitly called during object creation.
False
815. What is hasattr(obj,name) used for?
To check if an attribute exists or not
816. What is delattr(obj,name) used for?
To delete an attribute
817. __del__ method is used to destroy instances of a class.
F) true
818. What does print(test.__name__) display (assuming test is the name of the class)?
Test
819. Which of the following best describes inheritance?
G) ability of a class to derive members of another class as a part of its own definition
820. Which of the following statements is wrong about inheritance?
Private members of a class can be inherited and accessed