Variables, Data Types and Operators :

        A variable is a name given to a memory location in a program. Its a container to store a value.

a = 25                          [ here 'a' is a variable which stores int value]
b = "education"

Data Types :
Following are the data types in python.

1. integer
2. floating point number
3. strings
4. Boolean
5. None

    Python is a fantastic language that automatically identifies the type of data for us.

a=71     [Identifies a as class int]
b = 883.44     [Identifies b as class float]

Rules for defining a variable name:

1. A Variable name can contain alphabets, digits and underscore
2. A Variable name must start with an alphabet or an underscore
3. A Variable name cannot start with a digit.
4. No white spaces allowed to be used insde a variable name.

Operators :
Following are some operators 

1. Arithmetic : + - * / %, etc
2. Assignment : =, +=, -=, etc
3. Comparission : ==, >, >=, <, <=. etc.
4. Logical : and, or , not.

    type () function is used to find the type of data of a given variable in Python.

a=31             :                   type(a)                   : class <int>
b="31"        :                   type(b)                    : class<str>

    A number can be converted into  a string. Functions to convert one data type to another.

str(31) = "31" : integer to string
int("31") = 31 : string to integer
float(32) = 32.0 : integer to float

input () : this function allows the user to take input from the keyboard as a string (like scanf in c).

a = input("Enter the string")                           [Now  type your name ]

***It is important to note that the output of the input is always a string .


Programs:

1. #variables

a_122 = '''praveen'''
# a = 'praveen'
# a = "praveen"
b = 345
c = 45.32
d = True
# d = None

# Printing the variables
print(a)
print(b)
print(c)
print(d)

# Printing the type of variables
print(type(a))
print(type(b))
print(type(c))
print(type(d))


2.  #operators

a = 3
b = 4

# Arithmetic Operators
print("The value of 3+4 is ", 3+4)
print("The value of 3-4 is ", 3-4)
print("The value of 3*4 is ", 3*4)
print("The value of 3/4 is ", 3/4)

# Assignment Operators
a = 34
a -= 12
a *= 12
a /= 12
print(a)

# Comparison Operators
# b = (14<=7)
# b = (14>=7)
# b = (14<7)
# b = (14>7)
# b = (14==7)
b = (14!=7)
print(b)

# Logical Operators
bool1 = True
bool2 = False
print("The value of bool1 and bool2 is", (bool1 and bool2))
print("The value of bool1 or bool2 is", (bool1 or bool2))
print("The value of not bool2 is", (not bool2))

3. #Typecasting

a = "35fgrfg34"
a = int(a)
print(type(a))
print(a + 5)


4. #input_function

a = input("Enter a number: ")
a = int(a) # Convert a to an Integer(if possible)
print(type(a))