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. White Sox 11K posts
- 2. #AskFFT N/A
- 3. Murakami 13.9K posts
- 4. Happy Winter Solstice 10.1K posts
- 5. Good Sunday 71.6K posts
- 6. #sundayvibes 4,960 posts
- 7. Estime 5,739 posts
- 8. #FirstDayOfWinter N/A
- 9. Villarreal 15.2K posts
- 10. Ugarte 4,758 posts
- 11. Full PPR 1,173 posts
- 12. Todd Blanche 7,429 posts
- 13. Victory Sunday 3,584 posts
- 14. #AskBetr N/A
- 15. Okamoto 1,956 posts
- 16. Brissett N/A
- 17. #ATSD 1,747 posts
- 18. Muhammad Qasim 36.6K posts
- 19. Balde 4,917 posts
- 20. Dowdle 1,144 posts
Something went wrong.
Something went wrong.