Short Circuit Practice
Programming Progress Log » Devlog
#Short circuit practice
x=6
y=2
print(x>=2and(x/y)>2)
#True
x=1
y=0
print(x>=2and(x/y)>2)
#False
x=6
y=0
print(x>=2and(x/y)>2)
#Calculation fails, causes runtime error as cannot divide by zero.
#Guard Evaluation
x=6
y=0
print(x>=2 and y!=0 and (x/y)>2)
True
False
Traceback (most recent call last):
File "main.py", line 12, in <module>
print(x>=2and(x/y)>2)
ZeroDivisionError: division by zero
Programming Progress Log
More posts
- List FunctionsNov 14, 2022
- Python Classes/ObjectsOct 24, 2022
- While LoopsOct 24, 2022
- LoopsOct 16, 2022
- ListsOct 16, 2022
- Using VariablesOct 15, 2022
- Converting degrees to farenheitOct 15, 2022
- First CodeOct 15, 2022
Leave a comment
Log in with itch.io to leave a comment.