Assuming that the following three files: a.py, b.py, and c.py reside in the same directory, what will be the output produced after running the c.py file?
# file a.py print("a", end='') # file b.py import a print("b", end='') # file c.py print("c", end='') import a import b
- cba
- cab
- bc
- bac
Explanation: Executing the file c.py results in the following:
- the print(“c”, end=”) function prints c to the screen;
- the import a statement imports the print(“a”, end=”) function, which prints a to the screen;
- the import b statement imports the print(“b”, end=”) function, which prints b to the screen;
- The file b.py also contains the import a statement, but this module has already been imported into the mainspace. When a particular module is imported, its contents are executed once only. Note that the order of imports does not matter here.
More Questions: Python Essentials 2 (PE2) Course Final Test
Please login or Register to submit your answer