General Information Edit
The Python Interactive Shell is an interactive interpreter that can execute Python commands without saving it to a file.
Starting it EditThe Interactive Shell can be started with the bash-command
python -i FILENAME.py
Use it as a calculator Edit
As explained above, the Interactive Shell can execute Python commands. Same goes for simple calculations. Here are a few examples:
>>> 1 + 3 4 >>> 12 / 4 3 >>> 12 % 4 0
Logical expressions Edit
We can do the exact same thing with logical expressions, e.g.:
>>> True and (not False) True >>> (False or (not (False and True))) and True True
File operations Edit
As we can open, write and read files by executing a script, we can also do that in this environment.
>>> f = open('test.txt', 'w') >>> f.write('Hello ') >>> f.write('World!') >>> f.close() >>> g = open('test.txt', 'r') >>> for entry in g: ... print(entry) ... Hello World! >>> g.close() >>> import os >>> os.remove('text.txt')
For further explanations about the usage of files, please look at Files.