1. E stands for Entry in LEGB Rule.

A) True

B) False

Correct Answer: False

Explanation : The letters in the acronym LEGB stand for Local, Enclosing, Global, and Built-in scopes.


2. What is a variable defined outside a function called?

A) A static variable

B) A global variable

C) A local variable

D) An automatic variable

Correct Answer: A global variable


3. Which of the following functions clears the regular expression cache?

A) re.sub()

B) re.pos()

C) re.purge()

D) re.subn()

Correct Answer: re.purge()


4. What does os.close(f) do?

A) terminate the process f

B) terminate the process f if f is not responding

C) close the file descriptor f

D) return an integer telling how close the file pointer is to the end of file

Correct Answer: close the file descriptor f

Explanation : To close a “file object” returned by the built-in function open() or by popen() or fdopen(), use its close() method.


5. Which of the following can be used to create a directory?

A) os.mkdir()

B) os.creat_dir()

C) os.create_dir()

D) os.make_dir()

Correct Answer: os.mkdir()

Explanation : os.mkdir() Creates a directory named path with numeric mode mode. If the directory already exists, FileExistsError is raised. If a parent directory in the path does not exist, FileNotFoundError is raised.