・ People who want to see using input ・ People who are in trouble due to errors in usage
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