-
Notifications
You must be signed in to change notification settings - Fork 4
/
comparisons_examples.py
76 lines (54 loc) · 1.72 KB
/
comparisons_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 29 03:31:58 2021
@author: mjach
"""
'''Comparisions example with numbers '''
# > greater than sign
# >= greater than equal to sign
# < less than sign
# <= less than equal to sign
# print('100 < 200 =', 100 < 200)
# print('100 <= 100 =', 100 <= 100)
# print('100 < 50 =', 100 < 50)
# print('100 <= 90 =', 100 <= 90)
# print('\n') # to get a new line
# print('200 > 100 =', 200 > 100)
# print('200 >= 200 =', 200 >= 200)
# print('200 > 500 =', 200 > 500)
# print('200 >= 500 =', 200 >= 500)
# print('-20 is greater than 20 ?:', -20 > 20)
'''
Equality
Comparisions example with equals(==) and not equals(!=)
will return boolen result either True or False
'''
answer_one = 1
answer_two = 1
#print('True or False:',answer_one == answer_two)
answer_one = 5
answer_two = 1
#print('True or False:',answer_one != answer_two)
answer_one = 'apple'
answer_two = 'apple'
# print('True or False:',answer_one == answer_two)
# print('True or False:',answer_one != answer_two)
'''Identity check
is or is not key words. (is) is similiar to == and (is not) is similiar to !=
'''
fruit_list_one = ['apple', 'banana']
fruit_list_two = ['apple', 'banana']
#checking for equality
#print(fruit_list_one == fruit_list_two) # will give true or false result
#checking for identity
# both list has different memory address so when checking for identy
# it will give false result because both list has different memory address.
#print(fruit_list_one is fruit_list_two) # will give true or false result
'''
is and is not checking for built in types like None, True and False
'''
one = True
print('One is True :',one is True)
two = False
print('Two is fasle:',two is False)
print('Two is not true:', two is not False )