What is predicate and with example ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is predicate and with example ?

Python3

1st Nov 2020, 8:41 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
2 Answers
+ 3
A predicate is a case that has to be met for an operation to happen. For example in Python: li = [x for x in li if x % 2 == 0] `x % 2 == 0` is the predicate that only allows even numbers to be added to the new list in the list comprehension operation.
1st Nov 2020, 9:46 PM
Maxwell Anderson
Maxwell Anderson - avatar
+ 2
Muhammad Abdulmalik I recommend you review the answers posted in this other thread. https://www.sololearn.com/Discuss/2568039/?ref=app Also, you should use tags that will help people searching for questions like yours. No one is going to search "help" to find questions in the future on predicates in python. I recommend the following: python predicates I hope that tip helps you improve your future questions.
2nd Nov 2020, 5:29 AM
David Carroll
David Carroll - avatar