Syntax and Numerical operators

Python

Syntax and Numerical operators

Variables:
Python uses variables to store data in memory.
For ex:
number=12
number=126
Initially, the value of the number was 12. Later it was changed to 126.
print(number)
126
name="ArdousGeek"
print(name)
ArdousGeek
Python is a case sensitive language and variable names should use Snake case, like so:
Snake case:
Snake case is a writing convention where words are separated by underscores. It typically uses all lower case letters.
this_is_a_ardous_geek
language='python'
print(language)
python

Fundamental Data Types:
Python has data types or classes.
Classes
A class is a code template where objects are created.
Integers: any whole number. Positive or negative whole numbers. Integers belong to the int class.
>>> type(2345)
<class 'int'>
Floats: any decimal numbers. Any real number with a floating-point representation in which a fractional component is denoted by decimal symbol or scientific notation. Floats belong to the float class.
>>> type(26.3)
<class 'float'>
Complex Numbers: complex numbers come in the form a+b*j, where a is a real number, b is an imaginary number and j represents sqrt -1.
>>> complex_value=3+5j
>>> type(complex_value)
<class 'complex'>
Strings: any characters wrapped in single or double quotes("see"). A string value is a collection of one or more characters put in a single or double or triple quote. Strings belong to the str class.
>>> type('90')
<class 'str'>
By using single quotes you can embed double quotes and vice-versa.
single='you can see "these"'
double="I can see 'these"'
Pythonic is an adjective used to describe code that is clear, concise, and maintainable.
Pythonic means code that does not just get the syntax right but that follows the conventions of the python community and uses the language in the way it's intended to be used.
Other python data types:
1.Boolean
2.Set
3.Dictionary
4.List
5.Tuple
Arithmetic Operators:
Python uses standard arithmetic operators.
The four standard operators are +,-,*, and /.
These allow us to add, subtract, multiply, and divide.
>>> 23+43
66
>>> 4-54
-50
>>> 87*45
3915
>>> 54/8
6.75
In python 3, Using the division operator / will always return a float. And whenever you use a float in your calculation, a float will be returned, even if the number is a whole number ending 0.
If you want to perform floor division to return an int, use // operator:
>>> 65//7
9
When using the // operator, you only return the whole number part of the division. Any digits after the decimal point will be removed.
Complex operator:
Python uses the exponent operator, **, to multiply a number to the power of another.
>>> 3**5
243
This code executes 2 to the power of 4.
>>> -4**4
-256
>>> 3**-3
0.037037037037037035
Python uses modulus operator, %, to return the remainder of a division.
>>> 34%2
0
>>> 34%3
1
34 divided by 3 equals 11 remainders 1. The modulus operator returns this remainder 1.
The execution order of the operator
When using more than one operator in python, it's crucial to understand the order they will be executed in.
 >>> 2+3**4/2-5
37.5
This expression is equivalent to:
2+((3**4)/2)-5
>>> 2+3*4/2-5
3.0
Here is the order of execution for python's operators(highest to lowest):
 OperatorName 
 ()Parenthesis 
 **Exponent 
 *,/,//,%Multiplication, division, floor division, modulus 
 +,-Addition, subtraction 

type() function:
Python has in built function type() to ascertain the data type of certain value. For example: enter type(5678) in python shell and it will return <class 'int'>, which means 5678 is an inter value.
>>> type(5678)
<class 'int'>
>>> type(43.4)
<class 'float'>
>>> type(2+4j)
<class 'complex'>
>>> type('ArdousGeek')
<class 'str'>