Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60c4da5

Browse filesBrowse files
committed
Assignment solutions | Created using Colaboratory
1 parent 4996d2e commit 60c4da5
Copy full SHA for 60c4da5

File tree

Expand file treeCollapse file tree

1 file changed

+144
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+144
-0
lines changed

‎day_07/03_assignment_solutions.ipynb

Copy file name to clipboard
+144Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"name": "03_assignment_solutions.ipynb",
7+
"provenance": [],
8+
"authorship_tag": "ABX9TyOi1wXDFpZZ0xkalt4ty7T8",
9+
"include_colab_link": true
10+
},
11+
"kernelspec": {
12+
"name": "python3",
13+
"display_name": "Python 3"
14+
}
15+
},
16+
"cells": [
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {
20+
"id": "view-in-github",
21+
"colab_type": "text"
22+
},
23+
"source": [
24+
"<a href=\"https://colab.research.google.com/github/gumdropsteve/intro_to_python/blob/main/day_07/03_assignment_solutions.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
25+
]
26+
},
27+
{
28+
"cell_type": "markdown",
29+
"metadata": {
30+
"id": "xdIugRuOpAjz"
31+
},
32+
"source": [
33+
"# Company\r\n",
34+
"https://github.com/gumdropsteve/intro_to_python/blob/main/day_07/02_assignment.md#1-lets-build-a-company-class-used-to-represent-some-company-riyadh-tea-co-chick-fil-a-chipotle-etc"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"metadata": {
40+
"id": "A_We7mxIo_tE"
41+
},
42+
"source": [
43+
"class Company(): \r\n",
44+
" \"\"\"\r\n",
45+
" This docstring will describe how to interact with the Company class. \r\n",
46+
"\r\n",
47+
" The company class will have attributes that are standard to a company, \r\n",
48+
" and methods that interact with a couple of those attributes. \r\n",
49+
"\r\n",
50+
" Parameters\r\n",
51+
" ----------\r\n",
52+
" name: str\r\n",
53+
" Holds the company name. \r\n",
54+
" industry_type: str\r\n",
55+
" Holds what industry the company belongs to. \r\n",
56+
" num_employees: int\r\n",
57+
" total_revenue - float\r\n",
58+
" \"\"\"\r\n",
59+
"\r\n",
60+
" def __init__(self, name, industry_type, num_employees, total_revenue): \r\n",
61+
" self.name = name\r\n",
62+
" self.industry_type = industry_type\r\n",
63+
" self.num_employees = num_employees\r\n",
64+
" self.total_revenue = total_revenue\r\n",
65+
"\r\n",
66+
" def serve_customer(self, cost): \r\n",
67+
" \"\"\"\r\n",
68+
" Adjusts the company's total_revenue by the cost required \r\n",
69+
" to serve a customer. \r\n",
70+
"\r\n",
71+
" Args: \r\n",
72+
" cost: float\r\n",
73+
" \"\"\"\r\n",
74+
"\r\n",
75+
" self.total_revenue += cost \r\n",
76+
"\r\n",
77+
" def gain_employees(self, new_employee_lst): \r\n",
78+
" \"\"\"\r\n",
79+
" Adjusts the company's num_employees to account for new employees. \r\n",
80+
"\r\n",
81+
" Args: \r\n",
82+
" new_employee_lst: list \r\n",
83+
" \"\"\"\r\n",
84+
" self.num_employees += len(new_employee_lst)"
85+
],
86+
"execution_count": null,
87+
"outputs": []
88+
},
89+
{
90+
"cell_type": "markdown",
91+
"metadata": {
92+
"id": "dVctZ0GSpFO3"
93+
},
94+
"source": [
95+
"# TV\r\n",
96+
"https://github.com/gumdropsteve/intro_to_python/blob/main/day_07/02_assignment.md#2-lets-build-a-tv-class-used-to-represent-a-television"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"metadata": {
102+
"id": "MT4Ygy9GpFcV"
103+
},
104+
"source": [
105+
"class Television():\r\n",
106+
"\r\n",
107+
" def __init__(self, brand, on_status=False,\r\n",
108+
" current_channel=0, life_perc=100.0):\r\n",
109+
" self.brand = brand\r\n",
110+
" self.on_status = on_status\r\n",
111+
" self.current_channel = current_channel\r\n",
112+
" self.life_perc = life_perc\r\n",
113+
"\r\n",
114+
" def hit_power(self):\r\n",
115+
" \"\"\"\r\n",
116+
" Switches the television either on or off.\r\n",
117+
" \"\"\"\r\n",
118+
" # This simply switches the self.on_status to the\r\n",
119+
" # opposite of what it currently is (True to False, and\r\n",
120+
" # vice versa).\r\n",
121+
" self.on_status = not self.on_status\r\n",
122+
"\r\n",
123+
" if not self.on_status:\r\n",
124+
" self.current_channel = 0\r\n",
125+
" self.life_perc -= 0.01\r\n",
126+
"\r\n",
127+
" def change_channel(self, channel_num):\r\n",
128+
" \"\"\"\r\n",
129+
" Change the channel of the television to the inputted channel.\r\n",
130+
"\r\n",
131+
" Args:\r\n",
132+
" channel_num: int\r\n",
133+
" \"\"\"\r\n",
134+
"\r\n",
135+
" if self.on_status:\r\n",
136+
" self.current_channel = channel_num\r\n",
137+
" else:\r\n",
138+
" print('Television is not on!')"
139+
],
140+
"execution_count": null,
141+
"outputs": []
142+
}
143+
]
144+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.