Lesson-2:Python Comparison Oparetors

Python Comparison Oparetors

Python karşılaştırma operatörleri
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).
KARŞILAŞTIRMA OPARETÖRLERİ
Bu görsel boş bir alt niteliğe sahip; dosya adı image-1-1024x458.png
Bu görsel boş bir alt niteliğe sahip; dosya adı image-1-1024x458.png

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”

a=19
b=11
c= (a>b) or (a==b)

print (c)
Screen = True

a=19
b=11

c= (a>b) and (a==b)

print (c)

Screen = False

Python comparison operators Example-2

Bu görsel boş bir alt niteliğe sahip; dosya adı image-5.png

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

Bu görsel boş bir alt niteliğe sahip; dosya adı image-6.png

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

Bu görsel boş bir alt niteliğe sahip; dosya adı image-7.png

In this example, the user is prompted for a number. If this number is positive: True or False, it is printed on the screen.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *