Python-Basic to Advanced
Table of Contents
Introduction to Python
Basic Of Python
Operators in Python
if -else in python
Loop in python
More Basic of Python
Function in Python
Advanced Topic in Python
Python-Mini Project
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Introduction to Python
What is Python?
Python is high-level programming language. Python language
Created by Guido van Rossum. Python First Released in 1991.
Why Python So Popular Language ?
• Simple Syntax
• Totally Free & Open Source
• Support For Beginners & Experts
• Used By Popular Organization
What is Python Used For?
• Machine Learning & Artificial Intelligence
• Data Analysis
• Web Development
• Automation
• Game Development
Python Required Softwares
• Python
• PyCharm ( Ofline Code IDE)
• Google Colab( Online Code IDE)
Python Version History
• Python 1.X & 2.X
• Python 3.X
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Basic Of Python
Python Print(“ “)
String in python Use (” ”)
Example
Print(1+4)
Example
Python Comment
Comments are used for code explanation
• Singel-Line Comment
• Multi-Line Comment
Singel-Line Comment Use # Symbol
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Multi-Line Comment Use “”” “”” Symbol
Example
Python Escape Sequences
Python Escape Sequences Is a combination characters that
represent a special characters when used inside a string .
Common Python Escape Sequences:
Newline ( line break) = \n
Tab=\t
Singel Quote = \’
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Double Quote = \”
Python Variables
Python Variables Used to Store Data Values . Python variables
are initialized with strings.
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Python Data Types
Python data type specifies the type of data a variable can hold.
Common Python Data Types:
String Data ‘str’
Example
Numeric Data Types ( int , float,complex)
Example ( int data type)
Example ( float data type)
Example ( Complex data type)
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Boolean Data Type ( True , False)
Example ( True )
Example ( False)
Python Memory Management
Memory management in Python refers to how the language
handles the allocation memory during the execution of
programs.
Example(id())
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Python User Input
Python User Input the input() function is used to capture user
input.
Example
Python Type Casting
Python always accepts everything as string data when taking user input.
Many times when user input is required to take other data then Python
type casting is required.
Example (Before type casting)
Example (Before type casting)
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Operators in Python
Python Operators
Operators in Python are special symbols that operate on variables and
values.
Types of Operators in Python:
Arithmetic Operators
Operator Name Example
+ Addition 5+5=10
- Subtraction 5-5=0
* Multiplication 5*5=25
/ Division 5/5=1
% Modulus 5%5=0
** Exponentiation 5**5=3125
// Floor Division 5//5=1
Example ( Addition Operators)
Example ( Subtraction Operators)
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Example ( Multiplication Operators)
Example ( Division Operators)
Comparison Operators
Operator Name Example
== Equal to X==y
!= Not equal to X!=y
< Greater than X<y
> Less Than x>y
<= Greater than or equal to X<=y
>= Less than or equal to x>=y
Example ( Equal to)
Example (Greater than or equal to)
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Logical Operators
Operators Condition
and True if both conditions are true
or True if at least one condition is
true
not makes true conditions false and
vice versa
Python Math Library Function
Math Lib Condition
max Returns the largest value
min Returns the smallest value
floor Rounds a number down to the nearest integer
ceil Rounds a number up to the nearest integer
sqrt Returns the square root of a number
round Rounds a number to the nearest integer or decimal place
abs Returns the absolute (non-negative) value of a number
Example
max
min
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Floor
Ceil
if -else in python
if-else
if-else statement in Python is used for decision-making.
if expression:
statement ()
else:
statement ()
Example 1
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Example 2 ( Calculate EvenOdd Number)
elif in Python
elif statement in Python is short for "else if" and is used in decision
making to test multiple conditions.
Example
Nested-if in Python
Nested if statement in Python is when you place one if statement inside
another if (elif or else) statement.
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Loop in python
While loop in Python
Python while loop is a control flow statement that repeatedly executes a
block of code as long as a given condition is true.
Example
For loop in Python
Python for loop is another control flow statement that iterates over a
sequence and executes a block of code for each element in the
sequence.
Example
Range in Python
The range () function in Python generates a sequence of numbers.
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Python break and continue
Python break and continue control flow statements that alter
the execution of loops.
More Basic of Python
String In Python
Python String is a sequence of characters.
Example
List In Python
Python list is a mutable, ordered collection of items.
Example
Array In Python
Python array is similar to a list, but typically used with more specific
numeric types.
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Example
Dictionary In Python
Python dictionary is an unordered collection of key-value pairs.
Example
Tuple In Python
Python tuple is an immutable, ordered collection of items.
Example
Set In Python
Python set is an unordered collection of unique items.
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Function in Python
Def function In Python
In Python def is used to define a function. Def Functions help modularize
code, improving readability and reusability.
Example
Lambda function In Python
Lambda function to define the anonymous function.
Example
Map function In Python
Map function is used to apply a given function to every item in an
Repeatable and return a map object.
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Zip function In Python
zip function in Python takes multiple Repeatables and aggregates them
into tuples, pairing elements from each Repeatable at the same index.
Example
Advanced Topic in Python
Exception Handling In Python
Exception handling in Python allows you to handle errors gracefully and
avoid program crashes.
Example
Class & Object In Python
Python classes are blueprints for creating objects (instances), which
encapsulate both data (properties) and behavior (methods).
Example
Written By Meharin Hasna Puspo
Python-Basic to Advanced
File In Python
Python file handling allows you to read from and write to files on your
filesystem.
Example
Python has some advanced libraries. For example:
Pandas Library
Numpy Library
Matplotlib Library
Seaborn Library ,etc
These libraries are especially used in data science, data analysis, machine learning.
Written By Meharin Hasna Puspo
Python-Basic to Advanced
Python-Mini Project
Random Password Generate
import random
chars='abcdefghijklmnopqurstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789!
@#$%^&*()[]{}'
Length=int(input('Enter The Length Password: '))
Password=''
for i in range(Length):
Password+=random.choice(chars)
print( 'Your Password:',Password)
Author identity
Nmae: Meharin Hasna Puspo
Studying Diploma in Computer Science Engineering
Python |Data Science | Machine learning
Written By Meharin Hasna Puspo