πŸ“Š Python
Q. Which statement is used to define a block of code that runs only when the program is executed directly, not when imported?
  • (A) if __main__ == '__name__':
  • (B) if __name__ == '__main__':
  • (C) main():
  • (D) run()
πŸ’¬ Discuss
βœ… Correct Answer: (B) if __name__ == '__main__':

Explanation: The `if __name__ == '__main__':` block ensures the code runs only when the file is executed directly.

Explanation by: Rati Dubey
The `if __name__ == '__main__':` block ensures the code runs only when the file is executed directly.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
45
Total Visits
πŸ“½οΈ
4 mo ago
Published
πŸŽ–οΈ
Rati Dubey
Publisher
πŸ“ˆ
82%
Success Rate