AssocProf RAM.A.DAYINABOYINA, C.S.E, JU.JIT, MTU, RAISONY UNIV
23, నవంబర్ 2025, ఆదివారం
22, నవంబర్ 2025, శనివారం
20, నవంబర్ 2025, గురువారం
Ternary Operator in Python............
The ternary operator in Python allows us to perform conditional checks and assign values or perform operations on a single line. It is also known as a conditional expression because it evaluates a condition and returns one value if the condition is True and another if it is False.
ex 1:-
n = 5
res = "Even" if n % 2 == 0 else "Odd"
print(res)
ex 2:-
n = -5
res = "Positive" if n > 0 else "Negative" if n < 0 else "Zero"
print(res)
19, నవంబర్ 2025, బుధవారం
17, నవంబర్ 2025, సోమవారం
16, నవంబర్ 2025, ఆదివారం
దీనికి సబ్స్క్రయిబ్ చేయి:
కామెంట్లు (Atom)