Lesson-2:Python Comparison Oparetors
Python Comparison Oparetors
- Comparisons of values taken by variables (size,equality, etc.) the operators we use to make are called comparison operators.
- Comparison operators send us data of boolean type (True or False).
Python comparison operators Example – 1
b_year = input(<strong>"Enter your year of birth: " age = 2021 - int(b_year) d_license= (yas >= 18) print(<strong>"License import status="</strong>, d_license)
A person aged 18 and over according to the year of birth can obtain a driver’s license. So we can check with a large equal operator (>=) whether a person whose age we calculate according to the year of birth can get a driver’s license.
USING OF “AND”, “OR”, “NOT”
c= (a>b) or (a==b)
Screen = True
c= (a>b) and (a==b)
Screen = False
Python comparison operators Example-2
The user is prompted for vize1, vize2, and final grades. 40% of the midterms and 60% of the final grade are the student’s overall average. If the overall average is 60 and above, it will write “your class passing status :True”. If the overall average is less than 60, it will write “your class passing status :False”.
Python comparison operators Example-3
In this example, the user is prompted for a number. If this number is even: true or False, it is printed on the screen. the ” sayi%2 ” command returns the rest of the number divided by 2.
Python comparison operators Example-4
In this example, the user is prompted for a number. If this number is positive: True or False, it is printed on the screen.