what does a conditional operator in python do

0 votes
can you give the syntax and an example to use a conditional operator?
May 2, 2019 in Python by Waseem
• 4,540 points
1,119 views

1 answer to this question.

0 votes
Conditional operators in python is same as any other programming language. They are the conditional expressions used to give the output according to the condition in the expression.

example:

# Program to demonstrate conditional operator

a, b = 10, 20

# Copy value of a in min if a < b else copy b

min = a if a < b else b

  print(min)
answered May 2, 2019 by Mohammad
• 3,230 points

Related Questions In Python

0 votes
0 answers

What does a ternary conditional operator do in python?

Can you give an example using a ...READ MORE

Jun 17, 2019 in Python by Waseem
• 4,540 points
519 views
+4 votes
6 answers

Does Python have a ternary conditional operator like C does?

Yes, the syntax is: a if condition else ...READ MORE

answered Apr 13, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,940 views
+1 vote
7 answers
0 votes
1 answer

What does eval() in Python do?

The eval function lets a Python program ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 58,090 points
540 views
0 votes
1 answer

To simulate construct of other language does Python have a ternary conditional operator?

You can index into a tuple: (falseValue, trueValue)[test] test needs ...READ MORE

answered Oct 15, 2018 in Python by findingbugs
• 4,780 points
415 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,067 views
0 votes
1 answer

What does the operator "/=" do in python?

x = 20 res = x /= 5 print(res) The ...READ MORE

answered Aug 2, 2019 in Python by Mohammad
• 3,230 points
671 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP