You are on page 1of 27

Python Environment Setup and

Essentials

Prepared by
Narasimha N
Technical Trainer
Outline
◈ Installation of Anaconda
◈ Data types with Python
◈ Basic Operators
◈ Functions
Installation of Anaconda
Visit the Anaconda website:
Go to the Anaconda website at
https://www.anaconda.com/products/individual and navigate to
the individual edition download page.
Choose the correct installer:
Make sure to download the installer
appropriate for your operating system (Windows, macOS, or
Linux). Anaconda supports both 32-bit and 64-bit systems.
Contd..
Contd..
o Download the installer: Click on the download link for the version
of Anaconda you want to install. Wait for the download to complete.

o Run the installer: Once the installer is downloaded, locate it on your


computer and run it. The installer file should have a filename like
"Anaconda3-<version>-<platform>.exe" for Windows, or
"Anaconda3-<version>-<platform>.pkg" for macOS.
Contd..
o Follow the installation wizard: The installation wizard will guide
you through the installation process. You can choose the default
options or customize the installation according to your preferences.

o Read and accept the license agreement: During the installation


process, you will be presented with a license agreement. Read
through it and accept the terms to proceed with the installation.
Contd..

o Select the installation location: Choose the location where you want
to install Anaconda. By default, it will be installed in your user
directory.

o Choose whether to add Anaconda to your system's PATH: It is


recommended to check the option to add Anaconda to your system's
PATH. This allows you to use Anaconda from the command line or
terminal without having to provide the full path to the Anaconda
executables.
Contd..
o Complete the installation: Once you've configured the installation
options, click on the "Install" button to begin the installation process.
Wait for the installation to finish.

o Verify the installation: After the installation is complete, you can


verify it by opening a new terminal or command prompt window and
typing "conda --version" or "conda info" (without quotes). If
Anaconda is properly installed, you should see information about the
conda package manager.
Data types with Python
• Numeric Types:
• int: Integers, e.g., 1, 2, -3.
• float: Floating-point numbers, e.g., 3.14, -2.5.
• complex: Complex numbers, e.g., 2 + 3j, -1.5 + 0.5j.

• Sequence Types:
• str: Strings, e.g., "hello", 'world'.
• list: Ordered, mutable sequences, e.g., [1, 2, 3], ['a', 'b', 'c'].
• tuple: Ordered, immutable sequences, e.g., (1, 2, 3), ('a', 'b', 'c').
Contd..
• Mapping Type:
• dict: Key-value pairs, e.g., {'name': 'John', 'age': 30}.
• Set Types:
• set: Unordered collection of unique elements, e.g., {1, 2, 3}, {'a',
'b', 'c'}.
• frozenset: Immutable version of set, e.g., frozenset({1, 2, 3}).
• Boolean Type:
• bool: Represents truth values (True or False).
• None Type:
• None: Represents the absence of a value or null.
Basic Operators
• Arithmetic Operators:
• Addition: +
• Subtraction: -
• Multiplication: *
• Division: /
• Floor Division: //
• Modulus: %
• Exponentiation: **
Contd..
• Assignment Operators:
• Assignment: =
• Addition Assignment: +=
• Subtraction Assignment: -=
• Multiplication Assignment: *=
• Division Assignment: /=
• Modulus Assignment: %=
• Exponentiation Assignment: **=
Contd..
• Comparison Operators:
• Equal to: ==
• Not equal to: !=
• Greater than: >
• Less than: <
• Greater than or equal to: >=
• Less than or equal to: <=
Contd..
• Logical Operators:
• Logical AND: and
• Logical OR: or
• Logical NOT: not
Contd..
• Bitwise Operators:
• Bitwise AND: &
• Bitwise OR: |
• Bitwise XOR: ^
• Bitwise NOT: ~
• Left Shift: <<
• Right Shift: >>
Contd..
• Membership Operators:
• In: Checks if a value exists in a sequence.
• Not in: Checks if a value does not exist in a sequence.
Contd..
• Identity Operators:
• is: Checks if two variables refer to the same object.
• is not: Checks if two variables do not refer to the same object.
Functions in Python
In Python, functions are blocks of reusable code that perform a specific
task. They help in organizing code, promoting reusability, and making
the code modular.
• Built-in Functions: These functions are built into the Python
language and are available for use without any import or additional
setup. Examples include print(), len(), input(), type(), etc.
Contd..
• User-Defined Functions: These functions are defined by the user to
perform specific tasks. They are created using the def keyword,
followed by the function name, parameters (if any), and a block of
code.
Contd..
• Function with Parameters:
Functions can accept parameters, which are variables
passed into the function. These parameters can be used within the
function's code to perform operations.
Contd..
• Function with Return Value:
Functions can return a value using the return
statement. The returned value can be stored in a variable or used directly in
the code.
Contd..
• Recursive Functions:
Recursive functions are functions that call themselves
within their own definition. They are useful for solving problems that
can be broken down into smaller, similar subproblems.
Contd..
• Lambda Functions:
Lambda functions, also known as anonymous
functions, are one-line functions without a name. They are typically
used for simple, single-expression tasks.

You might also like