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
31 changes: 31 additions & 0 deletions challenges/week_1/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Bus Fare Challenge - Week 1

## Challenge

Write a program that does the following:

1. gets today's date and stores it in a variable `'date'`
2. uses today's date to get the name on the day of the week written in short form with the first letter capitalized eg. `'Fri'` if today were Friday and assigns it a variable `'day'`
3. uses if statements to determine the today's fare following these bus fare schedule:

- monday - friday --> 100
- saturday --> 60
- sunday --> 80
4. Prints the results in this format
>Date: 2021-01-05
>Day: Tue
>Fare: 100

## Evaluation

Run the [Checker](checker.py) file to evaluate your code. If all tests pass, your code will be the correct solution. If any fail, check the error messages and make changes to your code and repeat.

## Note

1. Your solution must be written in the [bus_fare_challenge](bus_fare_challenge.py) file and its name should never be changed.
2. Your program must make use of the following variable names:
- `'date'`
- `'day'`
- `'fare'`
*Failure to which all your tests will fail.*
3. The **Checker** file should **never** be **altered** at any cost.
1 change: 1 addition & 0 deletions challenges/week_1/bus_fare_challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# WRITE YOUR CODE SOLUTION HERE
55 changes: 55 additions & 0 deletions challenges/week_1/checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import bus_fare_challenge
import datetime
import unittest


class TestBusFareChallenge(unittest.TestCase):
def setUp(self) -> None:
self.date = datetime.datetime.now().date()
self.day = self.date.strftime("%a")
self.charts = {
"Mon": 100,
"Tue": 100,
"Wed": 100,
"Thu": 100,
"Thu": 100,
"Sat": 60,
"Sun": 80,
}

def test_date(self) -> None:
"""
Tests whether the date returned by the program is correct.
"""
actual = self.date
given = bus_fare_challenge.date
self.assertEqual(actual, given, f"Today's date is Wrong by {given - actual}!")

def test_day(self) -> None:
"""
Tests whether the day returned by the program is correct.
"""
actual = self.day
given = bus_fare_challenge.day
self.assertEqual(
actual, given, f"Today is wrong, expexted {actual} but got {given}!"
)

def test_fare(self) -> None:
"""
Tests whether the fare returned by the program is correct.
"""
actual = self.charts[self.day]
given = bus_fare_challenge.fare
self.assertEqual(
actual, given, f"Fare is wrong, expected {actual} but got {given}!"
)


if __name__ == "__main__":
print("=========================================================================")
print("=========================================================================")
print("===== Start: Checking Return Values For Today's Date, Day and Fare =====")
unittest.main(exit=False)
print("===== End: Checking Return Values For Today's Date, Day and Fare =======")
print("=========================================================================")
23 changes: 22 additions & 1 deletion source/week-4/csv-files-jupyter/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# CSV Files and Jupyter Notebooks

CSV files are comma separated variable file. CSV files are frequently used to store data. In order to access the data in a CSV file from a Jupyter Notebook you must upload the file.
The so-called **CSV** (Comma Separated Values) format is the most common import and export format for spreadsheets and databases. The CSV format was used for many years prior to attempts to describe the format in a standardized way.

Python has an in-built csv module which implements classes to read and write tabular data in CSV format.

```python
# format example
>>> import csv
>>> with open('./airports.csv') as file:
... data = csv.reader(file)
... for row in data:
... print(*row) # * is used to unpack lists
Name City Country
Seattle-Tacoma Seattle USA
Dulles Washington USA
Heathrow London United Kingdom
Schiphol Amsterdam Netherlands
Changi Singapore Singapore
Pearson Toronto Canada
Narita Tokyo Japan
```

A this module has a lot more features, checkout [more details](https://docs.python.org/3/library/csv.html).

## Microsoft Learn Resources

Expand Down
Loading