Sequence of Instructions
Sequence of Instructions
Program A program is a sequence of instructions given to a computer.
Defining a Variable
A variable gets created when you assign a value to it for the first time.
Code
Printing Value in a Variable
Code
Output
Code
Output
Variable name enclosed in quotes will print variable rather than the value in it. If you intend to print value, do not enclose the variable in quotes.
Order of Instructions
Python executes the code line-by-line.
Code
Output
Variable
Spacing in Python
Having spaces at the beginning of line causes errors.
Code
Output
Variable Assignment
Values in the variables can be changed.
Code
Output
Examples of Variable Assignment
Code
Output
Code
Output
Expression
An expression is a valid combination of values, variables and operators.
Examples a * b a + 2 5 2 + 3 4
BODMAS The standard order of evaluating an expression - Brackets (B) - Orders (O) - Division (D) - Multiplication (M) - Addition (A) - Subtraction (S)
Step by Step Explanation
Comments
Post a Comment