Python 3D Academyবাংলা

Input & Type Conversion in Python

Chapter 5: Input & Type Conversion

4 short lessons, with 3D animations, quizzes and coding tasks.

The lessons

  1. Asking questions with input()

    input() shows a prompt, waits for the user to type a line and press Enter, and gives back what they typed as a str.

  2. Changing types: int(), float() and str()

    int(), float() and str() build a new value of another type from the value you give them, if it can be read that way.

  3. Numbers from input()

    int(input(...)) asks a question and turns the answer into a number straight away, because Python works from the inside out.

  4. True or False? bool() and truthiness

    bool() turns any value into True or False: empty or zero is False, and everything else is True.