Unit 5
Unit 5
results = sum(5, 8)
print results
def add_one(x):
return x + 1
y = add_one(100)
print(y)
• Code Outcome
• 13
101
• Code
• global_var = 10
other_ var = 20
print(global_var)
• Code Outcome
• global_var —> 10
other_var —> 20
5.7 Exceptions
⁃ Try/Except
numerator = int (input ("Enter #: "))
denominator = int (input ("Enter #: "))
try:
quotient = numerator / denominator
if quotient * denominator = numerator:
print ("Divisible!")
else: print ("Not divisible.")
except ZeroDivisionError:
print ("Cannot divide by zero!")
Documentation
⁃ provides information to show programmers how to use it
• docs tab of editor
⁃ chart.js
⁃ HTML