0% found this document useful (0 votes)
7 views75 pages

Python Programming

Uploaded by

yasmohamed0
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)
7 views75 pages

Python Programming

Uploaded by

yasmohamed0
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
You are on page 1/ 75

Sudanese Data Science Community(SDSC)

Python Programming

Eng.Mohammed
 Python Programming
 Introduction to Python Programming
 Anaconda Distribution
 install Anaconda Distribution
 Anaconda Distribution Environment
 Print() function
 Python Data Types
 Variables
 Strings and Strings Methods
 Data Structures : Lists , Dictionaries ,tuple , sets
 Booleans , Comparisons Operators , Logical Operators
 conditional statement : If, Else, Elif Statements
 Loops : for loop and while loop
 Functions
 Advance Functions
 Introduction to Python Programming

 Python is used for software development at companies and organizations


such as Google, Yahoo, Facebook and NASA.

 Guido van Rossum created the Python programming language in the late 1980s.

 Python is simple programming language

 Python is powerful programming language

 Python has powerful syntax


 Anaconda Distribution

 Free distribution install

 Thousands of the most fundamental DS, AI, and ML packages

 Manage packages and environments from desktop application

 Deploy across hardware and software platforms


 Anaconda Distribution Environment
 Print() function
 Python Data Types

 Numbers

 Python has two basic number types, integer and float

 For example, 2 is an integer and 2.0 is a floating point number, which has a decimal attached to it.

 We can perform arithmetic operations to either of these numbers types.


 Python Data Types

 Numbers
 Python Data Types

 Numbers
 Python Data Types

 Numbers
 Variables

 Python variables also can represent values Uses variable to store a value and then prints the value
of the variable.

 The key to an assignment statement is the symbol = which is known as the assignment operator.

 The statement assigns the value to the variable

 in Python using equal sign operator “=“

 We can perform arithmetic operations

 We can perform any arithmetic operation and assign the result to a new variable.

 We can re-assigna value to the variables. This will replace the existing value to its new value.
 Variables
 Variables
 Variables

 Important regarding variable name

 Variable names can not be started with number (e.g. 1var, 2x etc)

 variable names can not be started with special characters (e.g. *var, !y etc)

 variable names are case sensitive, "Name" is not the same as "name“

 reserved words can not be a variable name, e.g. "class" is a reserve word in Python, it can not be used as a
variable name, but "klass" and "Class" work fine.
 Variables
 Python Data Types

 Strings and Strings Methods

 Strings are one of the most popular and very useful data types in Python.

 They can be created by enclosing characters in single '' or double "" quotes.

 Python consider single and double quotes in the same way.

 Strings are used to record text information (e.g. person name) as well as arbitrary collection
of bytes (e.g. contents of an image file).

 We can pass a string to a variable as well

 We can use the print() method to output the variable X. This is a proper and official way to
display the results in Python
 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings and Strings Methods


 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Strings Methods
 Python Data Types

 Data Structures : Lists

 list is a sequence of elements separated by commas in a set of square brackets.

 it can take any data type

 list have no fixed size.

 list is mutable — unlike strings, list can be modified.

 list can be indexed and sliced, like strings


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Lists


 Python Data Types

 Data Structures : Dictionaries

 Dictionaries are something completely different as they are not sequences at all.

 Dictionaries are key-value pairs in curly brackets "{}“

 Dictionaries store objects by 'key' instead of by relative position and don't maintain any reliable let-to-right order;
they simply map key to its associated value.

 Dictionaries can grow and shrink on demand, Like lists


 Python Data Types

 Data Structures : Dictionaries


 Python Data Types

 Data Structures : Dictionaries


 Python Data Types

 Data Structures : Tuples

 similar to lists but can not be changed.

 sequences, like lists, but immutable, like strings.

 used to represent fixed collection of items.

 coded in parentheses "()" instead of square brackets


 Python Data Types

 Data Structures : Tuples


 Python Data Types

 Data Structures : sets


 Booleans , Comparisons Operators , Logical Operators
 Booleans , Comparisons Operators , Logical Operators
 Booleans , Comparisons Operators , Logical Operators
 Conditional statement : If, Else, Elif Statements
 Conditional statement : If, Else, Elif Statements
 Loops : for loop and while loop
 The statement/s perform an action over and over.

 while and for are the two main loops in Python for this purpose.

 Python keeps evaluating the test expression (loop test) before executing the statement/s, until the test returns
a False value.

 When we know the number of iterations that must occur in a loop execution, we use the for loop. On the other hand, if
we do not know how many iterations must occur in a loop, we use a while loop.The statement/s are nested in the body of
the loop.

 For loop allow us to iterate through a sequence.

 The for statement works on strings, lists, tuples and other built-in iterables, as well as on new user-defined objects.

 In While loop continually performed an action, until some condition has been met

 The statement/s perform an action over and over. while and for are the two main loops in Python for this purpose.

 Python keeps evaluating the test expression (loop test) before executing the statement/s, until the test returns
a False value.
 Loops : for loop and while loop
 Loops : for loop and while loop
 Loops : for loop and while loop
 Loops : for loop and while loop
 Loops : for loop and while loop
 Functions

 A function is a block of code that performs a specific task. which only runs when
it is called
 Functions
 Functions
 Advance Functions

 Lambda functions are similar to user-defined functions but without a name

 A lambda function can take any number of arguments, but can only have one expression
 Advance Functions

 Map function is a function that works as an iterator to return a result after applying a function to every
item of an iterable (tuple, lists, etc.).

 It is used when you want to apply a single transformation function to all the iterable elements
Thank You

You might also like