Python Literal's & Unicode Encoding
At this page we are going to look at Literals & Unicode Encoding. If you guys wanna check out previous basic concepts such as Variable's & Datatypes go check out my previous post.
3.) Literal's :
Literal's are sequence of characters that means/stands for itself.
eg:
Numbers : 5,10,15,8.9
Strings : "Hello",'World'
Boolean : True,False
Now basically there are different types of literals :
- Integer
- Float
- String
- Boolean
(i) Integer Literal's :
- Sequence of digit without decimal points.
- Optionally we can use signs i.e (+/-).
- No other special characters are allowed.
eg :
x = 25 ✔
y = +25 ✔
z = 25550 ✔
a = 12.5 ✘
b = 12,000 ✘
c = $500 ✘
(ii) Floating Point Literal's :
- Will be real numbers ( will have decimal point ).
- Optionally we can use signs i.e (+/-).
- Floating point value in python are double precision i.e they have 16 to 17 digits of precision in expressing a decimal number.
- The range of floating points is 10^(-308) to 10^(308).
- The floating point can be expressed in 2 form :
a.) Decimal / scientific notation : 25.36987
b.) Exponential notation : if the number is " 2.5 x 10^(-3) " we express it as 2.5e^(-3)
(iii) String Literal's :
String literal's are sequence of character enclosed in either 'single_quotes' or "double_quotes".
eg : 'Home',"Hello"
(iv) Boolean Literals :
There are 2 boolean values i.e True & False. But not true & false remember python is case sensitive.
4.) Unicode Encoding :
Encoding some used for representing characters in a computer system.
Capital Alphabets : A → 65 , B → 66 , ... , Z → 90
Small Alphabets : a → 97 , b → 98 , ... , z → 122
Numbers : 0 → 48 , 1 → 49 , ... , 9 → 57
space : 32
Special character : 37 , ... , 47
There are 2 functions to use unicode encoding :
(i) ord() → order
(ii) chr() → character
No comments:
No Spamming and No Offensive Language