Japanese translation of self-study "A Beginner's Guide to Getting User Input in Python"

Original article URL https://hackernoon.com/a-beginners-guide-to-getting-user-input-in-python-141q312q

This is a translation for self-study, so please use it at your own risk.

A Beginner's Guide to Getting User Input in Python (How to enter data in Python)

January 8th 2021 January 8, 2021

29079D8A-0671-4DF0-8C5B-281A33731DFA.jpeg

@aswinbarath Aswin Barath Budding Software Engineer @aswinbarath Oswin Ballas Rookie software engineer

Getting input from the user is what makes a program more interactive with the user. Accepting input from the user makes the program more interactive to the user.

Hence, in python we have an input function: input(), to receive input from the user. So, to receive input from the user, Python has a function input () for input.

Take a look at an example. See the sample code below.

B5BDCCF8-EA2D-476F-9274-CC484680B005.png

Output: The screen output looks like this:

Enter any data:Happy new year!
Happy new year!

Input Function Under the Hood (Internal movement of the input function)

When input() function is encountered by python, the program will pause until the user enters data. When the Python interpreter executes the input () function, the program pauses until the user inputs data.

Later, any input entered by the user will be converted into a string. Let’s see another example to understand this point. Then, when the user enters some data, that data is converted to a string object. To understand this, take a look at the following sample code.

6CAC671F-E665-4AB1-B14C-FAB6DDB87812.png

Output: The screen output looks like this:

Enter any text: Have a great year ahead.
text: Have a great year ahead. , type: <class 'str'>
Enter any number: 2021
number: 2021 , type: <class 'str'>

So, in these cases make sure that you convert the input to your preferred data type using its corresponding constructors. Let’s see that example too. Therefore, in the above cases, it is necessary to convert the input data to the desired data type using the corresponding constructor (in this case, the conversion method if the beginner reads it). See also the sample code below.

80AAAEF2-C6AC-43C0-9C12-7A5EE17E0401.png

Output: The screen output looks like this:

Enter any number: 2021
number: 2021 , type: <class 'int'>

So, code along and have fun :) So let's enjoy coding! (^ v ^)

Recommended Posts

Japanese translation of self-study "A Beginner's Guide to Getting User Input in Python"
[For beginners] Summary of standard input in Python (with explanation)
Enabled to input Japanese in Linux environment (crostini) of Chromebook
How to develop in a virtual environment of Python [Memo]
How to get a list of built-in exceptions in python
I want to make input () a nice complement in python
[For beginners of competitive pros] Three input methods to remember when starting competitive programming in Python
What seems to be a template of the standard input part of the competition pro in python3
How to handle Japanese in Python
Try to get a list of breaking news threads in Python.
How to check the memory size of a variable in Python
How to check the memory size of a dictionary in Python
Implement a deterministic finite automaton in Python to determine multiples of 3
[Python] The role of the asterisk in front of the variable. Divide the input value and assign it to a variable
[Translation] scikit-learn 0.18 User Guide Table of Contents
Display a list of alphabets in Python 3
Comparison of Japanese conversion module in Python3
How to send a visualization image of data created in Python to Typetalk
How to install python package in local environment as a general user
How to get a stacktrace in python
I want to color a part of an Excel string in Python
Pandas User Guide "merge, join and concatenate" (Japanese translation of official documentation)
Getting started: 30 seconds to Keras Japanese translation
How to format a list of dictionaries (or instances) well in Python
I made a program to check the size of a file in Python
[Python] [Word] [python-docx] Try to create a template of a word sentence in Python using python-docx
I tried to implement a card game of playing cards in Python
Japanese translation: PEP 20 --The Zen of Python
Various ways to read the last line of a csv file in Python
How to pass the execution result of a shell command in a list in Python
How to mention a user group in slack notification, how to check the id of the user group
Python script to get a list of input examples for the AtCoder contest
Basic data frame operations written by beginners in a week of learning Python
How to get a list of files in the same directory with python
Draw a graph of a quadratic function in Python
Try to calculate a statistical problem in Python
How to clear tuples in a list (Python)
To execute a Python enumerate function in JavaScript
How to embed a variable in a python string
Summary of how to import files in Python 3
Get the caller of a function in Python
I want to create a window in Python
How to create a JSON file in Python
Make a copy of the list in Python
Rewriting elements in a loop of lists (Python)
A clever way to time processing in Python
Steps to develop a web application in Python
Try to calculate RPN in Python (for beginners)
Getting rid of DICOM images in Python Part 2
To add a module to python put in Julialang
How to notify a Discord channel in Python
Make a joyplot-like plot of R in python
Output in the form of a python array
Get a glimpse of machine learning in Python
[Python] How to draw a histogram in Matplotlib
Prime factorization ver.2 of integers input in Python
How to hide user input in PySimple GUI
A well-prepared record of data analysis in Python
Basic story of inheritance in Python (for beginners)
How to identify the element with the smallest number of characters in a Python list?
A story of trial and error trying to create a dynamic user group in Slack