Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions pset1/meal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
def main():
in_time = input('What time is it? ').strip()
time = convert(in_time)
# print(f'{in_time} converts to {time:.2f}')
if 7 <= time and time <= 8:
print('breakfast time')
elif 12 <= time and time <= 13:
Expand All @@ -14,18 +15,18 @@ def convert(time):
if time.rfind('a.m.') != -1:
time= time[:time.rfind('a')]
hours, minutes = time.split(':')
converted_time = float(hours)+(float(minutes)/600)
converted_time = float(hours)+(float(minutes)/60)
return converted_time

elif time.rfind('p.m.') != -1:
time= time[:time.rfind('p')]
hours, minutes = time.split(':')
converted_time = 12+float(hours)+(float(minutes)/600)
converted_time = 12+float(hours)+(float(minutes)/60)
return converted_time

else :
hours, minutes = time.split(':')
converted_time = float(hours)+(float(minutes)/600)
converted_time = float(hours)+(float(minutes)/60)
return converted_time


Expand Down
11 changes: 4 additions & 7 deletions pset2/plates.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ def is_valid(s):
first_num = s.index(character)
break
# check if there is no alphabet after first num
for character in s:
if s.index(character)<= first_num:
pass
else:
if character.isalpha():
return False
#all conditions satisfied
for character in s[first_num:]:
if character.isalpha():
return False
# all conditions satisfied
return True


Expand Down