Objective
To implement a program to read a number from user.
Instructions
The program reads a number from the user and its equivalent low-level language instructions executed by the hardware. The low-level language instructions used are:
- Declare a variable n1 to hold the user input.
- Get the number from the user using input function.
- The default data type of the user input is string. So 'int()' is used to convert the string type data into integer type.
- Finally print the user input in the console / screen.
in |
It reads the input from the user and stores it in a variable. |
out |
It prints the output value to the screen. |
Learning Outcomes
- Learn how to use the 'input()' function in Python to prompt the user for input and store the entered value in a variable.
- Understand the need for the 'int()' function and learn how it converts the user input (which is initially a string) into an integer data type.
- Explore how the 'print()' statement is used to display the entered number on the console, demonstrating the fundamental concept of output in Python.