Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b247326
adds first assessment for week one
laumurph May 17, 2018
cab26d4
adds second assessment for week one
laumurph May 17, 2018
aa882ac
adds third assessment for week one
laumurph May 17, 2018
b2c4a7f
adds fourth assessment for week one
laumurph May 17, 2018
d7cb1a1
adds first assessment for week two
laumurph May 17, 2018
296834f
adds first assessment for week three
laumurph May 17, 2018
fa54f3b
adds second assessement week three and edits the first one that week
laumurph May 17, 2018
0572ab9
adds third assessment week three
laumurph May 17, 2018
a537124
adds first assessment week four
laumurph May 17, 2018
6064c54
adjusts the syntax around the header for week four
laumurph May 17, 2018
88fa531
adds inital part of week five assessment one. more TODO
laumurph May 17, 2018
a8e59ef
adds assessment two week five and new problem to assessment one
laumurph May 18, 2018
4bf0a3f
adds end of course one assignment
laumurph May 18, 2018
27ba2a8
edits feedback to fit style. Edits multiple answer questions
laumurph May 18, 2018
6cdbf12
edits multiple choice questions week five assess two
laumurph May 18, 2018
09a2257
adds in reference diagram questions for assessments
laumurph May 18, 2018
3cc395a
edits configuration to work with presnick repo and edits assessments
laumurph May 21, 2018
009703a
adds fill in the blank questions and another aliasing question
laumurph May 21, 2018
d9d0123
adds description of activecode in A Typical First Program
laumurph May 23, 2018
ad8f2ce
adds print as a function in Function Calls
laumurph May 23, 2018
ceac3e0
adds accumulator pattern with conditionals, new reference diagrams, a…
laumurph May 23, 2018
5288f24
adds in the Accumulator Pattern Strategies page and small edit to Con…
laumurph May 24, 2018
cae415d
adds page for Disabmiguating between indexing and creating lists.
laumurph May 24, 2018
87fd521
adds a page about using the range function
laumurph May 24, 2018
6714d21
adds hello world to sytnax error page and control structures to more …
laumurph May 24, 2018
9b1e808
adds hello world assessment week 1, other small edits
laumurph Jun 4, 2018
e381505
ads images/gifs from class slides to slice and split and join pages
laumurph Jun 4, 2018
cc62574
adds images to flow or execution and statements and expressions
laumurph Jun 4, 2018
5f10e4d
adds image to chained conditionals
laumurph Jun 4, 2018
a438abd
adds images for lambda, internet requests, and exceptions
laumurph Jun 4, 2018
329de7b
adds images to while loop, inheritance, and internet requests
laumurph Jun 4, 2018
0b9cecb
adds images to classes, inheritance, and unix
laumurph Jun 4, 2018
06ec2a1
Adds a square function gif to function calls page
laumurph Jun 4, 2018
58bb8e8
adds gif for casting to type conversion functions
laumurph Jun 4, 2018
3eb009a
adds gif to accum w/conditionals and new version of refdiag4
laumurph Jun 5, 2018
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
Binary file added .DS_Store
Binary file not shown.
Binary file added _sources/.DS_Store
Binary file not shown.
Binary file added _sources/Assessments/.DS_Store
Binary file not shown.
Binary file added _sources/Assessments/Figures/.DS_Store
Binary file not shown.
Binary file added _sources/Assessments/Figures/week3a1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a1_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a2_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a2_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a2_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a2_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a3_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a3_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _sources/Assessments/Figures/week3a3_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions _sources/Assessments/assigmentcourseone.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, and Dario Mitchell. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".

Assignment
----------

.. activecode:: asign_c01_01
:language: python
:autograde: unittest
:practice: T
:topics:

**1.** Write code to determine how many vowels are in the text assigned to ``story``. Assign this number to the variable ``num_vowels``. Note that in this problem, only 'a', 'e', 'i', 'o', and 'u' count as vowels.
~~~~
story = """The quick brown fox jumped over the lazy dog.
By the end of the day, the fox had travelled far from home
and the dog had only made it down the street. This was not
an advantage for the dog though, because it still took both
animals the same amount of time to arrive at home."""

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
og_story = """The quick brown fox jumped over the lazy dog.
By the end of the day, the fox had travelled far from home
and the dog had only made it down the street. This was not
an advantage for the dog though, because it still took both
animals the same amount of time to arrive at home."""
self.assertEqual(num_vowels, 80, "Testing that num_vowels is a number that contains the correct elements.")
self.assertEqual(story, og_story, "Testing that story is still the original string assigned.")
self.assertIn('for', self.getEditorText(), "Testing your code (Don't worry about actual and expected values.)")

myTests().main()

.. activecode:: asign_c01_02
:language: python
:autograde: unittest
:practice: T
:topics:

**2.** Write code that uses the string stored in ``org`` and creates an acronym which is assigned to the variable ``acro``. Only the first letter of each word should be used, each letter in the acronym should be a captial letter, and there should be nothing to separate the letters of the acronym. Words that should not be included in the acronym are stored in the list ``stopwords``. For example, if ``org`` was assigned the string "hello to world" then the resulting acronym should be "HW".
~~~~
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and']
org = "The organization for health, saftey, and education"

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(acro, 'OHSE', 'Checking that acro has been set correctly.')
self.assertTrue(type(acro) == type("string"), "Checking that acro is a string.")
self.assertIn('for', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()

.. activecode:: asign_c01_03
:language: python
:autograde: unittest
:practice: T
:topics:

**3.** Write code that uses the string stored in ``sent`` and creates an acronym which is assigned to the variable ``acro``. The first two letters of each word should be used, each letter in the acronym should be a captial letter, and each element of the acronym should be separated by a ". ". Words that should not be included in the acronym are stored in the list ``stopwords``. For example, if ``sent`` was assigned the string "height and ewok wonder" then the resulting acronym should be "HE. EW. WO".
~~~~
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and']
sent = "The water, earth, and air are vital."

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(acro, 'WA. EA. AI. AR. VI', 'Checking that acro has been set correctly.')
self.assertTrue(type(acro) == type("string"), "Checking that acro is a string.")
self.assertIn('for', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()

.. activecode:: asign_c01_04
:language: python
:autograde: unittest
:practice: T
:topics:

**3.** Write code that checks if ``p_phrase`` is a palindrome. A palindrome is a phrase that, if reversed, would read the exact same. Assign the reversed version of ``p_phrase`` to the variable ``r_phrase``.
~~~~
p_phrase = "was it a car or a cat I saw"

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(r_phrase, "was I tac a ro rac a ti saw", "checking that r_phrase is set correctly")
stripped_phrase = p_phrase.replace(" ", "").lower()
stripped_r_phrase = r_phrase.replace(" ", "").lower()
self.assertEqual(stripped_phrase, stripped_r_phrase, "checking that r_phrase and p_phrase are equivalent if the spaces are placed in the correct locations.")
self.assertIsNot(p_phrase, r_phrase, "checking that r_phrase and p_phrase are not the same object.")

myTests().main()


88 changes: 88 additions & 0 deletions _sources/Assessments/week1a1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, and Dario Mitchell. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".

Week 1 Assessment 1
-------------------

**Check your understanding**

.. mchoice:: question1_1_1
:answer_a: A solution to a problem that can be solved by a computer.
:answer_b: A step by step list of instructions that if followed exactly will solve the problem under consideration.
:answer_c: A series of instructions implemented in a programming language.
:answer_d: A special kind of notation used by programmers.
:feedback_a: While it is true that algorithms often do solve problems, this is not the best answer. An algorithm is more than just the solution to the problem for a computer. An algorithm can be used to solve all sorts of problems, including those that have nothing to do with computers.
:feedback_b: Algorithms are like recipes: they must be followed exactly, they must be clear and unambiguous, and they must end.
:feedback_c: Programming languages are used to express algorithms, but an algorithm does not have to be expressed in terms of a programming language.
:feedback_d: Programmers sometimes use a special notation to illustrate or document an algorithm, but this is not the definition of an algorithm.
:correct: b
:practice: T
:topics: GeneralIntro/Algorithms

An algorithm is:

.. mchoice:: question1_1_2
:answer_a: Because computers are better at solving problems.
:answer_b: So that you don't have to solve the problem yourself.
:answer_c: So that you have a general solution to a problem.
:answer_d: Because you need a set of instructions to follow.
:feedback_a: Computers aren't necessarily better at solving problems, though often they can be quicker than humans. Additionally, algorithms can be used to solve non-computer related problems.
:feedback_b: While it is beneficial to have a set of instructions that others can follow, this isn't the best answer. By creating the algorithm, you solve a problem for yourself and others.
:feedback_c: Yes, by creating a general solution you can then express it as a program if you choose, and then use a computer to automate the execution.
:feedback_d: While it is beneficial to have a set of instructions as that is what an algorithm **is**, it is not **why** we would want to create one.
:correct: c
:practice: T
:topics: GeneralIntro/Algorithms

Why create an algorithm?


.. mchoice:: question1_1_3
:answer_a: natural languages can be parsed while formal languages cannot.
:answer_b: ambiguity, redundancy, and literalness.
:answer_c: there are no differences between natural and formal languages.
:answer_d: tokens, structure, syntax, and semantics.
:feedback_a: Actually both languages can be parsed (determining the structure of the sentence), but formal languages can be parsed more easily in software.
:feedback_b: All of these can be present in natural languages, but cannot exist in formal languages.
:feedback_c: There are several differences between the two but they are also similar.
:feedback_d: These are the similarities between the two.
:correct: b
:practice: T
:topics: GeneralIntro/FormalandNaturalLanguages

The differences between natural and formal languages include:

.. mchoice:: question1_1_4
:answer_a: True
:answer_b: False
:feedback_a: It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding.
:feedback_b: It usually takes longer to read a program because the structure is as important as the content and must be interpreted in smaller pieces for understanding.
:correct: b
:practice: T
:topics: GeneralIntro/FormalandNaturalLanguages

True or False: Reading a program is like reading other kinds of text.

.. activecode:: question1_1_5
:language: python
:autograde: unittest

1 Write code to print out the phrase "Hello World".
~~~~

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertIn("Hello World", self.getOutput(), "Testing output (Don't worry about actual and expected values).")

myTests().main()
102 changes: 102 additions & 0 deletions _sources/Assessments/week1a2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
.. Copyright (C) Brad Miller, David Ranum, Jeffrey Elkner, Peter Wentworth, Allen B. Downey, Chris
Meyers, and Dario Mitchell. Permission is granted to copy, distribute
and/or modify this document under the terms of the GNU Free Documentation
License, Version 1.3 or any later version published by the Free Software
Foundation; with Invariant Sections being Forward, Prefaces, and
Contributor List, no Front-Cover Texts, and no Back-Cover Texts. A copy of
the license is included in the section entitled "GNU Free Documentation
License".

Week 1 Assessment 2
-------------------

**Check your understanding**

.. activecode:: ps_01_02
:include: addl_functions
:language: python
:autograde: unittest
:topics: SimplePythonData/FunctionCalls

**1.** There is a function we are providing in for you in this problem called ``square``. It takes one integer and returns the square of that integer value. Write code to assign a variable called ``xyz`` the value ``5*5`` (five squared). Use the square function, rather than just multiplying with ``*``.
~~~~
xyz = ""

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(type(xyz), type(3), "Checking type of xyz")
self.assertEqual(xyz, 25, "Checking if xyz is 25")
self.assertIn('square', self.getEditorText(), "Testing that 'square' is in your code. (Don't worry about Actual and Expected Values.)")

myTests().main()

.. activecode:: ps_01_01
:language: python
:autograde: unittest
:practice: T
:topics: Sequences/SplitandJoin

**2.** Write code to assign the number of *characters* in the string ``rv`` to a variable ``num_chars``.
~~~~
rv = """Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore,
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
'Tis some visitor, I muttered, tapping at my chamber door;
Only this and nothing more."""

# Write your code here!

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(num_chars, len(rv), "Testing that num_chars has been set to the length of rv")

myTests().main()


.. mchoice:: question1_1_1_3
:multiple_answers:
:answer_a: a = len("hello worldwelcome!")
:answer_b: a = 11 + 8
:answer_c: a = len(z) + len(y)
:answer_d: a = len("hello world") + len("welcome!")
:answer_e: none of the above are hardcoding.
:feedback_a: Though we are using the len function here, we are hardcoding what len should return the length of. We are not referencing z or y.
:feedback_b: This is hardcoding, we are writing in the value without referencing z or y.
:feedback_c: This is not considered hard coding. We are using the function len to determine the length of what is stored in z and y, which is a correct way to approach this problem.
:feedback_d: Though we are using the len function here, we are hardcoding what len should return the length of each time we call len. We are not referencing z or y.
:feedback_e: At least one of these solutions is considered hardcoding. Take another look.
:correct: a,b,d
:practice: T
:topics:

The code below initializes two variables, ``z`` and ``y``. We want assign the total number of characters in ``z`` and in ``y`` to the variable ``a``. Which of the following solutions, if any, would be considered hard coding?

.. sourcecode:: python

z = "hello world"
y = "welcome!"


.. activecode:: addl_functions
:language: python
:nopre:
:hidecode:

(This is not an assessment question) The code below defines functions used by one of the questions above. Do not modify the code, but feel free to take a look.

~~~~

def square(num):
return num**2

Loading