data type conversion

Cards (16)

  • Type conversion is the process of converting the value of one data type to another.
  • Type conversion is of two types in Python: implicit conversion and explicit conversion.
  • Implicit conversion is a type of conversion in which Python does the conversion without the involvement of the programmer which usually done to avoid loss of data.
  • Python always converts smaller data types to larger data types to avoid data loss.
  • Explicit conversion is a type of conversion of one data type to another that is done by the programmer.
  • The syntax for conversion is given as follows:
    <required_dataType>([value])
  • Python does not allow adding an integer number with a string.
  • If the numbers stored in the integer and the string variables are to be added up, an explicit type conversion hasto be used.
  • A statement is an instruction that the Python interpreter executes.
  • instructions are the orders or commands that the computer follows to do something.
  • Assignment and print() statements are the two types of statements
  • An assignment statement assigns value to a variable while a print() statement displays the value that is given to it.
  • it is only the print statement that produces an output.
  • Expressions are what the Python interpreter evaluates to produce some value.
  • An expression could be a simple literal value, a variable, or something more complex which is a combination of literals, variables, and operators
  • expressions in the above table are those encircled withred.