Skip to content

Commit 51674c9

Browse files
committed
first commit
0 parents  commit 51674c9

File tree

8 files changed

+447
-0
lines changed

8 files changed

+447
-0
lines changed

.gitignore

+251
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### macOS template
3+
# General
4+
.DS_Store
5+
.AppleDouble
6+
.LSOverride
7+
8+
# Icon must end with two \r
9+
Icon
10+
11+
# Thumbnails
12+
._*
13+
14+
# Files that might appear in the root of a volume
15+
.DocumentRevisions-V100
16+
.fseventsd
17+
.Spotlight-V100
18+
.TemporaryItems
19+
.Trashes
20+
.VolumeIcon.icns
21+
.com.apple.timemachine.donotpresent
22+
23+
# Directories potentially created on remote AFP share
24+
.AppleDB
25+
.AppleDesktop
26+
Network Trash Folder
27+
Temporary Items
28+
.apdisk
29+
30+
### JetBrains template
31+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
32+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
33+
34+
# User-specific stuff
35+
.idea/**/workspace.xml
36+
.idea/**/tasks.xml
37+
.idea/**/usage.statistics.xml
38+
.idea/**/dictionaries
39+
.idea/**/shelf
40+
41+
# Generated files
42+
.idea/**/contentModel.xml
43+
44+
# Sensitive or high-churn files
45+
.idea/**/dataSources/
46+
.idea/**/dataSources.ids
47+
.idea/**/dataSources.local.xml
48+
.idea/**/sqlDataSources.xml
49+
.idea/**/dynamic.xml
50+
.idea/**/uiDesigner.xml
51+
.idea/**/dbnavigator.xml
52+
53+
# Gradle
54+
.idea/**/gradle.xml
55+
.idea/**/libraries
56+
57+
# Gradle and Maven with auto-import
58+
# When using Gradle or Maven with auto-import, you should exclude module files,
59+
# since they will be recreated, and may cause churn. Uncomment if using
60+
# auto-import.
61+
# .idea/artifacts
62+
# .idea/compiler.xml
63+
# .idea/jarRepositories.xml
64+
# .idea/modules.xml
65+
# .idea/*.iml
66+
# .idea/modules
67+
# *.iml
68+
# *.ipr
69+
70+
# CMake
71+
cmake-build-*/
72+
73+
# Mongo Explorer plugin
74+
.idea/**/mongoSettings.xml
75+
76+
# File-based project format
77+
*.iws
78+
79+
# IntelliJ
80+
out/
81+
82+
# mpeltonen/sbt-idea plugin
83+
.idea_modules/
84+
85+
# JIRA plugin
86+
atlassian-ide-plugin.xml
87+
88+
# Cursive Clojure plugin
89+
.idea/replstate.xml
90+
91+
# Crashlytics plugin (for Android Studio and IntelliJ)
92+
com_crashlytics_export_strings.xml
93+
crashlytics.properties
94+
crashlytics-build.properties
95+
fabric.properties
96+
97+
# Editor-based Rest Client
98+
.idea/httpRequests
99+
100+
# Android studio 3.1+ serialized cache file
101+
.idea/caches/build_file_checksums.ser
102+
103+
### Python template
104+
# Byte-compiled / optimized / DLL files
105+
__pycache__/
106+
*.py[cod]
107+
*$py.class
108+
109+
# C extensions
110+
*.so
111+
112+
# Distribution / packaging
113+
.Python
114+
build/
115+
develop-eggs/
116+
dist/
117+
downloads/
118+
eggs/
119+
.eggs/
120+
lib/
121+
lib64/
122+
parts/
123+
sdist/
124+
var/
125+
wheels/
126+
pip-wheel-metadata/
127+
share/python-wheels/
128+
*.egg-info/
129+
.installed.cfg
130+
*.egg
131+
MANIFEST
132+
133+
# PyInstaller
134+
# Usually these files are written by a python script from a template
135+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
136+
*.manifest
137+
*.spec
138+
139+
# Installer logs
140+
pip-log.txt
141+
pip-delete-this-directory.txt
142+
143+
# Unit test / coverage reports
144+
htmlcov/
145+
.tox/
146+
.nox/
147+
.coverage
148+
.coverage.*
149+
.cache
150+
nosetests.xml
151+
coverage.xml
152+
*.cover
153+
*.py,cover
154+
.hypothesis/
155+
.pytest_cache/
156+
cover/
157+
158+
# Translations
159+
*.mo
160+
*.pot
161+
162+
# Django stuff:
163+
*.log
164+
local_settings.py
165+
db.sqlite3
166+
db.sqlite3-journal
167+
168+
# Flask stuff:
169+
instance/
170+
.webassets-cache
171+
172+
# Scrapy stuff:
173+
.scrapy
174+
175+
# Sphinx documentation
176+
docs/_build/
177+
178+
# PyBuilder
179+
.pybuilder/
180+
target/
181+
182+
# Jupyter Notebook
183+
.ipynb_checkpoints
184+
185+
# IPython
186+
profile_default/
187+
ipython_config.py
188+
189+
# pyenv
190+
# For a library or package, you might want to ignore these files since the code is
191+
# intended to run in multiple environments; otherwise, check them in:
192+
# .python-version
193+
194+
# pipenv
195+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
196+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
197+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
198+
# install all needed dependencies.
199+
#Pipfile.lock
200+
201+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
202+
__pypackages__/
203+
204+
# Celery stuff
205+
celerybeat-schedule
206+
celerybeat.pid
207+
208+
# SageMath parsed files
209+
*.sage.py
210+
211+
# Environments
212+
.env
213+
.venv
214+
env/
215+
venv/
216+
ENV/
217+
env.bak/
218+
venv.bak/
219+
220+
# Spyder project settings
221+
.spyderproject
222+
.spyproject
223+
224+
# Rope project settings
225+
.ropeproject
226+
227+
# mkdocs documentation
228+
/site
229+
230+
# mypy
231+
.mypy_cache/
232+
.dmypy.json
233+
dmypy.json
234+
235+
# Pyre type checker
236+
.pyre/
237+
238+
# pytype static type analyzer
239+
.pytype/
240+
241+
# Cython debug symbols
242+
cython_debug/
243+
244+
### Example user template template
245+
### Example user template
246+
247+
# IntelliJ project files
248+
.idea
249+
*.iml
250+
out
251+
gen

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Install Requirement
2+
pip install -r requirements.txt
3+
4+
## Goal
5+
```bash
6+
# check if there are Python syntax errors or undefined names
7+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
8+
# run testcase
9+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
10+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
11+
pytest
12+
```

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flake8
2+
pytest

template/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Example Python Homework
2+
3+
From https://github.com/uwhpsc-2016/example-python-homework
4+
5+
*An example homework assignment in Python for demonstrating how homework is done
6+
in the course.*
7+
8+
In this (example) assignment we will learn some basic Python. In particular, we
9+
will learn about basic Python arithmetic, list handling, and how to create
10+
Python modules as well as an introduction to writing tests using Python's
11+
`unittest` module.
12+
13+
## Objective
14+
15+
Provide definitions to the functions `square` and `cube` defined in the Python
16+
submodules `example_homework.squaring` and `example_homework.cubing`,
17+
respectively.
18+
19+
```python
20+
def square(x):
21+
# return the square of x
22+
23+
def cube(x):
24+
# return the cube of x
25+
```
26+
27+
The provided example test suite can be executed using
28+
29+
```
30+
$ python ./test_example_homework.py
31+
```
32+
33+
As always, you are welcome (and encouraged) to add your own tests to the test
34+
suite to ensure that your code is robust. Most of all, make sure that the
35+
supplied tests pass so that the grading software can import and use your
36+
function as expected.
37+
38+
## Grading
39+
40+
When the homework deadline is reached your implementation of `square` and `cube`
41+
will be run against the following tests:
42+
43+
* (1/5) the square and cube of zero is zero (already in the provided test suite)
44+
* (1/5) the square and cube of two is four and eight, respectively (already in
45+
the provided test suite)
46+
* (1/5) `square` and `cube` should behave appropriately with complex numbers as
47+
input (e.g. `1.0 - 2.0j`)
48+
* (2/5) these functions should also be able to act on Python `list`s of numbers
49+
without the use of the Python function `map`. that is, if the input is of type
50+
`list` then the output should also be of type `list` containing appropriate
51+
corresponding values
52+
53+
It is important that the function names and locations DO NOT CHANGE. Otherwise,
54+
the test suite used for grading may not be able to import your code. If it's
55+
importable in the test suite provided to you it should be importable in the
56+
grading test suite.

template/example_homework/__init__.py

Whitespace-only changes.

template/example_homework/cubing.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
r"""
2+
cubing.py
3+
===========
4+
Provides a definition for the "cube" function. The function prototype should
5+
be
6+
cube(x : type) -> type
7+
Solution
8+
--------
9+
Do not modify the interface to `cube()`. This function can, however, call
10+
other functions.
11+
"""
12+
13+
14+
def cube(x):
15+
"""
16+
Return the cube of a `x`.
17+
Parameters
18+
----------
19+
x : number
20+
Any numerical type that can be cubed.
21+
Returns
22+
-------
23+
value : number
24+
The square of `x`.
25+
"""
26+
if type(x) != list:
27+
return x * x * x
28+
else:
29+
return [cube(a) for a in x]

template/example_homework/squaring.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
r"""
2+
squaring.py
3+
===========
4+
Provides a definition for the "square" function. The function prototype should
5+
be
6+
square(x : type) -> type
7+
Solution
8+
--------
9+
Do not modify the interface to `square()`. This function can, however, call
10+
other functions.
11+
"""
12+
13+
14+
def square(x):
15+
"""
16+
Return the square of a `x`.
17+
Parameters
18+
----------
19+
x : number
20+
Any numerical type that can be squared.
21+
Returns
22+
-------
23+
value : number
24+
The square of `x`.
25+
"""
26+
if type(x) != list:
27+
return x * x
28+
else:
29+
return [square(a) for a in x]

0 commit comments

Comments
 (0)