0% found this document useful (0 votes)
5 views11 pages

Introduction To Python

This document provides an introduction to Python, covering its definition, popularity, and installation processes. It explains Python's features, such as readability and dynamic typing, and outlines steps for installing Python using both IDLE and Visual Studio. Additionally, it details how to set up a Python virtual environment for project isolation and package management.

Uploaded by

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

Introduction To Python

This document provides an introduction to Python, covering its definition, popularity, and installation processes. It explains Python's features, such as readability and dynamic typing, and outlines steps for installing Python using both IDLE and Visual Studio. Additionally, it details how to set up a Python virtual environment for project isolation and package management.

Uploaded by

Rajasekhar G
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introduction to Python

Today, we will be discussing the following topics.

1. What is Python
2. Why is Python so popular?
3. How Python works
4. Installing Python

What is Python?
 Python was invented by Guido van Rossum, a Dutch programmer who first
released it in 1991. He created the language with a focus on readability and
simplicity, and the name was inspired by the British comedy series, Monty
Python's Flying Circus.
 Python is an interpreted, object-oriented, high-level programming language with
dynamic semantics
 The dynamic semantics is primarily characterized by its dynamic typing. This
means that the type of a variable is not fixed at compile time but is determined
at runtime based on the value assigned to it
 Python's simple, easy to learn syntax emphasizes readability
 Python uses indentation to define code blocks, unlike many other languages
that rely on curly braces or semicolons. This enforced indentation promotes
consistent and readable code, making it easier to follow the flow of logic
 Python supports modules and packages, which encourages program modularity
and code reuse.

Why is Python so popular?


1. Python is versatile and flexible

 Python is a general-purpose language, which means it can be used to create a


wide variety of applications
 For example, data scientists use Python to generate visualization and
manipulate data, while web developers use it to build dynamic websites

2. Python is simple and easy to learn

 Python's simple and clean syntax makes it an ideal language for application
development.

3. Python is open source

 Python's open-source nature has led to the development of a vast ecosystem of


libraries and frameworks. Whether you need tools for web development
(Django, Flask), data analysis (pandas, NumPy), machine learning
(TensorFlow, scikit-learn), or any other task, Python has a library for it.
How Python Works?

1. Code Editor:

You start by writing your Python code in a code editor. This is where you create your
program and save it with a .py extension

2. Source File:

Your Python code is saved in a source file with a .py extension, e.g., [Link]. Here,
you will have instructions written by a Python script for the system.

3. Compilation Stage:

The source code is converted into a byte code. Python compiler also checks the
syntax error in this step and generates a .pyc file.

4. Python Virtual Machine

Byte code that is .pyc file is then sent to the Python Virtual Machine(PVM) which is the
Python interpreter. PVM converts the Python byte code into machine-executable code
and in this interpreter reads and executes the given file line by line. If an error occurs
during this interpretation, then the conversion is halted with an error message.

5. Running Program:

In the last step, the final execution occurs where the CPU executes the machine code
and the final desired output will come as according to your program.

Installing Python – Use Python IDLE to execute a python code


Follow the instructions below to install the Python.

1. Go to company portal, search for “Python”. Search for


Python

2. Python option will be as shown below.

Click on this

3. Click on “Install” option to install the Python. Once installed, you will be able to see
“Installed” as shown below.
“Installed”

4. Go to windows search bar, type Python IDLE (Python integrated development and
learning environment) and open Python IDLE. Python IDLE will be opened as
shown below.

“Python IDLE”
5. Type the following to print Hello World as shown below.

print (“Hello World”)

6. Open any code editor and type the following and save this file as “[Link]” under
pythonexamples folder.

Note: You need to create a folder named pythonexamples.

7. To execute, python code, Go to Python IDLE  File Open, [Link] as shown


below.
8. Python file will be opened as shown below.

9. Now, press F5 to execute the python code, output will be shown as below.

Successfully, we have installed the Python and executed [Link].


Installing Python – Use Visual Studio
Follow the instructions below to use visual studio.

1. Go to company portal, search for visual studio.

“Click on Visual Studio”

2. Click on Visual Studio and install the Visual Studio. Follow the instructions.
3. Open Visual Studio. Go to File  Open Folder  Select “pythonexamples”.

4. To run the code, open terminal as shown below.


“Click on New
Terminal”

5. Terminal window will be opened as shown below.

6. Type “python [Link]”. Output will be displayed as shown below.

Successfully, we have installed visual studio and executed [Link] code.

Next, Let’s discuss how to set up Python Virtual Environment

A Python virtual environment is an isolated directory that contains a specific Python


interpreter and its own set of installed packages, separate from the global Python
installation and other projects. It functions as a self-contained workspace for a Python
project.

7. Set up python virtual environment

Type the following command.

python -m venv environment


Virtual environment will be created as below.
“Virtual
Environment”

8. Activate the environment.

Type the following to activate the environment

.\environment\Scripts\activate

“Inside your virtual environment”

9. To execute the code, type the following as shown below.

10. Installing required packages for the application

Create a [Link] as shown below.

“Click New File to


create
[Link]”
11. Installing ipykernel to work with ipynb (interactive python notebook)

Type the following in [Link] file.

ipykernel
12. To install the package type the following in the terminal.

pip install -r [Link]

13. Create [Link] file as shown below. Click on Select Kernal.

Select Kernel

14. Select “Python Environment” as shown below.

15. Select the virtual environment that you have created.


16. Type the following and execute it.

print(“Hello, World”)

Successfully, we have created the Python virtual environment.

Happy Learning!!!

You might also like