抱歉,我无法找到更好的表达方式,所以基本上我试图创建一个自动完成数学问题的脚本,但现在我已经卡住了,无法在论坛上找到一个好的答案。
这是它的外观
print("That's how you type the function : f(x) = a*sin(b(x-h))+k\nDon't use space!")
print("If the value of the variable is unknown type 'None'")
import math
def start():
y= input("y = ")
sct = input("sin, cos, tan = ")
a= input("a = ")
b= input("b = ")
x= input("x = ")
h= input("h = ")
k= input("k = ")
print("So if I understand here the problem you want to solve")
print(y,"=",a,sct,"(",b,"(",x, "-" ,h,"))",k)
QUA = input("Yes or No? : ")
if QUA == "Yes":
print("Good")
elif QUA == "No":
start()
start()
所以我所坚持的部分是我问一个问题,如果你说"是"它继续剧本。如果你说'#34;不"它回到开始()。因此,当我尝试使用变量时,它只是说
>>> print(y)
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
print(y)
NameError: name 'y' is not defined
帮助任何人?
答案 0 :(得分:0)
您将其退回,否则无法在您的函数范围之外访问它。
class CheckToken extends React.Component {
constructor() {
this.state = { isLogged: false}
}
componentDidMount() {
fetch(url).then(res => res.text()).then(token => this.setState({isLogged: token})
}
render() {
return this.state.isLogged ? <Route path='/terms' component={TermsAndConditionsPage}/> : null
}
}
如果您需要多个返回值,则可以返回多个。
def start():
y = input("y = ")
return y
y = start()
print(y)