Post

Python Developer
Python Developer@PythonDvz·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
51
19
139
12.8K
Sergei Kotov
Sergei Kotov@kotov_dev·
@Python_Dv Answer: A) 2 The boolean arithmetic trap! › In Python, True = 1 and False = 0 › True + True + False = 1 + 1 + 0 = 2 For beginners: Booleans are a subclass of int and you can use them in arithmetic operations.
English
0
0
0
570
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv The correct answer is A) 2. In Python, True and False are boolean values that are treated as integers in arithmetic operations. True is equivalent to the integer 1, and False is equivalent to the integer 0. Therefore, the expression True + True + False is
English
0
0
0
562
World of SQL
World of SQL@SQL_feed·
@Python_Dv In Python, True = 1 and False = 0. True + True + False = 1 + 1 + 0 = 2
English
0
0
0
744
TJ Greene
TJ Greene@K1NGD1NG4L1NG·
@Python_Dv A)2 While I've been using python off and on for years, I've just recently decided to start actually learning to code with it proper. That is to say, I suspected the answer was A or C, so I tried it myself and A was correct. Learning everyday
English
0
0
0
88
Loïc andréas Ndoko essoke
Loïc andréas Ndoko essoke@LoicNdoko·
@Python_Dv The output is **2**. In Python, `True` is equal to `1` and `False` is equal to `0`. The operation is therefore `1 + 1 + 0`, which results in `2`.
English
0
0
0
154
yas🐉
yas🐉@FlyingCircus_py·
@Python_Dv A)2 EXPLANATION in python True has a value of and False has a value of 0. True + True + False = 1 + 1 + 0 = 2
English
0
0
0
46
Omo Yewa
Omo Yewa@AceKelm·
@Python_Dv A. 2. In python, True and False are categorised as Boolean data types. But in arithmetic operations, they are seen as 1 and 0. So for the operation above when you substitute 1 and 0 for true and false respectively, the output would be 2. Because 1 + 1 + 0 = 2.
English
0
0
0
239
Code Fiend
Code Fiend@xannycodes·
@Python_Dv I’m not a python programmer but i think it’s 2 False = 0 True= 1
English
0
0
0
242
Gk
Gk@Gk54259045·
@Python_Dv A) 2 Because TRUE = 1, FALSE = 0. So TRUE+TRUE+FALSE = 1+1+0 = 2
English
0
0
0
25
Ronaldo Pinheiro
Ronaldo Pinheiro@ronaldoalpinhei·
@Python_Dv The answer is A. The reason why the answer is A has already been perfectly explained by my esteemed colleagues.
English
0
0
0
84
Rittmeister Mortimer “Morty” von Klinge
@Python_Dv I read the other comments and tried on REPL as well. But the explanation does not satisfy. I'd like to ask, if anyone knows *why* this is the case? + could easily have been the OR operator, such that True + True = True and True + False = True. Why does it get converted to int?
English
0
0
0
231
Joe
Joe@Joe46791334·
@Python_Dv It ahould be an error, but Pythonis very permissive. + usually isn't a Boolean operator.
English
0
0
0
17
Ayush
Ayush@iAyushCodes·
@Python_Dv Answer: A Explanation 👇🏻 Think of True as 1 and False as 0 True + True + False 1 + 1 + 0 = 2
English
0
0
0
70
Paylaş