Variables are the character(s) used to store a value to be used further in the program. For example, when you want to store roll number of a student in the program then we use some variables to store roll number data:
Roll_no = 35
In the above statement we use an identifier(Roll_no) to store roll number of a student of integer type. Then we can call Roll_no a numeric variable.
Em_name = "Ricc"
Then we can call Em_name a string variable.
IMPORTANT:
In Python, you cannot use integer, float, complex number, expression as a variable as it will raise an error. You can only use characters, or identifiers to store any value.
For example:
36=Id
25=x
2a/c=20
In Python, you can use multiple assignments. #that's nice
For example:
A,B,C=5,10,15
x=y=z=50
Dynamic Typing
A variable who is used to store a value of one type, can be used again to store a value of different type. Python uses Dynamic Typing.
For example:
x=5
print(x)
x=10.5
print(x)
x="PyCodeWiz"
print(x)
Then the output will be as follows:
510.5
PyCodeWiz
Types Of Literals
(i) Numeric Literal : In Python , you can use integers, float or complex numbers as numeric literals.
Integers are the whole numbers without decimal having either positive(+) or negative(-) sign. A number without sign considered as positive.
For example: +49, -345, 89, -99,etc.
Floats are real numbers and always contain decimal point or fractional part.
For example: 5.35, -50.1, 99.99, etc.
Complex numbers are the numbers of form a+ib, where a and b are int or float type, i represents the imaginary number. a is real part of complex number and b is the imaginary part of the complex number.
(ii) String Literals : In Python, character(s) which are enclosed in quotes(single quote(') or double quote(") ).
(iii) Boolean Literals : In Python, Boolean literals are used to store either True or False. True are False are the only boolean literal value.
(iv) None Literal(Special Literal) : Python has one special literal, which is None Literal. The None Literal is used to represent or points absence of value. None means nothing.
Types Of Operators
(i) Arithmetic Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponent
// Floor Division
% Modulus
(ii) Logical Operators:
or Logical OR
and Logical AND
(iii) Membership Operators:
in whether the character in sequence
not in whether the character not in sequence
(iv) Relational Operators:
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to
(v) Bitwise Operators:
| Bitwise OR
& Bitwise AND
^ Bitwise XOR
(vi) Assignment Operators:
= Assignment
+= Assign sum
-= Assign difference
*= Assign Product
/= Assign quotient
%= Assign remainder
**= Assign exponent
//= Assign floor division
(vii) Identity Operators:
is is identity same?
is not is identity not same?
If you have any queries, feel free to ask.
YOU ARE READING
Learn Python
RandomCome here to learn Python programming language. All the basics of Python programming language here.
