1.
Python Data Types
Python has several built-in data types. For Data Analytics, the most
commonly used ones are:
1.1 Integer (int)
Whole numbers, positive or negative
No decimal point
Example:
a = 10
b = -5
Characteristics
Unlimited length (only limited by system memory)
Used in counts, indexes, counters, IDs, etc.
1.2 Float (float)
Numbers with decimal points
Used for mathematical and scientific calculations
Example:
price = 10.99
rating = -3.5
Characteristics
Represents decimal values
Necessary in data analytics for averages, percentages, statistical
calculations.
1.3 String (str)
Collection of characters enclosed in ' ', " ", or ''' '''
Example:
name = "Jasmitha"
city = 'Bangalore'
String properties
Immutable → you cannot change characters directly
Supports operations (concatenation, slicing, splitting)
text = "Data Analytics"
print(text[0:4]) # Data
Why important in analytics?
Most data from files (CSV, JSON, SQL) come as strings
Required for data cleaning, text processing.
1.4 Boolean (bool)
Only two values: True or False
Used in:
o Conditions
o Loops
o Filtering datasets
Examples:
is_active = True
is_valid = False
Booleans in Python come from comparisons:
5 > 3 # True
10 == 2 # False
2. Input / Output Operations
2.1 Output – print()
Used to display information on the screen.
Basic usage:
print("Hello, World")
Printing variables:
name = "Jasmitha"
print("My name is", name)
Formatted printing (f-string):
age = 25
print(f"Age is {age}")
2.2 Input – input()
Takes input from the user as string.
Example:
name = input("Enter your name: ")
print("Welcome", name)
Important: Convert input data types
Input is always string → convert manually:
age = int(input("Enter your age: "))
salary = float(input("Enter salary: "))
3. Operators in Python
Operators are symbols used to perform operations on variables and
values.
Categories:
3.1 Arithmetic Operators
Operat
Meaning Example
or
+ Addition 5+3→8
- Subtraction 10 - 4 → 6
* Multiplication 3 * 7 → 21
Division (float 10 / 3 →
/
result) 3.33
// Floor division 10 // 3 → 3
Operat
Meaning Example
or
Modulus 10 % 3 →
%
(remainder) 1
** Exponent 2 ** 3 → 8
Example:
x = 10
y=3
print(x % y) #1
print(x ** y) # 1000
3.2 Comparison Operators
Used to compare values → result is boolean.
Operat Examp
Meaning
or le
== 5 == 5 Equal
!= 5 != 3 Not equal
> 7>3 Greater than
< 3<5 Less than
Greater or
>= 7 >= 7
equal
<= 3 <= 4 Less or equal
Example:
print(10 > 5) # True
print(2 == 3) # False
3.3 Logical Operators
Used for combining conditions.
Operat
Meaning
or
True if both conditions are
and
true
or True if at least one is true
Reverses True to False, vice
not
versa
Example:
x = 10
print(x > 5 and x < 20) # True
print(x < 5 or x == 10) # True
print(not(x == 10)) # False
3.4 Assignment Operators
Used to assign values to variables.
Operat Usag
Meaning
or e
x= Assign
=
10 value
x +=
+= x=x+1
1
x -=
-= x=x-1
1
x *=
*= x=x*5
5
x /=
/= x=x/2
2
Example:
x=5
x += 3
print(x) # 8
3.5 Membership Operators
Used with strings, lists, etc.
Operat
Meaning
or
in True if value exists
True if value does not
not in
exist
Example:
name = "python"
print("p" in name) # True
print("z" not in name) # True
3.6 Identity Operators
Compare object memory location.
Operat
Meaning
or
is True if same object
True if different
is not
objects