👉 Variables
👉 Data types
👉 Type Conversions
👉 Operators in Python
Variables are like boxes or containers which stores any data. We can declare the variables using alphabet or using strings (more than one alphabet).
In Python, assigning any type of data to the variables is too easy than any other programming languages
Ex:
X = -4 (Integer type)
Y = 3.8 (Float Type)
comp = 2 + 3j (Complex Type)
char = 'A' (String Type)
name = "Dev-Incept" (String Type)
- Strings are written inside the quotes, either single quotes or double quotes
We have seen one of the data type in the above example i.e, Numeric Data type
- We have 4 data types in python as shown below
| S.No. | Data Type | Types/Operations | Examples |
|---|---|---|---|
| 1. | Numeric data type |
|
|
| 2. | List data type |
|
|
| 3. | Tuple data type |
|
|
| 4. | Set data type |
|
|
| 5. | String data type |
|
|
| 6. | Dictionary data type |
|
|
💭 List Data Type:
Lists store any type of data ie., it stores int , float , boolean , string etc.. These are indicated using square brackets []. The operations performed for lists are mentioned above in the tabular form.
Lists are Mutable that means we can change our data in the list.
💭 Tuple Data Type:
Tuples are similar to lists ie., tuples also store int , float , boolean , string etc.. but these are indicated with paranthesis or round brackets (). The operations performed for tuples are mentioned above in the tabular form.
Tuples are Im-mutable that means once we have assigned some data to the variable we can't change the data again.
Difference between Lists and Tuple
- Lists are Mutable
- Tuples are Im-mutable
- Tuples take less time to execute than lists
💭 Set Data Type:
Sets also store different type of data like int , float , boolean , string etc..These are indicated using curly brackets {}. The operations performed for sets are mentioned above in the tabular form.
Sets don't return the repeated values in the output and the order in the output is also not as same as the order in the given input.
💭Strings:
Strings are the group of characters or only one charcter inside the singles quotes or double quotes. The characters may be numeric type or alphabets. The operations performed in strings are mentioned above in the tabular form.
💭 Dictionary Data Type:
Dictionary also store different type of data like int , float , boolean , string etc.. followed by key value pairs. These are indicated using curly brackets { "Key" : "Value"} . The keys name should be UNIQUE and the values may be repeated based on our data. The operations performed for sets are mentioned above in the tabular form.
Converting one data type into another data type is called as type conversion. That means, we can convert an integer to a float value ; boolean value to integer ; float to boolean and vice versa etc..
We observe this type conversion detailly in the "Bommidi_Python_variables,types,type conversions.ipynb" file.
Operators are used to perform operations on variables and data
We have different types of opertors they are:
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Bitwise Operators
All the examples for this topic will be in "Bommidi_Python_variables,types,type conversions.ipynb" file.
💭Arithmetic Operators:
Arithemetic operators includes
- Addition(+)
- Subtraction(-)
- Multiplication(*)
- Division(/)
- Floor division(//)
- Modulus(%)
- Exponential(**)
💭Comparison Operators:
Comparison Operators are used to compare two values like
- Equal to (==)
- Not Equal to (!=)
- Greater than (>)
- Eess than (<)
- Greater than or Equal to (>=)
- Less than or Equal to (<=)
💭Logical Operators:
Logical Operators are used to combine conditional statements
- and
- or
- not
💭 Bitwise Operators:
Bitwise Operators are used to compare binary numbers
- AND &
- OR |
- XOR ^
- NOT ~
=====================================================================================
I hope you have gained some knowledge on these concepts!