The print function asks LWOS to print some text to the shell. The function definition is:
def print(text):
- text is the message to print in the shell (type is string).
This function does not return anything.
For example, suppose we called:
print("Hello World!")
As with all function calls, the argument will be evaluated first and added to the top of the Values Stack. Then Python updates the LWOS Python state as follows:
- Python
- Status: "BLOCKED",
- System Call
- Type: "SHELL",
- Mode: "WRITE"
- Data: "101 Park Street, Seattle"
- Values Stack:
- "Hello World!"
- [ ]
- Expression Stack:
- [ ]
- print("Hello World!")
Python -> Status is now "BLOCKED." This prompts LWOS to inspect Python -> System Call. When Python -> System Call -> Type is "SHELL" and mode is "WRITE," LWOS is going to prints some text on the shell. LWOS appends Python -> IO -> Data, which is "101 Park Street, Seattle," to Shell -> Buffer. LWOS then asks the display to render the updated shell buffer. LWOS then resumes the Python process by updating Python -> Status to "SYSCALL_COMPLETE."
At this point, the LWOS state is:
- Hostname: "computer_1"
- Command: "python"
- Status: "IDLE"
- Shell
- buffer: "> python serve_books.py
101 Park Street, Seattle
- buffer: "> python serve_books.py
- Python
- Status: "SYSCALL_COMPLETE",
- System Call
- Type: "SHELL",
- Mode: "WRITE"
- Data: "101 Park Street, Seattle"
Python then resumes evaluation of the print function call. Python pops the function call argument from the Values Stack and pushes None to the top of the Values Stack (nothing is returned). Python also updates Python -> Status to "RUNNING" and pops the Expression Stack. The print function call is now complete.
Please write a Python statement that asks LWOS to print "It is a good day to code!" to the shell.
Inside the print function, Python updates the LWOS Python property to:
- Python
- State: "BLOCKED",
- System Call
- Type: "_________"
- Mode: "WRITE"
- Data: "It is a good day to code!"
Please fill in the blank.
Comments
Please log in to add comments