Unit-8 ( Programming Concept) Python
Language
Statements , Indentation
- There are different types of statements in
Python language as Assignment statements,
Conditional statements, Looping statements, etc.
- Statement in Python can be extended to one or more
lines using parentheses (), braces {}, square brackets [],
semi-colon (;), and continuation character slash (\).
- Python indentation refers to adding white space before
a statement to a particular block of code.
Variables
a 50
b a 50
What will be b?
Variables
Variables typically have a descriptive name that’s somehow
associated with a target value or object. This target value
can be of any data type. So, you can use variables to
represent numbers, strings, sequences, custom objects, and
more.
You can perform two main operations on a variable:
[Link] its value
[Link] it a new value
Math also has the concept of constants. The term refers to
a value or quantity that never changes. In programming,
Datatypes
Every value has a datatype, and variables can hold values.
Python is a powerfully composed language; consequently,
we don't have to characterize the sort of variable while
announcing it.
Data types are the classification or categorization of data
items. It represents the kind of value that tells what
operations can be performed on a particular data.
Datatypes
The following are the standard or built-in data types in
Python:
•Numeric
•Sequence Type
•Boolean
•Set
•Dictionary
•Binary Types
Datatype
Numeric Dictionary Boolean Char Sequence Type
integer string
Complex number list
float
Keywords
Operators
The operator is a symbol that performs a specific operation
between two operands, according to one definition.
• Arithmetic operators
• Comparison operators
• Logical Operators
• Membership Operators
• Identity Operators
Arithmetic operators
Comparison operators
Logical Operators or Boolean
Operators
Membership Operators
Identity Operators
Sequencing
Incorrect order lead to incorrect results.
Selection
Selection and Decision making is the most important
aspect of almost all the programming languages.
IF
temperature > 25
THEN
OUTPUT “ It is Hot”
Else
OUTPUT “ Good Temperature”
ENDIF
Iteration also known as looping
Three different types of structure :
1 . Count-controlled loop – for a set of number of
iteration.
2. Pre-condition loop – may have no iteration.
3. Post-condition loop – always has at least one
iteration.
String Handling
- String length
- Substring
-Uppercase
-Lowercase