0% found this document useful (0 votes)
23 views34 pages

Python Introduction DataTypes Variables

The document provides an overview of Python programming, detailing its history, key concepts, applications, and installation processes for different operating systems. It explains Python's data types, variables, and the importance of comments and documentation for code readability. Additionally, it emphasizes the use of Integrated Development Environments (IDEs) and text editors for Python programming.

Uploaded by

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

Python Introduction DataTypes Variables

The document provides an overview of Python programming, detailing its history, key concepts, applications, and installation processes for different operating systems. It explains Python's data types, variables, and the importance of comments and documentation for code readability. Additionally, it emphasizes the use of Integrated Development Environments (IDEs) and text editors for Python programming.

Uploaded by

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

PYTHON

PROGRAMMING
BASICS

<p> Introduction to Python


Programming. </p>
What is PYTHON ?
What is
PYTHON ?
Python is a high-level, general-
purpose programming language created
by Guido van Rossum in 1991. The
language is known for it’s
simplicity, readability and
versatility.
Python History and Versions
• Python laid its foundation in the late 1980s.

• The implementation of Python was started in December 1989 by Guido


Van Rossum at CWI in Netherland.

• In February 1991, Guido Van Rossum published the code (labeled


version 0.9.0) to [Link].

• In 1994, Python 1.0 was released with new features like lambda, map,
filter, and reduce.

• Python 2.0 added new features such as list comprehensions, garbage


collection systems.
Python History and Versions (CONT.)
• On December 3, 2008, Python 3.0 (also called "Py3K") was released. It
was designed to rectify the fundamental flaw of the language.

• ABC programming language is said to be the predecessor of Python


language, which was capable of Exception Handling and interfacing
with the Amoeba Operating System.

• The following programming languages influence Python:


• ABC language.
• Modula-3
PYTHON: Applications

Can be used on a server to create web applications (Django, Flask).

Can be used with software to create workflows.

Can connect to database systems.

Used to handle big data (Pandas, NumPy).

Used in machine learning and AI (TensorFlow, PyTorch).


PYTHON: Key Concepts

Python is an interpreted language.

The programming syntax is straightforward and is easy to understand.

Dynamically typed, allowing variables to change types during runtime.

Python supports object-oriented programming.

The programming language can be integrated with other languages and is


compatible with various operating system.
PYTHON: Key Concepts (cont.)

Python comes with vast standard library, for fast and efficient
development.

Python has a large and active community of developers, that help expand
its capabilities.
Python’s
DEVELOPMENT
environment
Before starting in Python programming,
a development environment is needed to
create and run any python program.
These can be Integrated Development
Environments (IDEs) or text editors.
Python IDEs and Text Editors

IDEs – are software Text Editors – are simple


application that provides programs that are typically
comprehensive tools and included with most operating
features to assist systems that only allows
developers in writing, basic text editing
debugging, and deploying operations.
software.
How to DOWNLOAD Python?
Python Installation for Windows
1. Visit the official Python website at
[Link]

2. Choose the latest version of Python by clicking on it.

3. Scroll down to the "Files" section and click on the installer that
matches your system (e.g., "Windows installer (64-bit)").

4. Once the installer is downloaded, double-click on it to run it.

5. In the installer window, make sure to check the box that says "Add Python
x.y to PATH" (x.y will be the version number).

6. Click "Install Now" to start the installation process.


Python Installation for macOS
1. Open a web browser and visit the official Python website at
[Link]

2. Scroll down to the "Python Releases for macOS" section.

3. Choose the latest version of Python by clicking on it.

4. Scroll down to the "Files" section and click on the macOS installer
package (the filename will end with ".pkg").

5. Download the installer package and double-click on it to open it.

6. Follow the on-screen instructions to install Python.


How are Python Programs
EXECUTED ?
How are Python Programs EXECUTED ?

01 02 03

Source Code Tokenization Parsing


Start by writing An interpreter The interpreter
the Python code reads the source then parses these
in a file with a code and breaks tokens to create
.py extension. it down into a data structure
smaller units called the
called tokens. Abstract Syntax
Tree (AST).
How are Python Programs EXECUTED ?

04 05 06

Translation Execution Result


The interpreter The bytecode is As the bytecode
then translates executed by the is executed, the
the AST into Python Virtual Python program
bytecode. Machine. performs its
intended actions.
Python Fundamentals –
COMMENTS and
DOCUMENTATIONS
Comments and
Documentation
in Python
Comments are important documentation
are essential elements for code
readability, maintainability, and
understanding.
Comments
Comments are lines in the code that are not executed by the Python
interpreter. They are used to provide explanations, notes, or
annotations to the code. Comments can be single-line (starts with ‘#’)
or multi-line (starts with triple quote), also known as ‘docstring’.

Example:

Single-line

# This is a single-line comment ‘‘‘ Comments from this line


x=100 to this line is a docstring’’’
name=“John Doe”
Documentations
Documentation in Python refers to providing detailed explanations about
the purpose, usage, parameters, return values, and behavior of
functions, classes, and modules.

Example:
def calculate_sum(a,b)
“””
Calculate the sum of two numbers.

Parameters:
a (int): The first number.
B (int): The second number.

Returns:
int: The sum of the two numbers.
“””
return a+b
Python Fundamentals –
Variables and Data Types
Literals
in Python
A literal is a fixed or static value
that is written in a source code that
represents data that doesn’t change
Throughout a program execution. The
literals of Python can be categorized by
the following types: integers, floating
numbers, strings, booleans, etc.
Data Types in
Python
In Python, a data type represents the
type of data that a variable can hold.
Python is dynamically typed, and
automatically determines the data type
based on the value assigned to the
variable.
Python Data Types

Numeric Boolean
● Integers – represents ● Boolean – represents
whole numbers (positive either “true” or “false”
or negative) without any used for logical
decimal point operations and control
flow
● Floating Point -
represents numbers with
decimal point or numbers
in exponential form
Python Data Types (cont.)

String List
● String – represents a ● List – are ordered
sequence of characters collection of items.
enclosed in single (‘’), Lists can contain
double (“”), or triple elements of different
(‘‘‘ ’’’ or “““ ”””) data types and are
quotes mutable.
Python Data Types (cont.)

Tuple Set
● Tuple – are similar to ● Set – are unordered
lists but are immutable collection of unique
(elements are elements. Sets don’t
unchangeable after allow duplicate values.
creation)
Python Data Types (cont.)

Dictionary None
● Dictionary – are key- ● None – represents a
value pairs where each special type that
value is associated with indicates the absence of
a unique key a value (null value)
Variables in
Python ● Note: To assign a
value to a
variable, use the
Variables in Python are used to store
assignment operator
data of different types. A variable “=“.
acts like a container that holds a
value and is associated with a name.
VARIABLES: Key Rules

Variable names in Python can contain letters (A-Z, a-z), digits (0-9),
and underscores (_).

Variable names CANNOT start with a digit.

Python is case-sensitive, so ‘my_variable’ is different from


‘My_Variable’.
Variable Examples
# Integer variable # Boolean variable
age = 25 is_student = True

# String variable # List variable


name = “John Doe” numbers = [1, 2, 3, 4, 5]

# Float variable # Dictionary variable


pi = 3.14 person = {‘name’: ‘Alice’, ‘age’: 30}
Lesson Summary
Python is a high-level programming language known for its simplicity,
readability and versatility.

Python is an interpreted language.

Python is used various applications such as web applications,


databases and even to machine learning and AI.

IDEs or text editors are essential in creating and debugging


instructions written in Python programming language.

IDEs offers comprehensive tools whereas text editors performs basic


text editing operations.
Lesson Summary (cont.)
Python source code is written in a .py extension file.

An interpreter tokenizes Python source codes, parses these tokens


into AST and translates it into bytecodes.

Data types in Python are types of data that can be stored and used in
a program.

Some examples of data types are int, float, str, and list.

Variables are containers that are used to hold values and data types.

Values are dynamically typed, allowing changes during runtime.


Lesson Summary (cont.)
Python variable names are case-sensitive and cannot start with a
digit.

Comments are lines in the code that are not executed by the
interpreter.

Documentation in Python are detailed explanation about the purpose


and parameters of a block of code.

Comments are mainly for purely for human readers and help others (and
yourself) understand the code better whereas documentations are
intended to be used by other developers or users of your code.
FIN

You might also like