DS Lab 01
DS Lab 01
Basic Syntax
• The Python language has many similarities to Perl, C, and Java. However, there are some
definite differences between the languages.
• First code…
Identifiers
• Here are naming conventions for Python identifiers −
• Class names start with an uppercase letter. All other
identifiers start with a lowercase letter.
• Starting an identifier with a single leading underscore
indicates that the identifier is private.
• Starting an identifier with two leading underscores
indicates a strong private identifier.
• If the identifier also ends with two trailing underscores,
the identifier is a language-defined special name.
Lines and Indentation
Multiple
and terminate with a colon ( : ) and are followed by one
or more lines which make up the suite.
Statement
Groups as
Suites
• Variables are nothing but reserved memory locations to store
values. It means that when you create a variable, you reserve
some space in the memory.
• Based on the data type of a variable, the interpreter allocates
memory and decides what can be stored in the reserved
memory.
Types variables.
Assigning Values to
Variables
• Python variables do not need explicit
declaration to reserve memory space. The
declaration happens automatically when
you assign a value to a variable. The equal
sign (=) is used to assign values to
variables.
• The operand to the left of the = operator is
the name of the variable and the operand
to the right of the = operator is the value
stored in the variable.
Multiple Assignment
• Python allows you to assign a single value to several variables
simultaneously.
Standard Data Types
• The data stored in memory can be of many types. For example,
a person's age is stored as a numeric value and his or her
address is stored as alphanumeric characters. Python has
various standard data types that are used to define the
operations possible on them and the storage method for each
of them.
• Python has five standard data types:
• Numbers
• String
• List
• Tuple
• Dictionary
Python Numbers
• Number data types store numeric values. Number objects are
created when you assign a value to them.