Creating Comments in Python
Single Line Comment: Comments starts with a #
We can write comments at the beginning or at the end .
Multiline Comments
Variable Declaration
Rules for variable declaration
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive (age, Age and AGE are three different variables)
- A variable name cannot be any of the Python Keyword.
Data Types
Python Numeric Data Type
Int
Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.
Float
Float, or "floating point number" is a number, positive or negative, containing one or more decimals.
Float can also be scientific numbers with an "e" to indicate the power of 10
Complex
Complex numbers are written with a "j" as the imaginary part:
Boolean Type
If an expression is True
or False
.
The bool()
function allows you to evaluate any value, and give you True or False
in return,
Any string is True
, except empty strings.
Any number is True
, except 0
.
Any list, tuple, set, and dictionary are True
, except empty ones.
The following with return False
Note : Functions can return Boolean values as well.
Example
String Data Type
We can use single quotation marks, or double quotation marks.
'uday' or "uday".
No comments:
Post a Comment
Thank you for visiting my blog