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
38 changes: 38 additions & 0 deletions challenges/week_1/bus_fare_challenge.py
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
# WRITE YOUR CODE SOLUTION HERE
from datetime import datetime, timedelta, date

#Get todays date and store it in a variable 'date'

date = datetime.now()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost correct, only that datetime.now() alone returns the full date including time and timezone. The challenge only needs the date, find a way to pull this off.
Hint: add another attribute to this line to specify the date alone.


"""
# Use todays date to get the name on the day of the week written in a short
# form with the first letter capitalized (e.g) 'Fri' if today were Friday and
# assigns it a variable 'day'
"""
day = datetime.date(date).strftime('%a')


"""
Uses if Statement to determine the todays fare following these bus fare shedule:
Monday - Friday --> 100
Saturdat --> 60
Sunday --> 80
Prints the results in this exact formart
Date: 2021-01-05
Day:Tue
Fare:100
"""
if day == "Mon" or day == "Tue" or day == "Wen" or day =="Thu" or day == "Fri":
print("Date:", date)
print("Day:" + day)
print('Fare: 100')
elif day == "Sat":
print("Date:", date)
print("Day:" + day)
print('fare:60')
else:
print("Date:", date)
print("Day:" + day)
print('fare:80')