0% found this document useful (0 votes)
18 views13 pages

Day 1

my own notes for python and Machine Learning
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)
18 views13 pages

Day 1

my own notes for python and Machine Learning
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/ 13

Python

Fundamentals
Phase- I
What is Python ?

Python is a high-level, interpreted programming language known for its simplicity and readability. It was
created by “Guido van Rossum” and first released in 1991. Python supports multiple programming
paradigms, including procedural, object-oriented, and functional programming.

PEP8 (Python Enhancement Proposal)

Advantages:

 Easy to Learn and Read


 Versatility
 Large Ecosystem
 Cross-Platform Compatibility
 Interpreted Language
 Open Source
Mac OS/Ubuntu OS:
Python3 (Default)

Windows:

1. https://www.anaconda.com/download
2. Open the anaconda.exe file as administrator
3. Make it for All users
4. Anaconda prompt and type python ide
Data Types
Data Types

Primitive Non-Primitive

Integer
Linear Non-Linear
Float

Character Tree
Static Dynamic

String Array Linked List


Graph

Boolean Stack

Queue
Primitive DataTypes

Data Type Description Example

Integer Numbers without Decimal Point 1, 2, 3, 4, 5, ………..

Float Numbers with Decimal Point 3.5, 2.5, 6.5, ……….

Character Single Character A, B, C, F

String Text Hello World!

Boolean Logical Values True or False True or False


Python Type Conversion ?

In programming, type conversion is the process of converting data of one type to another. There are two
types of type conversion in Python.

 Implicit Conversion - Automatic type conversion


 Explicit Conversion - Manual type conversion

Example 1: Converting integer to float


Python Type Conversion ?

Example 2: Converting String to Integer


Python Operators

1. Arithmetic Operators

Operator Example
Addition 5+2=7
Subtraction 5–2=3
Multiplication 5 * 2 = 10
Division 5 / 2 = 2.5
Floor Division 5 // 2 = 2
Modulo 5%2=1
Power 5 ** 2 = 25
Python Operators

2. Assignment Operators

Operator Example

Addition Assignment a += 1 or a = a + 1
Subtraction Assignment a -= 3 or a = a - 3
Multiplication Assignment a *= 4 or a = a * 4
Division Assignment a /= 3 or a = a / 3
Remainder Assignment a %= 10 or a = a % 10
Exponent Assignment a **= 10 or a = a ** 10
Python Operators

3. Comparison Operators

Operator Example
Is Equal To 3 == 5 gives us False

Not Equal To 3 != 5 gives us True


Greater Than 3 > 5 gives us False
Less Than 3 < 5 gives us True
Greater Than or Equal To 3 >= 5 give us False
Less Than or Equal To 3 <= 5 gives us True
Python Operators

4. Logical Operators

Operator Example
Logical AND:
a and b True only if both the operands are
True

Logical OR:
a or b True if at least one of the operands
is True
Logical NOT:
not a True if the operand is False and
vice-versa.
Python Operators

5. Bitwise operators

Operator Example
Bitwise AND x & y = 0 (0000 0000)

Bitwise OR x | y = 14 (0000 1110)


Bitwise NOT ~x = -11 (1111 0101)
Bitwise XOR x ^ y = 14 (0000 1110)
Bitwise right shift x >> 2 = 2 (0000 0010)
Bitwise left shift x << 2 = 2 (0010 1000)
Python Operators

6. Special operators

6.1 Identity Operators

Operator Example

is x is True

is not x is not True

6.2 Membership Operators

Operator Example

in 5 in x

not in 5 not in x

You might also like