Page 251 - AI Computer 10
P. 251
Example:
u Explicit Type Conversion: In Explicit Type Conversion, users convert the data type of an object to required
data type. You can use the predefined functions like int(), float(), str(), bool (), complex(), tuple(), etc. to
perform explicit type conversion. This type of conversion is also called typecasting because the user casts
(changes) the data type of the objects.
Example:
Input() function
The input() function is used to accept input value from the user. When this statement executes, the flow of the
program stops until user enters the value at blinking cursor position. Note that the input given by the user is
always considered as a string value. To accept the input value as integer or flow. We type cast the entered value
bu using input() function in the int() or float() function receptively.
Example:
Conditional Statements
Conditional statements are structures within the code that can execute different IF <conditi on> False
lines of code on the basis of specified condition.
If Statement
If statement tests a particular or specific condition. If the condition evaluates to True
True, it carries out the execution of a set of instructions inside the body of ‘if’ and Statements
if the condition evaluates to False, it does nothing.
117
117