[GO] Let's see using input in python

Target audience of the article

・ People who want to see using input ・ People who are in trouble due to errors in usage

Know how to use input

I will explain after writing the code first.

age = input("Please enter your age")
typle(age)

#Execution result
Please enter your age 50

str

First of all, we create a variable that stores the input of input (here we use age) and use = to assign the input result to the variable. After that, enter a message in parentheses that prompts you to enter it, and you're done. However, since all the arguments returned by input are str type (type that stores character strings), it is not possible to input a numerical value and calculate based on that numerical value as it is, so the following code Please hit and see

age = float(input("Please enter your age"))
type(age)

if age >= 20:
  print("I'm an adult! !!")
else:
  print("I'm a kid! !!")

#Execution result
Please enter your age 10
I'm a kid! !!

By enclosing the output of input in float type, it can be handled as a numerical value. Finally, let's play with the graph. ![Screenshot 2020-08-27 23.22.15.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/581846/a780a2d1-f664-640f-a024- 1d44e4e4b9d7.png) Paste it in the code and run it.

    import numpy as np
    import matplotlib.pyplot as plt

    #Determine variables
    a = float(input("a * x - b to 'a'"))
    b = float(input("a * x - b to 'b'"))

    x = np.arange(-10, 10)
    y = a * x - b
    plt.ylim([-10, 10])
    plt.grid()
    plt.plot(x, y) 

Recommended Posts

Let's see using input in python
Key input in Python
Key input in Python
Let's judge emotions using Emotion API in Python
Let's use def in python
Python Input Note in AtCoder
Translate using googletrans in Python
Let's find pi in Python
Using Python mode in Processing
GUI programming in Python using Appjar
Precautions when using pit in Python
Let's run "python -m antigravity" in python
Try using LevelDB in Python (plyvel)
Let's try Fizz Buzz in Python
Using global variables in python functions
Infinite product in Python (using functools)
Edit videos in Python using MoviePy
Handwriting recognition using KNN in Python
Try using Leap Motion in Python
Depth-first search using stack in Python
When using regular expressions in Python
GUI creation in python using tkinter 2
Mouse operation using Windows API in Python
Notes using cChardet and python3-chardet in Python 3.3.1.
Try using the Wunderlist API in Python
Data input / output in Python (CSV, JSON)
GUI creation in python using tkinter part 1
Get Suica balance in Python (using libpafe)
(Bad) practice of using this in Python
Slowly hash passwords using bcrypt in Python
Try using the Kraken API in Python
Using venv in Windows + Docker environment [Python]
[FX] Hit oanda-API in Python using Docker
[Python] [Windows] Serial communication in Python using DLL
I tried using Bayesian Optimization in Python
Log in to Slack using requests in Python
Get Youtube data in Python using Youtube Data API
Using physical constants in Python scipy.constants ~ constants e ~
Scraping a website using JavaScript in Python
Develop slack bot in python using chat.postMessage
Write python modules in fortran using f2py
Draw a tree in Python 3 using graphviz
Notes for using python (pydev) in eclipse
Disease classification in Random Forest using Python
Let's make a combination calculation in Python
Download files in any format using Python
Parallel task execution using concurrent.futures in Python
Notes on using code formatter in Python
Meaning of using DI framework in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
[Python] Standard input
Epoch in Python
Discord in Python