Question-143: What would happen, when you run below code
def calculate():
print("You are trying to calculate")
i=0
calculate=1
while(i<10):
print(calculate)
i=i+1
- It would give error. Since, function name and variable name is same.
- Get all Questions and Answer from here
- You need to have paid subscription to access all questions
- Thanks for considering Python Certification Material
Answer: C
Exp:
Never use the same variable name and function name
- You should not use same name as function and variable in same program.
- In below code your function can never/ever be called. Because, you have created a variable with the same name as function. Which overwrites function as variable. (Not a good practice, don’t do that).
def calculate(): print("You are trying to calculate")
i=0 You can access to full explanation to question and answer from this page. |