For Programmers,
<Python+Java challenge>
In Java we can write conditions in ONE LINE using ternary operator, how will you do the same in python?
Explain your answer using the following statement after converting to python...
\\A Java Statement
Answers
Answered by
10
In Java:
a = (2>3)?3:2
In Python:
a = 2 if 2 < 3 else 3
Explanation:
In Java "(2>3)?" returns the value in Boolean, if it's true, it takes the first [from 3:2] value, else it takes the second value i.e. 3 here.
In the same way, In Python, it checks the if condition which is 2<3 here and if it's true, it takes 2 else takes 3.
Answered by
1
Explanation:
Mark me as a brainliest plz
Attachments:
Similar questions