You are on page 1of 2

17CS61

Lab # 12
Interacting with Basics of OS through Python shell

EXERCISE

1. Print ("%s: %s" % (threadName, time.ctime(time.time()) )). Explain


functioning and working of above line used in manual.

Print command contains two arguments:

 ThreadName to print the name of the thread which is passed to the function
‘print_time’.
 Time.ctime(time.time())
 time() is a method of time module which is returning the number of
seconds passed since epoch.
 ctime() is also a method of time module which is taking the seconds
returned by time.time() and is printing the a string representing local
time.

2. Using thread module, demonstrate one example of threading.


17CS61

3. The second argument (the *mode*) in open method determines how the
file gets opened. What ‘ru’ mode in open function denotes?

Opening a file with the mode 'U' or 'rU' will open a file for reading in universal newline
mode.

4. What is meant by single and multi-threading? Which category does python


python belong to?

 Single threaded processes contain the execution of instructions in a single


sequence.
 Multithreaded processes allow execution of multiple parts of a program at the
same time.
Python is single threaded, but multithreaded processes are also possible. Both are
possible.

5. What is meant by OS dependent module?

The design of all built-in operating system dependent modules of Python is such that as
long as the same functionality is available, it uses the same interface. 

You might also like