Arithmetic operations on Bools?
Answer: B. False Solution: Let's go checking the if-condition, which is (3>2) > 1 Now remember that no matter what, attack the parenthesis first. So we solve (3>2), ie, True Expression simplifies to True > 1 It's a bit of a fix now. Because how to compare a bool with int? +
Not very often, but it can be applied. For example, you have a list like so li = [5, 7, 3, 2, 9] You want to count how many items are >5. You could use sum(x>5 for x in li) This works by creating a bool (x>5). If True, adds 1. Else adds 0. Effectively counting Trues. +
Another use is for "skipping terms" in sums by taking product with bools, like so interest_rate = general_interest_rate + (is_senior_citizen * extra_rate_for_senior_citizen) if is_senior_citizen is True, the value becomes the sum of 2 terms. Otherwise it's only the first term.
United States 트렌드
- 1. #NicolandriaxGlamour 3,825 posts
- 2. Good Thursday 32.8K posts
- 3. #DareYouToDeathEP1 556K posts
- 4. Happy Friday Eve N/A
- 5. #thursdayvibes 2,015 posts
- 6. Core CPI 3,466 posts
- 7. TAE Technologies N/A
- 8. #ThursdayThoughts 2,011 posts
- 9. Ally 32.5K posts
- 10. #thursdaymotivation 2,121 posts
- 11. Disturbed 7,219 posts
- 12. Cartoon Network 2,030 posts
- 13. Cardinal Dolan 1,472 posts
- 14. Newt 3,712 posts
- 15. Nickelodeon 2,124 posts
- 16. Davido 293K posts
- 17. Keith Richards 8,514 posts
- 18. Approve 32.4K posts
- 19. Garfunkel N/A
- 20. Warrior Dividend 36.7K posts
Something went wrong.
Something went wrong.