- 1
What is the answer
9 Answers
+ 3
That's great anuj, now I've learned something too
+ 4
=10
y =20
ifx>y:
print(statement)
else:
print (else)
I got the correct answer
+ 1
What is the question
+ 1
x=10
y =20
if(x>y)
print(statement)
else
print (else)
I don't know the correct syntax for python but it should look something like that
+ 1
Then correct me
0
x=10
y =20
_x>y_
print(statement)
____
print (else)
0
no bro worng
0
=10
y =20
ifx>y_
print(statement)
else:
print (else)
idk what after the y
0
You might want to go through this systematically :)
1. If you want to compare two "variables", they both need to exist and have a value. So, the first blank needs to be filled with x. This will give a proper assignment:
x = 10
2. if-clauses MUST end with a colon - that's the law ;-)
Consequently, the third line must be
if x > y:
Note that there must be a blank between "if" and "x", but we do not need parenthesis around the expression x > y. Python is not Java ;-) There are cases with multiple conditions where parentheses are necessary, but that's not the case here.
As far as the else clause is concerned, you will need the trailing colon again, followed by proper indentation of those statements that need to be executed in case the if-clause is evaluated to False and the else-clause kicks in.
I hope I made myself clear enough without providing the full solution (and spoiling the fun).