Hello World!!! It’s JITHU….. Welcome back to the day-5 of your programming life. As you know that programming is the key skill nowadays, But why only python as it simple and good for the beginners, That’s it??? Not really Because it consists of a lot of rich libraries that make our work a lot simpler.OK let me stop this and dive into our DAY-5 Tutorial.
Value and Types:
First, what does the value means in the real world? For example, take a Blue edition of Harley-Davidson Bike when anyone asks what does it value? It costs around 13C OMG!!!! Yeap that’s the value. In PYTHON the main value types are 3. They are 1]INT ( 10 ) 2]Float ( 10.0 ) 3]STRING ( “TEN” ).
1]INT: The name itself says that it is an INTEGER value it might be both +VE and -VE values, But it doesn’t contain any decimal points.
2] FLOAT: It is similar to the INT but it gives the exact value of the Value. That means it consists of the decimal points.
3]STRING: This comes under normal English. But we have to assign it in between the Parathesis. NOTE: If you enter the INT value in between the parathesis, then PYHTON consider it as a STRING.
If you are not sure what type a value has, the interpreter can tell you.
>> type(‘Hello, World!’)
Variable!!!!! what does it mean??????????? OK, I will explain it. For example, thinking you’re filling a form you have to fill some details. You will enter your NAME where there is a place provided for the NAME BOX. Yeap you got me… Here your name is stored in the variable name NAME. These are nothing but the memory space created by the python according to the user. For example, you want to create a variable and assign a value to it.
>>> a=5 #Here the a is variable/memory location that stores the value 5.
Variable names contain some rules:
1. Variables should not start with numbers.
2. There should contain any special characters.
3. It should not contain Keywords
What are KEYWORDS?? KEYWORDS are nothing but the reserved words that are cant be used as Variable names.
Let us see the list of KEYWORDS…..
[‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]
There are 33 keywords.
It is a unit of code that executes by the Python Interpreter. 2 kinds of statements, 1] Expression statement and 2] Assignment statement. An expression statement is a statement that consists of an expression. A script usually contains a sequence of statements. If there is more than one statement, the results appear one at a time as the statements execute.
>>x=5 #Assingnment statement
>>x=x+5 # expression statement
Assignment statements produce no output.
Operators and Operands:
Operators are special symbols that represent computations like addition and multiplication. The values the operator is applied to are called operands.
+ ==> Addition >>> 5 + 4 = 9
– ==> Subtraction >>> 5 – 4 =1
* ==> Multiply >>> 5 * 4 = 20
/ ==> Division >>> 20 / 2 =10
** ==> Exponentation >>> 2 **3 = 8
% ==> Modulus >>> 2 % 3 = 2
These operators are executed according to the precedence.
1]It operators from left to right.
2] It is operators according to the PEMDAS….
i] P—> Parathesis
ii] E —> Exponentation
iii] M—> Multiplication
iv] D—> Division
v] A—> Addition
vi] S—> Subraction
An expression is a combination of values, variables, and operators.If you type an expression in interactive mode, the interpreter evaluates it and displays the result:
>>> 1 + 1
Basically, the variable names taken by the beginners are like a, b, c, d…….. so on. But it is a wrong way better start with the mnemonic variable names.
Mnemonic variable names:
These are nothing but taking the variable names according to the problem.
>>>print(c) >>>print(“area of the rectangle”)