Data Types
Data type is used to define the type of
value a data can contain.
1. Integer – whole numbers consisting of + or – sign
without decimal point.
num1=10
num2=-30
2. Float – represents floating point numbers which
contain decimal point.
val=12.5
3. String – sequence of characters used to store and
represent text-based information.
name=“reema”
pwd=‘reema@123’
Data Types
Try these and write the output
1. type(34)
2. type(15.5)
3. type(True)
4. type(“hello”) Sara
5. float(13)
6. int(14.45)
7. int(“1234”)
INPUT()
Input() is used to get input from user.
Input() functions always returns string value.
Syntax:
var_name=input(“string”)
Sara
INPUT()
Sara
INPUT()
Sara
INPUT()
Sara
Operators
Operators:
Operators are the special symbols that carry out
arithmetic and logical operations.
Operands:
The values operated by the operator
Sara
are called
operands.
Arithmetic Operator
Sara
Relational Operator
Sara
Logical Operator
Sara
Assignment Operator
Sara
Operator Precedence
Operator precedence determines the order in
which expressions are evaluated
Sara
Statements
Statement is the executable part of any
program. It is an instruction that the Python
interpreter executes and produces output.
3 types of statement:
i)Simple statement Sara
ii)Expression statement
iii)Compound statement
Statements
i)Simple statement
ii)Expression statement
iii)Compound statement
Sara
Control Structures
Control structures are used to control or change the flow
of execution.
Three basic Control Structures:
i) Sequential
ii) Conditional
iii) Loop
Indentation in Python(one
tab space)
Code blocks in python are defined by their indentation.
All the statements in conditional and looping statements
are structured using indentation.
Conditional Control
Structures
It tells the program which action to take based on a
certain condition.
4 Conditional Control
Structures
i) if
ii) if-else
iii) elif
iv) nested if-else
If Statement
i) If Statement
It executes the statements only when the
condition is true.
If Statement
i) If Statement
If-else Statement
If-else Statement
If-else Statement
If-else Statement
If-else Statement
If-else Statement
If-elif-else Statement
If-elif-else Statement
If-elif-else Statement
If-elif-else Statement
Nested If Statement
Nested if Statement
Nested If Statement
Example:
Thank you