The answer is yes. Python has a ternary conditional operator. It allows testing a condition in a single line by replacing the multiline if-else which makes the code compact. The syntax is-
[on_true] if [expression]
else [on_false]
A simple way of using the ternary operator is as follows-
a, b = 10, 20
min = a if a < b else b
print(min)
Here the output will be 10.
Another way of using a ternary operator is by using
nested if-else-
a, b = 10, 20
print ("Both a and b are equal" if a ==b else "a is greater than b"
if a > b else "b is greater than a")