Python · Basic Types & None

What does this print, and why isn't the result a plain `True`/`False`? ``` print(0 or "hello") print("a" and "b") ```

Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.

Get it on App StoreGet it on Google Play

This is one card from the KnowCard library — thousands more across SAP, Linux, Python and more. In the app you get the answer, AI explanations, and cards that come back right before you would forget them. Free to start on iOS, Android or the web.

More in Basic Types & None

You want to check whether a result is the "no value" sentinel. Why prefer if x is None: over if x == None:?
What is the type of None, and how many instances of it exist at runtime?
What does this print? ``` def greet(name): print("hi", name) result = greet("Sam") print(result) ```
What does this print? ``` nums = [3, 1, 2] result = nums.sort() print(result) ```
Is `None` truthy or falsy, and what does this print? ``` x = None if x: print("yes") else: print("no") ```
In Python, every value is an object with a type. What is the idea behind type(x), and what does type(5) return?

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play