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

 

  1. It would give error. Since, function name and variable name is same.
  2. Get all Questions and Answer from here
  3. You need to have paid subscription to access all questions
  4. 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.

 

 

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam