# Playing with variables in python

VARIABLE DECLARATION:

TO DECLARE AND INITIALISE A VARIABLE WE DO IT DIRECTLY IN PYTHON.

RULES FOR DECLARATION OF VARIABLES IN PYTHON:

1. A variable name should start only with underscore or alphabets.
3. A variable name is case sensitive.
4. A variable can contain alphabets, integer and underscore.

Examples :

my_name = “ Tom “

_myname = “ Tom “

_my_name = “ Tom “

TO DECLARE INTEGERS:

We can declare integers, floating numbers and complex numbers.

SYNTAX TO DECLARE FOR INTEGERS:

>>>Intnum =7

>>>print(intnum)

OUTPUT:  7

SYNTAX TO DECLARE FOR STRINGS:

>>>myword = “HelloWorld”

>>>print(mystring)

OUTPUT: HelloWorld

ASSIGNING MULTIPLE VALUES TO VARIABLES:

Python allows the user to initialise the variables simultaneously.

SYNTAX:

>>>x, y, z = ”tom”, “john”, “jim”

>>>print(x)

>>>print(y)

>>>print(z)

OUTPUT: tom

John

Jim

BUILT-IN FUNCTIONS:

Python has many inbuilt functions. Now here are some functions which are important and required for those who are learning basics.

1. abs(x) : This function returns the absolute value of x.
2. max(x1,x2,x3) : This function returns the largest value among x1,x2,x3.
3. min(x1,x2,x3) : This function returns the smallest value among x1,x2,x3.
4. round(x) : Returns the integer nearest to x.
5. input(x) : It allows user to enter the value of x.

PROGRAM EXECUTION SYNTAX FOR SOME BUILTIN FUNCTIONS:

FOR abs(x):>>>x = -2

>>>abs(x)

>>>print(x)

OUTPUT: 2

1.FOR max(x1,x2,x3):

>>>x1=5

>>>x2=7

>>>x3=9

>>>x=max(x1,x2,x3)

>>>print(x)

OUTPUT: 9

2.FOR min(x1,x2,x3):

>>>x1=5

>>>x2=7

>>>x3=9

>>>x=max(x1,x2,x3)

>>>print(x)

OUTPUT: 5

MATHEMATICAL FUNCTIONS:

Like other programming languages python also has an inbuilt function for mathematical problems.

FIRST TO USE WE MUST IMPORT MATHS.

WE SHOULD USE THE SYNTAX:

import math

These are the few important mathematical syntaxes:

1. math.fabs(x) The mathfabs() method returns the absolute value of a number. Absolute denotes a non-negative number.

2 )math.ceil(x)-The java.lang.Math.ceil(double a) Returns the smallest   (closest    to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer

3.math.floor(x)-The Mathfloor() function returns the largest integer less than or equal to a given number.

4.math.log(x)

5.math.sqrt(x)

6.math.cos(x)

7.math.sin(x)

PROGRAM EXECUTION:

>>>import math

>>>x=math.fabs(-2)

>>>print(x)

OUTPUT: 2

>>>import math

>>>x=math.ceil(2.1)

>>>print(x)

Click on the video button to know more