-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathequality.py
More file actions
32 lines (26 loc) · 964 Bytes
/
equality.py
File metadata and controls
32 lines (26 loc) · 964 Bytes
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
'''
Equality
100xp
To check if two Python values, or variables, are equal you can use ==.
To check for inequality, you need !=. As a refresher, have a look at the following
examples that all result in True. Feel free to try them out in the IPython Shell.
2 == (1 + 1)
"intermediate" != "python"
True != False
"Python" != "python"
When you write these comparisons in a script, you will need to wrap a print()
function around them to see the output.
Instructions
-In the editor on the right, write code to see if True equals False.
-Write Python code to check if -5 * 15 is not equal to 75.
-Ask Python whether the strings "pyscript" and "PyScript" are equal.
-What happens if you compare booleans and integers? Write code to see if True and 1 are equal.
'''
# Comparison of booleans
print(True == False)
# Comparison of integers
print(-5 * 15 != 75)
# Comparison of strings
print('pyscript' == 'PyScript')
# Compare a boolean with an integer
print(True == 1)