Answer: A) hello In Python, the if statement evaluates the truthiness of an expression. An empty string '' or an empty list [] would be considered "falsy," while any non-empty string, including a string containing only the digit '0' like '0', is considered "truthy."
"hello" because the zero is a string, so it's a non-null/"truthy" value. If the zero were an int, it would evaluate to False and then "world" would be printed.
It's A if you understand truthy and falsy values and in Python, any non empty string is a truthy value
'hello' is the result. The reason is because you are giving it nothing, so it is 0.
hello Because 0 here is a string not an integer so it's = True
Hello because in Python any non-empty string is true If "0" is non-empty string.
>>> if 0: ... print("hello!") ... else: ... print("world!") ... world! >>> if 1: ... print("hello!") ... else: ... print("world!") ... hello!
As a js learner i'd say A) hello. Cuz a string is evaluated true.
Why would you want to do anything like that? 🙄 I get the coding/mental exercise but that is more like an error statement than a real life application.
United States 트렌드
- 1. National Guard 306K posts
- 2. Thanksgiving 492K posts
- 3. Afghan 39.1K posts
- 4. Cease 21.3K posts
- 5. Blue Jays 8,202 posts
- 6. Blood 191K posts
- 7. Arsenal 505K posts
- 8. Liverpool 161K posts
- 9. Slot 131K posts
- 10. Rahmanullah Lakanwal 3,485 posts
- 11. #StrangerThings5 28.2K posts
- 12. Frank Ragnow 9,067 posts
- 13. Al Sharpton 4,783 posts
- 14. Bayern 259K posts
- 15. Derrick White N/A
- 16. Seditious Six 139K posts
- 17. #triplegobble N/A
- 18. Neuer 26.7K posts
- 19. Insurrection Act 9,174 posts
- 20. #LightningStrikes N/A
Something went wrong.
Something went wrong.