您好,能用python 帮我解决这些问题吗

img


这是问题的列表,,能帮我解决吗?需要很快的时间,麻烦各位了!!


import numpy as np
from matplotlib import pyplot as plt

x = np.arange(-10, 10, 0.1)
y = x
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("f(x)=x")
plt.plot(x, y)
plt.show()

x = np.arange(-10, 10, 0.1)
y = x ** 2
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("f(x)=x^2")
plt.plot(x, y)
plt.show()

x = np.arange(-10, 10, 0.1)
y = x ** 3
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("f(x)=x^3")
plt.plot(x, y)
plt.show()

x = np.arange(-10, 10, 0.1)
y = x ** 0.5
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("f(x)=x^0.5")
plt.plot(x, y)
plt.show()

x = np.arange(-10, 10, 0.1)
y = np.log(1/x)
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title("f(x)=ln(x)")
plt.plot(x, y)
plt.show()


import numpy as np
from matplotlib import pyplot as plt

data = {
    'f(x)=x': lambda x: x,
    'f(x) = x2': lambda x: pow(x, 2),
    'f(x) = x3': lambda x: pow(x, 3),
    'f(x) = Vx': lambda x: np.sqrt(x),
    'f(x) = ln(x)': lambda x: np.log(x),
    'f(x) = sin(x)': lambda x: np.sin(x),
    'f(x) = cos(x)': lambda x: np.cos(x),
    'f(x) = tan(x)': lambda x: np.tan(x),
    'f(x) = cot(x)': lambda x: np.arctan(x),
    'f(x) = | l': lambda x: abs(x),
    'f(x) = 1 / x': lambda x: 1 / x,
    'f(x) = é**x': lambda x: np.exp(x),
    'f(x) = x + 1': lambda x: x + 1,
    'f(x) = x/3': lambda x: x / 3,
}

for i in data:
    x = np.arange(1, 20, 0.1)
    y = data[i](x)
    plt.xlabel('x')
    plt.ylabel('y')
    plt.title(i)
    plt.plot(x, y)
    plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-5,5,100)
y = x
plt.plot(x, y, '-r', label='y=x')
plt.title('Graph of y=x')
plt.xlabel('x', color='#1C2833')
plt.ylabel('y', color='#1C2833')
plt.legend(loc='upper left')
plt.grid()
plt.show()

img

https://blog.csdn.net/manchan4869/article/details/117295396

import math

# f(x) = x
def f(x):
   return x

# f(x) = x2
def f(x):
   return x**2

# f(x) = x3
def f(x):
   return x**3

# f(x) = 根号x
def f(x):
   return x ** 0.5

# f(x) = ln(x)
def f(x):
   return math.log(x)

# f(x) = sin(x)
def f(x):
   return math.sin(x)

# f(x) = cos(x)
def f(x):
   return math.cos(x)

# f(x) = tan(x)
def f(x):
   return math.tan(x)

# f(x) = cot(x)
def f(x):
   return 1/(math.tan(x))

# f(x) = |x|
def f(x):
   return abs(x)

# f(x) = 1/x
def f(x):
   return 1/x

# f(x) = ex
def f(x):
   return math.e ** x

# f(x) = x+1
def f(x):
   return x+1

# f(x) = x/3
def f(x):
   return x/3

import numpy as np
import math

f(x) = x

def fun_one():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x)
except Exception:
print("输入内容不符")

f(x) = x2

def fun_two():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x ** 2)
except Exception as e:
print("输入内容不符")

f(x) = x3

def fun_three():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x ** 3)
except Exception as e:
print("输入内容不符")

f(x) = Vx

def fun_four():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x ** 0.5)
except Exception as e:
print("输入内容不符")

f(x) = ln(x)

def fun_five():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(np.log(x))
except Exception as e:
print("输入内容不符")

f(x) = sin(x)

def fun_six():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(math.sin(x))
except Exception as e:
print("输入内容不符")

f(x) = COS(x)

def fun_seven():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(math.cos(x))
except Exception as e:
print("输入内容不符")

f(x) = tan(x)

def fun_eight():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(math.tan(x))
except Exception as e:
print("输入内容不符")

f(x) = cot(x)

def fun_nine():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(np.arctan(x))
except Exception as e:
print("输入内容不符")

f(x) = | l

def fun_twelve():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(abs(x))
except Exception as e:
print("输入内容不符")

f(x) = 1 / x

def fun_thirteen():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(1/x)
except Exception as e:
print("输入内容不符")

f(x) = é**x

def fun_fourteen():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(math.exp(x))
except Exception as e:
print("输入内容不符")

f(x) = x + 1

def fun_fifteen():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x+1)
except Exception as e:
print("输入内容不符")

f(x) = x/3

def fun_sixteen():
try:
x = float(input("请输入x的值(必须是数值型):"))
print(x/3)
except Exception as e:
print("输入内容不符")

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632