Q. Following code is giving an error at line number 6. Why is this error occurring? What is the solution?


1. def c_to_f(c):
2. result = c/5.0 * 9 + 32
3. return result
4.
5. tempf = c_to_f(19)
6. print(result)


Reason :-
Corrected code :-


Answer :-


Reason :- variable result is in function c_to_f()


Corrected code :-

def c_to_f(c):
    result = c/5.0 * 9 + 32
    return result

tempf = c_to_f(19)
print (tempf)

Output :-


66.19999999999999
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post