Python 3.6 - Points to remember
Points to remember
·
A variable is any location in the computer’s
memory which holds a value.
·
Python is memory efficient when dealing with
variables as compared to other programming languages.
·
An identifier is a name given to a variable,
function, class, list, tuple etc. Identifiers are used to identify things in
Python.
·
Keywords are reserved words in Python that have
some special meaning and they can only be used for pre-defined purpose.
·
Comments are always used to describe the
features of a program and ignored by Python compiler and interpreter.
·
‘#’ symbol is used to create a single line
comment.
·
Python does not recommend Triple double quotes
(“””) or triple single quotes (‘’’) as multi line comment.
·
If triple double quotes (“””) or triple single
quotes (‘’’) are written as the first statement of a class, function, module
etc., then they are called Docstrings and can be used to create API files.
·
Datatype represents the type of data such as
int, float, str, list, tuple, dictionary etc.
·
There are two types of datatypes – built-in and user-defined.
Datatypes that are already defined by Python team are called built-in and
datatypes that are defined by user are called user-defined datatypes.
·
Datatype |
Characteristic |
int |
Immutable |
float |
Immutable |
str (string) |
Immutable |
list |
Mutable |
tuple |
Immutable |
dictionary |
Mutable |
set |
Mutable |
range |
Immutable |
frozenset |
Immutable |
·
Conditions in Python internally evaluate to
Boolean type i.e. True or False.
·
Indexing can be used to access a single element
of a sequence at a time and slicing can be used to access a part or slice of
sequence at a time.
·
Index in Python always starts from 0.
·
Reverse index always begins with -1.
·
Python does not support constants.
·
The value stored into a variable is called
literal.
·
A binary literal is represented using 0b or 0B
in the beginning of a number.
·
An octal literal is represented using 0o or 0O
in the beginning of a number.
·
A hexadecimal literal is represented using 0x or
0X in the beginning of a number.
·
We write strings in double or single quotes. And
if a string spans more than one line then we can use triple single or triple
double quotes.
·
A list is a collection of heterogeneous
(different types of) elements and used to store large collection of data. List
elements are written using square brackets [ ].
·
A tuple is similar to a list but tuple is
immutable (elements cannot be modified) and can be created using parentheses (
).
·
The range type is a collection or sequence of
numbers and generally used with for loop. A range can be created using range( )
function.
·
A set is an unordered collection of elements and
does not allow duplicate values. A set is created using curly braces { }.
·
We can use the type() function to determine the
type of any object such as variable.
·
Python does not have concept of constants but
you can write a constant name in all capital letters for your convenience.
·
Python has no datatype to represent single
character.
Comments
Post a Comment