0% found this document useful (0 votes)
4 views2 pages

Python Basic

Uploaded by

jadhavbs16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Basic

Uploaded by

jadhavbs16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Key Features of Python:

Easy to Read and Write: Python's syntax is clear and concise, making it easy for
beginners to learn and write code.
Interpreted Language: Python code is executed line by line, which makes debugging
easier.
Dynamically Typed: Variables in Python do not need to be declared with a specific
data type. Python automatically assigns the type at runtime.
Extensive Standard Library: Python comes with a large standard library that
provides tools suited to many tasks, such as web development, data analysis,
machine learning, and more.
Cross-Platform: Python runs on various platforms like Windows, macOS, Linux, etc.,
making it highly portable.
Object-Oriented: Python supports object-oriented programming (OOP), allowing for
concepts like classes, inheritance, and encapsulation.
Interactive Mode: Python has an interactive mode that allows for testing code
snippets quickly.
Community Support: Python has a large and active community, which contributes to
its extensive documentation and a wide range of libraries and frameworks.

Python can be used in two modes: interactive mode and non-interactive mode.

1. Interactive Mode:
Python Shell/REPL (Read-Eval-Print Loop): This is an interactive environment where
you can enter Python commands one at a time, and they are executed immediately. You
get immediate feedback as the output of each command is displayed right after it's
entered.
Use Cases: This mode is ideal for testing small code snippets, experimenting with
functions, or debugging. It’s very useful for learning and quick prototyping.
How to Use:
Open a terminal/command prompt.
Type python or python3 and press Enter.
You will see the Python prompt (>>>), where you can type your commands.
Example:
python
Copy code
>>> print("Hello, World!")
Hello, World!
>>> 2 + 3
5
2. Non-Interactive Mode:
Script Execution: In non-interactive mode, Python code is written in a script file
(with a .py extension), and the entire script is executed at once.
Use Cases: This mode is used for running complete programs, automating tasks, or
deploying applications. It’s more suited for developing larger applications or
scripts that need to be run multiple times.
How to Use:
Write your Python code in a text editor and save it as a .py file.
In the terminal/command prompt, navigate to the directory containing your script.
Run the script by typing python script_name.py or python3 script_name.py.
Example:
Create a file called hello.py with the following content:
python
Copy code
print("Hello, World!")
Run it in the terminal:
bash
Copy code
$ python hello.py
Hello, World!
Key Differences:
Immediate Feedback: Interactive mode provides immediate feedback, while non-
interactive mode does not.
Persistence: In interactive mode, once the session is closed, the code cannot be
retrieved unless saved. In non-interactive mode, code is saved in scripts and can
be executed repeatedly.
Suitability: Interactive mode is great for testing and experimenting, while non-
interactive mode is ideal for running full programs and automation.
Both modes have their advantages depending on the task at hand, and Python
developers often switch between them based on their needs.

You might also like