0
Basic def and if python question
I have written some pretty basic code here just trying to get it to tell me if x squared + 4 is less than 20 for a given x. ************************** 1 def f(x): 2 print((x**2) + 4) 3 4 x = 2 5 6 if f(x) < 20 7 print("true") ************************** It keeps telling me syntax error on line 6 which is the “if” line and pointing to the “20” though that sometimes changes. I’ve tried different combinations of spaces and notations, I began with “if f(4) == 20 print(“true”)” And changed it from there but still haven’t got a true back. Thanks guys!
2 Antworten
+ 4
if f(x) < 20:
print("True")
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2277/
+ 1
def f(x):
return x**2 + 4
x = 2
if f(x) < 20:
print("true")