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 Tendenze
- 1. TravisScott 6,170 posts
- 2. #FanCashDropPromotion 1,183 posts
- 3. Merry Christmas 151K posts
- 4. Good Friday 53K posts
- 5. Tucker 123K posts
- 6. Isiah 1,899 posts
- 7. Matt Strahm N/A
- 8. Lifesaving 4,673 posts
- 9. #FridayVibes 3,563 posts
- 10. Ben Shapiro 67.6K posts
- 11. #FridayMotivation 2,844 posts
- 12. #FridayFeeling 2,416 posts
- 13. #FursuitFriday 11.8K posts
- 14. RED Friday 2,645 posts
- 15. DataHaven 24.2K posts
- 16. Algorhythm Holdings N/A
- 17. Happy Friyay 1,106 posts
- 18. Myrtle Beach Bowl N/A
- 19. Boomer Sooner N/A
- 20. Son of God 14.7K posts
Something went wrong.
Something went wrong.