Page 55 - Computer - 7
P. 55
Lab Activity 6
Experiential Learning
Program to illustrate the use of Concatenation and Replication operator.
1. Type the code as shown in the image in the Python Editor.
2. Press the F5 key to execute the code. Sample output of the program is given.
Lab Activity 7 Experiential Learning
Program to accept the value of base and altitude of a triangle from the user and calculate its area.
1. Type the code as shown in the image in the Python Editor.
2. Press the F5 key to execute the code. Sample output of the program is given.
Knowledge Discovery Subject Enrichment
Python implements automatic data conversion from one data type to another. For example, if one value
in an expression is an integer, while the other is a float value, it will convert all the values to float data type
and evaluate the result.
PRECEDENCE OF OPERATORS
An expression in Python can comprise multiple operators and operands. To evaluate such expressions
correctly, it is important to know which operator will be evaluated earlier and which will be evaluated
later. Python defines the order of evaluation of different operators in an expression. This is called the
Rule of Precedence. A higher-level precedence operator is evaluated before an operator of lower-level
precedence. In case, operators have the same precedence level, they are evaluated from left to right in
the expression.
53