Skip to content

Initial pretext conversion #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
92 changes: 92 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
# Boilerplate list of files in a PreTeXt project for git to ignore
# ensure this file is tracked
!.gitignore

# don't track unpublished builds
output

# don't track assets generated from source
generated-assets

# don't track node packages
node_modules

# don't track error logs
.error_schema.log
cli.log

# don't track OS related files (windows/macos/linux)
.DS_Store
.DS_Store?
._*
.AppleDouble
.LSOverride
.Spotlight-V100
.Trashes
Icon
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
*.stackdump
*.lnk
*.cab
*.msi
*.msix
*.msm
*.msp
[Dd]esktop.ini
.directory
.fuse_hidden*
.Trash-*
.nfs*

# Don't include VSCode generated files
.vscode
*.code-workspace

# Don't inlucde SublimeText files
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# Workspace files are user-specific
*.sublime-workspace

# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
*.sublime-project

# SFTP configuration file
sftp-config.json
sftp-config-alt*.json

# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache

# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings


# Don't include Dropbox settings and caches
.dropbox
.dropbox.attr
.dropbox.cache

# Original .gitignore file
__pycache__/
build/
build_info
Expand Down
18 changes: 18 additions & 0 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@
else:
dest = "../../static"

template_args={
'course_id': 'fopp',
'login_required':'false',
'course_title': project_name,
'appname':master_app,
'dynamic_pages': True,
'loglevel': 10,
'course_url':master_url,
'use_services': 'true',
'python3': 'true',
'dburl': 'postgresql://user:password@localhost/runestone',
'default_ac_lang': 'python',
'basecourse': 'fopp',
'downloads_enabled': 'false',
'enable_chatcodes': 'false',
'allow_pairs': 'false'
}


options(
sphinx = Bunch(docroot=".",),
Expand Down
200 changes: 200 additions & 0 deletions pretext/AdvancedAccumulation/ChapterAssessment.ptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<section xml:id="advanced-accumulation_chapter-assessment">
<title>Chapter Assessment</title>

<exercise label="ac21_7_1">
<statement>
<p>Write code to assign to the variable <c>map_testing</c> all the elements in lst_check while adding the string <q>Fruit: </q> to the beginning of each element using mapping.</p>

</statement>
<program xml:id="ac21_7_1_editor" interactive="activecode" language="python">
<input>
lst_check = ['plums', 'watermelon', 'kiwi', 'strawberries', 'blueberries', 'peaches', 'apples', 'mangos', 'papaya']

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(map_testing, ['Fruit: plums', 'Fruit: watermelon', 'Fruit: kiwi', 'Fruit: strawberries', 'Fruit: blueberries', 'Fruit: peaches', 'Fruit: apples', 'Fruit: mangos', 'Fruit: papaya'], "Testing that map_testing has the correct values.")
self.assertIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")


myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_2">
<statement>
<p>Below, we have provided a list of strings called <c>countries</c>. Use filter to produce a list called <c>b_countries</c> that only contains the strings from <c>countries</c> that begin with B.</p>

</statement>
<program xml:id="ac21_7_2_editor" interactive="activecode" language="python">
<input>
countries = ['Canada', 'Mexico', 'Brazil', 'Chile', 'Denmark', 'Botswana', 'Spain', 'Britain', 'Portugal', 'Russia', 'Thailand', 'Bangladesh', 'Nigeria', 'Argentina', 'Belarus', 'Laos', 'Australia', 'Panama', 'Egypt', 'Morocco', 'Switzerland', 'Belgium']

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(b_countries, ['Brazil', 'Botswana', 'Britain', 'Bangladesh', 'Belarus', 'Belgium'], "Testing that b_countries is correct.")
self.assertNotIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")


myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_3">
<statement>
<p>Below, we have provided a list of tuples that contain the names of Game of Thrones characters. Using list comprehension, create a list of strings called <c>first_names</c> that contains only the first names of everyone in the original list.</p>

</statement>
<program xml:id="ac21_7_3_editor" interactive="activecode" language="python">
<input>
people = [('Snow', 'Jon'), ('Lannister', 'Cersei'), ('Stark', 'Arya'), ('Stark', 'Robb'), ('Lannister', 'Jamie'), ('Targaryen', 'Daenerys'), ('Stark', 'Sansa'), ('Tyrell', 'Margaery'), ('Stark', 'Eddard'), ('Lannister', 'Tyrion'), ('Baratheon', 'Joffrey'), ('Bolton', 'Ramsey'), ('Baelish', 'Peter')]

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(first_names, ['Jon', 'Cersei', 'Arya', 'Robb', 'Jamie', 'Daenerys', 'Sansa', 'Margaery', 'Eddard', 'Tyrion', 'Joffrey', 'Ramsey', 'Peter'], "Testing that first_names is correct.")
self.assertNotIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_4">
<statement>
<p>Use list comprehension to create a list called <c>lst2</c> that doubles each element in the list, <c>lst</c>.</p>

</statement>
<program xml:id="ac21_7_4_editor" interactive="activecode" language="python">
<input>
lst = [["hi", "bye"], "hello", "goodbye", [9, 2], 4]

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testFiveA(self):
self.assertEqual(lst2, [['hi', 'bye', 'hi', 'bye'], 'hellohello', 'goodbyegoodbye', [9, 2, 9, 2], 8], "Testing that lst2 is assigned to correct values")
self.assertNotIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_5">
<statement>
<p>Below, we have provided a list of tuples that contain students' names and their final grades in PYTHON 101. Using list comprehension, create a new list <c>passed</c> that contains the names of students who passed the class (had a final grade of 70 or greater).</p>

</statement>
<program xml:id="ac21_7_5_editor" interactive="activecode" language="python">
<input>
students = [('Tommy', 95), ('Linda', 63), ('Carl', 70), ('Bob', 100), ('Raymond', 50), ('Sue', 75)]

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(passed, ['Tommy', 'Carl', 'Bob', 'Sue'], "Testing that passed is correct.")
self.assertNotIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_6">
<statement>
<p>Write code using zip and filter so that these lists (l1 and l2) are combined into one big list and assigned to the variable <c>opposites</c> if they are both longer than 3 characters each.</p>

</statement>
<program xml:id="ac21_7_6_editor" interactive="activecode" language="python">
<input>

l1 = ['left', 'up', 'front']
l2 = ['right', 'down', 'back']

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(opposites, [('left','right'), ('front','back')], "Testing that opposites has the correct list of tuples.")
self.assertNotIn('map(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertIn('filter(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertNotIn('sum(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")
self.assertIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")


myTests().main()
</input>
</program>
</exercise>

<exercise label="ac21_7_7">
<statement>
<p>Below, we have provided a <c>species</c> list and a <c>population</c> list. Use zip to combine these lists into one list of tuples called <c>pop_info</c>. From this list, create a new list called <c>endangered</c> that contains the names of species whose populations are below 2500.</p>

</statement>
<program xml:id="ac21_7_7_editor" interactive="activecode" language="python">
<input>
species = ['golden retriever', 'white tailed deer', 'black rhino', 'brown squirrel', 'field mouse', 'orangutan', 'sumatran elephant', 'rainbow trout', 'black bear', 'blue whale', 'water moccasin', 'giant panda', 'green turtle', 'blue jay', 'japanese beetle']

population = [10000, 90000, 1000, 2000000, 500000, 500, 1200, 8000, 12000, 2300, 7500, 100, 1800, 9500, 125000]

=====

from unittest.gui import TestCaseGui

class myTests(TestCaseGui):

def testOne(self):
self.assertEqual(pop_info, [('golden retriever', 10000), ('white tailed deer', 90000), ('black rhino', 1000), ('brown squirrel', 2000000), ('field mouse', 500000), ('orangutan', 500), ('sumatran elephant', 1200), ('rainbow trout', 8000), ('black bear', 12000), ('blue whale', 2300), ('water moccasin', 7500), ('giant panda', 100), ('green turtle', 1800), ('blue jay', 9500), ('japanese beetle', 125000)], "Testing that pop_info was created correctly.")
def testTwo(self):
self.assertEqual(endangered, ['black rhino', 'orangutan', 'sumatran elephant', 'blue whale', 'giant panda', 'green turtle'], "Testing that endangered was created correctly.")
def testThree(self):
self.assertIn('zip(', self.getEditorText(), "Testing your code (Don't worry about actual and expected values).")

myTests().main()
</input>
</program>
</exercise>
</section>

2 changes: 2 additions & 0 deletions pretext/AdvancedAccumulation/Exercises.ptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0"?>
<p/>
Loading