Skip to content

Commit

Permalink
file handling; oop exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
ariefrahmansyah committed Aug 14, 2024
1 parent 6a4aa37 commit 55df9df
Show file tree
Hide file tree
Showing 13 changed files with 514 additions and 45 deletions.
1 change: 1 addition & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder contains code and notebooks that not referenced by the docs.
93 changes: 93 additions & 0 deletions code/hello_world.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "b557902c-d9fa-4c1e-872b-9df086463660",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello, World!\n"
]
}
],
"source": [
"print(\"Hello, World!\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4aa2bdfa-23a1-48fe-b9ce-0658bf8de8db",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2+3"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7604f907-b28b-4444-a987-2b3cc8a9b1f9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2*3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb90b656-0a0e-494b-a29f-3632ac6c10a2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions code/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello, world!")
1 change: 1 addition & 0 deletions data/creating_file_example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This text will be written in a newly created file.
2 changes: 2 additions & 0 deletions data/csv_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"name","country","city","skills"
"Aurora","Indonesia","Palembang","Python"
3 changes: 3 additions & 0 deletions data/reading_file_example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is an example to show how to open a file and read.
This is the second line of the text.
I love python.
1 change: 1 addition & 0 deletions data/writing_file_example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This text has to be appended at the end.
2 changes: 2 additions & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ parts:
sections:
- file: python/python_fundamentals_2/list_comprehension
- file: python/python_fundamentals_2/higher_order_functions
- file: python/python_fundamentals_2/file_handling
- file: python/oop/index
sections:
- file: python/oop/classes
- file: python/oop/inheritance
- file: python/oop/polymorphism
- file: python/oop/oop_exercises

- caption: NumPy
chapters:
Expand Down
3 changes: 3 additions & 0 deletions docs/python/oop/oop_exercises.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# OOP Exercises

Create a class called `PersonAccount`. It has `firstname`, `lastname`, `incomes`, and `expenses` properties. It also has `total_income()`, `total_expense()`, `account_info()`, `add_income()`, `add_expense()` and `account_balance()` methods. Incomes is a dict of income amount and its description. The same goes for expenses.
Loading

0 comments on commit 55df9df

Please sign in to comment.