SlideShare a Scribd company logo
By Muhammad Ashar
GET READY FOR
Artificial Intelligence
USING
PYTHON
What is AI?
Re-Calling Concepts:
•Print
•Type casting
•Input
•If-Elif-Else (Conditional Statements)
Operators
•Constants, Variables
What is PYTHON ?
PYTHON:
• General Purpose Programming: Python is versatile and addresses a wide range of
programming tasks.
• Scripting Language: Python automates repetitive tasks like file manipulation and text
processing.
• Interpreted Language: Python's line-by-line execution allows for flexibility and easier
debugging.
• Dual Role: Python develops complex applications and automates simpler tasks efficiently.
History
• Invented in the Netherlands, in 1991 by
Guido van Rossum
• Named after Monty Python
• Open sourced from the beginning
Why PYTHON ?
Getting started with the basics of python
Current Application of
PYTHON …
• Web development
• Software development
• System scripting
• Machine Learning
• Data Science
• AI, Deep Learning
Getting started with the basics of python
Getting started with the basics of python
iNTRODUCTION
TO PYTHON
Python is a high-level programming
language that is widely used in various
fields, Some of the key elements of
Python include:
01
DATA TYPES
02
VARIABLES
03
OPERATORS
04
CONDITIONA
L
STATEMENTS
05
LOOPS
06
FUNCTIONS
07
LIBRARIES
Variables:
Party Time! Get Your
Data On!
A variable in Python is just a name that
represents a value, and you can use it to
store and manipulate data throughout your
program.
In Python, we’ll try to create a variable called "age" and
assign a value to it, like this:
Now, whenever you need to use that age value in your
program, you can just use the variable name "age". For
example:
The output will be:
In this example, the variable "age" is assigned the value 15.
Then, the print statement uses the value of the variable "age"
to output the string "I am 15 years old."
Note: We use the str() function to convert the integer value of
"age" into a string, so we can concatenate it with the other
strings in the output statement.
Data Types:
So Many Flavors, So
Little Time!
In Python, data types are categories of
values that determine how the values
behave and what operations can be
performed on them.
Here are some common data types and
their examples:
TYPES DESCRIPTION EXAMPLES
Numeric Represents numerical values 'int' , 'float'
Sequence Represents a collection of
ordered and indexed values
'list' , 'tuple'
Text Represents a sequence of
characters
'str'
Mapping Represents a collection of
key-value pairs
'dict'
Set Represents a collection of
unique elements
'set'
Boolean Represents a binary truth
value
'bool'
Examples that shows how different data types can be used in Python:
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Operators:
Go crazy with
Calculations!
In Python, operators are symbols or special
characters that allow you to perform
different kinds of operations on variables
and values.
TYPES DESCRIPTION EXAMPLES
Arithmetic
Operators
Used to perform arithmetic
operations
'2 + 3' returns '5'
Comparison
Operators
Used to compare
values
'2 < 3' returns 'True'
Logical
Operators
Used to combine and
manipulate boolean values
'True and False' returns
'False'
Bitwise
Operators
Used to perform
bitwise operations
'a & b' returns '1'
Assignment
Operators
Used to assign values
to variables
'x=5'
Identity
Operators
Used to compare the memory
location of
two objects
'x is y' returns 'True'
Membership
Operators
Used to check if a
value is present in a
sequence
'2 in [1, 2, 3]' return 'True'
Getting started with the basics of python
Getting started with the basics of python
Input and f string:
Ask from user:
Getting started with the basics of python
Index and Slices:
Your Choice:
Conditional
Statements:
Be the boss of your
code!
TYPES DESCRIPTION EXAMPLES
If
statement
Executes a block
of code if a condition
is true
'x=5' <br>
'if x>3:'<br>
'print("x is greater than 3")'
If else
statement
Executes one block
of code if a condition
is true and another
block if it is false
See the diagram on Left Side
elif
statement
Executes a block of
code if a condition is true,
and if not, checks another
condition
See the diagram on Left Side
nested if
statement
Executes a block of
code if a condition is true,
and that block
can contain another
if statement
Loops:
Repeat After Me!
Loops are used to repeat a block of code multiple
times until a certain condition is met. There are two
main types of loops in Python: for loops and while
loops.
INPUT OUTPUT
FOR
LOOP
LOOP TYPE DESCRIPTION
'for' loop
Used to iterate over a sequence of elements, such
as a list or string
'while' loop
Used to repeat a block of code while a certain
condition is true
WHILE
LOOP
FUNCTION TYPE DESCRIPTION
Built-in
functions
Functions that are built in python and can be used
without needing to define them.
Examples - 'print()' , 'len()' and 'range()'
User-defined
functions
Functions that you create yourself to perform a
specific task. They can be reused multiple times
throughout your code.
Functions:
The Superheroes
of Code!
Functions are reusable blocks of code that perform a
specific task. They allow you to write a piece of code
once and use it multiple times without having to
rewrite the code. There are two main types of
functions in Python: built-in functions and user-defined
functions.
INPUT OUTPUT
Built-in
function
User-
defined
function
Functions
Continue...
Here's an example of using the math library to
calculate the square root of a number:
Another example is using the pandas library to
read a CSV file and display its contents:
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Getting started with the basics of python
Python's Top Guns:
The Most Important
Libraries
1. Import Numpy
NumPy is a library for numerical computing in
Python. It provides fast and efficient array
operations and linear algebra routines.
2. Import Art
Art is a library for data manipulation and
analysis in Python. It provides different
Example for importing NumPy
Library in Python
Example for importing Art
Library in Python
Libraries
Continue...
`TextBlob` is a Python library for processing
textual data, offering tools for sentiment
analysis, part-of-speech tagging, and
translation.
The `turtle` library in Python is used for
creating simple graphics and drawings by
controlling a turtle that moves around the
screen.
Example for importing TextBlob
Library in Python
Example for importing Turtle
library in Python
3. import TextBlob
4. import turtle
Tasks for Today:
•Am I an even number?
•Showcase the use of the following
functions:
•for, while, conditionals
•Build a calculator using functions
(add, subtract, multiply, divide)
•Use Lists for storing data
•Use a Dictionary for storing data
•Exception Handling
•Slicing

More Related Content

PPTX
Python intro
PDF
Python (3).pdf
PPTX
Python (Data Analysis) cleaning and visualize
PPTX
Python PPT.pptx
PPTX
Introduction-to-Python.pptx grade 9 ICT.
PPTX
Programming
PDF
web programming UNIT VIII python by Bhavsingh Maloth
PPT
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Python intro
Python (3).pdf
Python (Data Analysis) cleaning and visualize
Python PPT.pptx
Introduction-to-Python.pptx grade 9 ICT.
Programming
web programming UNIT VIII python by Bhavsingh Maloth
notwa dfdfvs gf fdgfgh s thgfgh frg reggg

Similar to Getting started with the basics of python (20)

PDF
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
PPT
Python slides for the beginners to learn
PPT
Py-Slides-1.ppt1234444444444444444444444444444444444444444
PPT
program on python what is python where it was started by whom started
PPT
Python Over View (Python for mobile app Devt)1.ppt
PPTX
Python-Basics.pptx
PDF
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
PPTX
Chapter 1-Introduction and syntax of python programming.pptx
PPT
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
PDF
Python Programing Bio computing,basic concepts lab,,
PPTX
UNIT 1 .pptx
PPTX
Python 01.pptx
PDF
Class_X_PYTHON_J.pdf
PDF
Python Module-1.1.pdf
PDF
Python_Unit_1.pdf
PPTX
Introduction to Basics of Python
PPTX
INTRODUCTION TO PYTHON PROGRAMMING .pptx
PPTX
Advance Python programming languages-Simple Easy learning
PPTX
Docketrun's Python Course for beginners.pptx
PPTX
Python Programming 1.pptx
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Python slides for the beginners to learn
Py-Slides-1.ppt1234444444444444444444444444444444444444444
program on python what is python where it was started by whom started
Python Over View (Python for mobile app Devt)1.ppt
Python-Basics.pptx
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
Chapter 1-Introduction and syntax of python programming.pptx
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
Python Programing Bio computing,basic concepts lab,,
UNIT 1 .pptx
Python 01.pptx
Class_X_PYTHON_J.pdf
Python Module-1.1.pdf
Python_Unit_1.pdf
Introduction to Basics of Python
INTRODUCTION TO PYTHON PROGRAMMING .pptx
Advance Python programming languages-Simple Easy learning
Docketrun's Python Course for beginners.pptx
Python Programming 1.pptx
Ad

Recently uploaded (20)

PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
Database Infoormation System (DBIS).pptx
PPT
Quality review (1)_presentation of this 21
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Foundation of Data Science unit number two notes
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Business Acumen Training GuidePresentation.pptx
PDF
Fluorescence-microscope_Botany_detailed content
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Business Ppt On Nestle.pptx huunnnhhgfvu
Moving the Public Sector (Government) to a Digital Adoption
Galatica Smart Energy Infrastructure Startup Pitch Deck
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Database Infoormation System (DBIS).pptx
Quality review (1)_presentation of this 21
oil_refinery_comprehensive_20250804084928 (1).pptx
Foundation of Data Science unit number two notes
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
STUDY DESIGN details- Lt Col Maksud (21).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
1_Introduction to advance data techniques.pptx
Reliability_Chapter_ presentation 1221.5784
Business Acumen Training GuidePresentation.pptx
Fluorescence-microscope_Botany_detailed content
Ad

Getting started with the basics of python

  • 1. By Muhammad Ashar GET READY FOR Artificial Intelligence USING PYTHON
  • 3. Re-Calling Concepts: •Print •Type casting •Input •If-Elif-Else (Conditional Statements) Operators •Constants, Variables
  • 5. PYTHON: • General Purpose Programming: Python is versatile and addresses a wide range of programming tasks. • Scripting Language: Python automates repetitive tasks like file manipulation and text processing. • Interpreted Language: Python's line-by-line execution allows for flexibility and easier debugging. • Dual Role: Python develops complex applications and automates simpler tasks efficiently.
  • 6. History • Invented in the Netherlands, in 1991 by Guido van Rossum • Named after Monty Python • Open sourced from the beginning
  • 9. Current Application of PYTHON … • Web development • Software development • System scripting • Machine Learning • Data Science • AI, Deep Learning
  • 12. iNTRODUCTION TO PYTHON Python is a high-level programming language that is widely used in various fields, Some of the key elements of Python include: 01 DATA TYPES 02 VARIABLES 03 OPERATORS 04 CONDITIONA L STATEMENTS 05 LOOPS 06 FUNCTIONS 07 LIBRARIES
  • 13. Variables: Party Time! Get Your Data On! A variable in Python is just a name that represents a value, and you can use it to store and manipulate data throughout your program. In Python, we’ll try to create a variable called "age" and assign a value to it, like this: Now, whenever you need to use that age value in your program, you can just use the variable name "age". For example: The output will be: In this example, the variable "age" is assigned the value 15. Then, the print statement uses the value of the variable "age" to output the string "I am 15 years old." Note: We use the str() function to convert the integer value of "age" into a string, so we can concatenate it with the other strings in the output statement.
  • 14. Data Types: So Many Flavors, So Little Time! In Python, data types are categories of values that determine how the values behave and what operations can be performed on them. Here are some common data types and their examples: TYPES DESCRIPTION EXAMPLES Numeric Represents numerical values 'int' , 'float' Sequence Represents a collection of ordered and indexed values 'list' , 'tuple' Text Represents a sequence of characters 'str' Mapping Represents a collection of key-value pairs 'dict' Set Represents a collection of unique elements 'set' Boolean Represents a binary truth value 'bool'
  • 15. Examples that shows how different data types can be used in Python:
  • 22. Operators: Go crazy with Calculations! In Python, operators are symbols or special characters that allow you to perform different kinds of operations on variables and values. TYPES DESCRIPTION EXAMPLES Arithmetic Operators Used to perform arithmetic operations '2 + 3' returns '5' Comparison Operators Used to compare values '2 < 3' returns 'True' Logical Operators Used to combine and manipulate boolean values 'True and False' returns 'False' Bitwise Operators Used to perform bitwise operations 'a & b' returns '1' Assignment Operators Used to assign values to variables 'x=5' Identity Operators Used to compare the memory location of two objects 'x is y' returns 'True' Membership Operators Used to check if a value is present in a sequence '2 in [1, 2, 3]' return 'True'
  • 25. Input and f string: Ask from user:
  • 28. Conditional Statements: Be the boss of your code! TYPES DESCRIPTION EXAMPLES If statement Executes a block of code if a condition is true 'x=5' <br> 'if x>3:'<br> 'print("x is greater than 3")' If else statement Executes one block of code if a condition is true and another block if it is false See the diagram on Left Side elif statement Executes a block of code if a condition is true, and if not, checks another condition See the diagram on Left Side nested if statement Executes a block of code if a condition is true, and that block can contain another if statement
  • 29. Loops: Repeat After Me! Loops are used to repeat a block of code multiple times until a certain condition is met. There are two main types of loops in Python: for loops and while loops. INPUT OUTPUT FOR LOOP LOOP TYPE DESCRIPTION 'for' loop Used to iterate over a sequence of elements, such as a list or string 'while' loop Used to repeat a block of code while a certain condition is true WHILE LOOP
  • 30. FUNCTION TYPE DESCRIPTION Built-in functions Functions that are built in python and can be used without needing to define them. Examples - 'print()' , 'len()' and 'range()' User-defined functions Functions that you create yourself to perform a specific task. They can be reused multiple times throughout your code. Functions: The Superheroes of Code! Functions are reusable blocks of code that perform a specific task. They allow you to write a piece of code once and use it multiple times without having to rewrite the code. There are two main types of functions in Python: built-in functions and user-defined functions. INPUT OUTPUT Built-in function User- defined function
  • 31. Functions Continue... Here's an example of using the math library to calculate the square root of a number: Another example is using the pandas library to read a CSV file and display its contents:
  • 36. Python's Top Guns: The Most Important Libraries 1. Import Numpy NumPy is a library for numerical computing in Python. It provides fast and efficient array operations and linear algebra routines. 2. Import Art Art is a library for data manipulation and analysis in Python. It provides different Example for importing NumPy Library in Python Example for importing Art Library in Python
  • 37. Libraries Continue... `TextBlob` is a Python library for processing textual data, offering tools for sentiment analysis, part-of-speech tagging, and translation. The `turtle` library in Python is used for creating simple graphics and drawings by controlling a turtle that moves around the screen. Example for importing TextBlob Library in Python Example for importing Turtle library in Python 3. import TextBlob 4. import turtle
  • 38. Tasks for Today: •Am I an even number? •Showcase the use of the following functions: •for, while, conditionals •Build a calculator using functions (add, subtract, multiply, divide) •Use Lists for storing data •Use a Dictionary for storing data •Exception Handling •Slicing