154
65.7k

310+ Problem Solving and Python Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Electrical Engineering , Civil Engineering , Mechanical Engineering .

Chapters

More MCQs
301.

What is the value stored in sys.argv[0]?

A. null
B. you cannot access it
C. the program’s name
D. the first argument
Answer» C. the program’s name
302.

How are default arguments specified in the function heading?

A. identifier followed by an equal to sign and the default value
B. identifier followed by the default value within backticks (“)
C. identifier followed by the default value within square brackets ([])
D. identifier
Answer» A. identifier followed by an equal to sign and the default value
303.

Where are the arguments received from the command line stored?

A. sys.argv
B. os.argv
C. argv
D. none of the mentioned
Answer» A. sys.argv
304.

To open a file c:\scores.txt for reading, we use                            

A. infile = open(“c:\\scores.txt”, “r”)
B. infile = open(“c:\\scores.txt”, “r”)
C. infile = open(file = “c:\\scores.txt”, “r”)
D. infile = open(file = “c:\\scores.txt”, “r”)
Answer» B. infile = open(“c:\\scores.txt”, “r”)
305.

To read the remaining lines of the file from a file object infile, we use                          

A. infile.read(2)
B. infile.read()
C. infile.readline()
D. infile.readlines()
Answer» D. infile.readlines()
306.

What is the current syntax of remove() a file?

A. remove(file_name)
B. remove(new_file_name, current_file_name,)
C. remove(() , file_name))
D. none of the mentioned
Answer» A. remove(file_name)
307.

Which of the following mode will refer to binary data?

A. r
B. w
C. +
D. b
Answer» D. b
308.

What is the difference between r+ and w+ modes?

A. no difference
B. in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+
C. in w+ the pointer is initially placed at the beginning of the file and the pointer is at the end for r+
D. depends on the operating system
Answer» B. in r+ the pointer is initially placed at the beginning of the file and the pointer is at the end for w+
309.

How do you get the name of a file from a file object (fp)?

A. fp.name
B. fp.file(name)
C. self.    name    (fp)
D. fp.    name    ()
Answer» A. fp.name
310.

Which function overloads the + operator?

A.     add    ()
B.     plus    ()
C.     sum    ()
D. none of the mentioned
Answer» A.     add    ()

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.