Unit 1 Python
Unit 1 Python
Python programming cycle is a little bit different from the traditional programming
cycle because, unlike the traditional programming cycle, python DO NOT have
compile or link steps because of this behaviour Python programs run immediately
after changes are made. . The programming Cycle for Python is in rapid prototyping.
In simple terms, the python development cycle do not have compiling and linking
steps, unlike the traditional programming cycle.
Answer to the question , What is programming cycle for Python can be framed as given
below:
Interactive mode
Script mode
Interactive Mode
Interactive mode, also known as the REPL provides us with a quick way of
running blocks or a single line of Python code. The code executes via the
Python shell, which comes with Python installation. Interactive mode is
handy when you just want to execute basic Python commands or you are
new to Python programming
To access the Python shell, open the terminal of your operating system and
then type "python". Press the enter key and the Python shell will appear.
This is the same Python executable you use to execute scripts, which
comes installed by default on Mac and Unix-based operating systems.
C:\Windows\sys
tem32>python
>>>
The >>> indicates that the Python shell is ready to execute and send your
commands to the Python interpreter. The result is immediately displayed on
the Python shell as soon as the Python interpreter interprets the command.
To run your Python statements, just type them and hit the enter key. You
will get the results immediately, unlike in script mode. For example, to print
the text "Hello World", we can type the following:
>>> 10
10
>>> print(5 * 20)
100
>>> "hi" * 5
'hihihihihi'
>>>
Pros and Cons of Interactive Mode
The following are the advantages of running your code in interactive mode:
1. Helpful when your script is extremely short and you want immediate
results.
2. Faster as you only have to type a command and then press the enter
key to get the results.
3. Good for beginners who need to understand Python basics.
The following are the disadvantages of running your code in the interactive
mode: