As the name implies, a variable is something which can change. A variable is a way of referring to a memory location used by a computer program. A variable is a symbolic name for this physical location. This memory location contains values, like numbers, text or more complicated types.
Please note important point for Python. It does not have a command for declaring a variable. A variable is created the moment you first assign a value to it.
first_Name = 'your name' y ='techTrekk' password1 ='password string' n00b = 'ac' un_der_scores = 'sample text'
Variables Naming convention
- Variables names must start with a letter or an underscore but not with number
- A variable name cannot start with a number
- A variable name can contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Names are case sensitive.
casesensitive, CASESENSITIVE, case_sensitive and Case_Sensitive are each a different variable.
See Python PEP 8.
Function names should be lowercase, with words separated by underscores as necessary to improve readability. mixedCase is allowed only in contexts where that’s already the prevailing style
Variable name chosen should be “mnemonic”, meaning, by variable name itself, reader should be able to understand what this variable is for. e.g. It is not convenient to store first name in first_name instead of abx123 or abc
Operators are special symbols that represent computations like additions and subtraction. The value these operators are applied to are called as operands.
Python follows PEDMAS rule
An express is combination of values, variable and operators
>>> 1+4 5
A statement is used to form the sequence of a program (e.g. if-then , while-do statements).
A statement can be simple or complex and can contain 0 or more expression
As program becomes bigger, it becomes difficult to track which part is doing what. For this reason, it is a good idea to add notes to the program. Notes can be added as a comments. Comment does not get execute or compile in program. Comments in python can be added two ways.
Hash Sign (# )
Anything mention after hash symbol(#) is considered as comment. This is limited to the same line where this symbol is added
MULTI LINE comments
Multi line comments can be added by triple double inverted commas. To close the comment, triple inverted comma’s needs to be added again. This method is primarily used for function clarification.