Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions lab0/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@ def middle(a, b, c):
"""Return the number among a, b, and c that is not the smallest or largest.
Assume a, b, and c are all different numbers.
"""
return ____
return sorted([a, b, c])[1]


def sum_digits(y: int) -> int:
"""
Sum all the digits of y.
"""
pass
sum = 0
while y > 0:
digit = y % 10
y //= 10
sum += digit
return sum


def double_eights(n: int) -> bool:
"""
Return True if n has two eights in a row.
"""
pass
prev_eight = False
while n > 0:
digit = n % 10
if digit == 8:
if prev_eight:
return True
else:
prev_eight = True
else:
prev_eight = False
n //= 10
return False