Introduction to Python Programming Cycle of Python Varibles and Datatypes in Python Input and Output in Python Operators in Python Precedence of Operators in Python Typecasting in Python If Else in Python Loops in Python Break, Continue and Pass in Python Functions in Python Default Arguments and Keyword Arguments in Python Strings in python Lists in Python Tuple in Python Dictionary in Python Sets in Python List Comprehension in Python Unpacking Sequences in Python Higher Order Functions in Python Lambda Functions in Python Sieve of Eratosthenes Algorithm in Python Linear Search in Python Binary Search in Python Selection Sort in Python Bubble Sort in Python Insertion Sort in Python Merge Sort in Python

Varibles and Datatypes in Python

Variable

Variable is a container that stores data. For example, we have a bottle it stores water. Here bottle is variable and water is data. As we know everything in our system is stored in memory. So we can say, a variable is a name given to the memory location in which we store data.
variable image
Example of Variable:-
n = 100
m = 10.43
s = "Rapid Coders"
Here n, m, s are variables.

Rules for defining the name of variable:

Example of valid variable names:- x, y, abc, username, etc.
Note:- Always use meaningfull name for variables. As we know spaces are not allowed so we use the following naming conventions:
  1. Camel case:- In this convention first letter of the variable is lowercase and all other words have the first letter in uppercase. Example:- nameOfUser, ageOfPerson.
  2. Snake case:- In this convention, we use underscore where we need to use space. Example:- name_of_user, age_of_person.

Datatypes

Type of data is called datatype. Before understanding it technically let's understand it generally. In real life, we have apples, bananas, mango, etc. These all are fruits. Here apples and bananas are data and fruit is datatype. Technically datatype is a classification that specifies the type of value or data.
data types image
In Python we have the following datatypes:
  1. Integers:- An integer is a whole number and it can be positive, negative, or zero. Example: 1, 2, 43, 456
  2. Floating point numbers:- A floating point number, is a positive or negative number with a decimal point. Example: 1.34, 2.543, 43.01, 456.5
  3. String:- String is a collection of characters. Example: "rapid coders", "Akshay"
  4. Booleans:- They can have only two values which are True and False.
  5. None:- This mean nothing. It is used to represent null or no value.
Some other datatypes are:
  1. List
  2. Tuple
  3. set
  4. dictionary
We will learn about them in further articles.