Q. Find the error(s) in the following code fragment. Correct the code to make it executable.
1. x = 0
2. y = 5
3. if x == 1, y < 10:
4. print ("Matched!!")
5. print ("*****")
6. else:
7. print ("No match")
8. print ("####")
Error :-
Correct code :-
Answer :-
Error in following Lines :-
In line 3 there should ‘or’ operator not comma.
In line 5, print statement is not as per syntax.
In line 7, print statement is not as per syntax.
Correct code :-
x = 0 y = 5 if x == 1 or y < 10: print ("Matched!!") print ("*****") else: print ("No match") print ("####")
Output :-
Matched!!
*****
>>>
OR
x = 0 y = 5 if x == 1 and y < 10: print ("Matched!!") print ("*****") else: print ("No match") print ("####")
Output :-
No match
####
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )