Repository containing practice problems for DSC 40A (past exams and discussion). Hosted at practice.dsc40a.com.
Note to futor tutors: If you encountered new issues and resolved it, please help contribute to the "Troubleshooting tips" section below. Thank you!
-- Your fellow tutor from 2025
-
- Requirements and setup
-
- Understanding the repo
-
- Adding problem sets
-
- Troubleshooting tips
Before using the repo, make sure you have the following packages installed:
- BeautifulSoup4
- pandoc
- lxml
Note: If you have taken dsc80, you can run this in dsc80's environment.
(1). Here is a walkthrough video of how to edit the site.
(2). Here's another walkthrough video of how to use the latex-to-practice-site script!
- Important folders: assume you are inside the root directory,
practice.dsc40a.com/. The only three important folders you will read/write to will be:
assets: Where you put your images from the exams.docs: Where you can preview the site's.HTMLpage files.pages: Contains metadata/ general information about each exam in.ymlformat. You will add a new file to exam or topic for generating new exam files.problems: The generated markdown files from your exams. In case the generating python file fails to compile your latex exam, this is where you will mannually write up the questions and answers.
- Answer: should be bolded followed by unbolded answer(s), comma separated if it fits on one line, or each answer on a new line if it doesn't fit on one line
- Use () for choose one, [] for select all. Add a space before the text of each answer choice.
- For subsubparts, use numbers followed by period to introduce each question
In translating from Latex to Markdown, there are a few easy find/replace things that help with a lot of things:
\begin{verbatim} --> ```py
\end{verbatim} --> ```
" --> '
\_ --> _
\texttt{ --> `
\textbf{ --> **
\textit{ --> *
\bubble --> ( )
\correctbubble --> ( )
\squarebubble --> [ ]
\correctsquarebubble --> [ ]
\begin{subprobset} -->
\end{subprobset} -->
\begin{subprob} --> # BEGIN SUBPROB
\end{subprob} --> # END SUBPROB
\begin{responsebox} --> # BEGIN SOLUTION
\end{responsebox} --> # END SOLUTION
\begin{soln} --> # BEGIN SOLUTION
\end{soln} --> # END SOLUTION
\bigskip -->
\noindent -->
- Note: ( ) and [ ] need a space between the brackets. There should not be blank lines between options.
To explain up-front:
- All exams are individual (collaboration on exams is never allowed).
- What ( ) and [ ] mean. In their absence, students needed to write out code by hand.
- In-person means on-paper.
- Think of select-all questions as a sequence of true-false questions. Partial credit for these questions was assigned accordingly.
- When taking an exam for practice, we recommend having a copy of the DSC 10 reference sheet open in another tab, as well as a second copy of the exam, so you can access the data descriptions.
- As usual, create exam file in
pagesand add your current exam questions to theexamsandtopicsfolder. - Now, if you encounter issue with generating exams because of format issue, go to
problems-> create new folder for exam -> create MD files for each question. You can useproblems/template.mdtemplate to generate question files and solution.
NOTE: Please remember to check for correctness; LLM is not to be relied upon, and we want to be responsible to our fellow students. :) - Compile and test it locally:
python run.py [insert yaml file name for the exam you created/changed]. For example,python run.py pages/exams/ss1-25-midterm.yml**NOTE: Unless youve messed up tremendously and feel like you have to recompile everything, do not run ``python run.py` without arguments; this will take some 5-10 minutes regenerating every MD file for every exam and topic!
When you are adding a new exam, this is typically what youll do.
- If you are not familar with git and worry about messing up, create a separate branch so your will not risk exploding the practice site accidentally. 💥 Only merge your changes to main when you make sure everything works.
- In the page folder, create exam file in
pages/exams. By topic, update the topic file inpages/topics. - Follow the steps in the video, run
utils/latex-to-md.py. If runningutils/latex-to-md.pyfails, create MD file mannually for all the exam questions. - In case latex to md fails, you will possibly also have to add the new file to
docs/index.html. Add a new entry like this:
<tr>
<th scope="row">
[Fall 2025] <!-- 1. Quarter information -->
</th>
<td>
Gal Mishne
</td>
<td>
[<a href='fa25-midterm/index.html'>Final </a>] <!-- 2. Your exam files that will be generated by run.py. -->
[<a href='fa25-midterm/index.html'>Midterm </a>]
</td>
</tr>- Locally test the files by compiling and run
run.pywith the approprieate argument, go intodocs/your-exam/, and open theHTMLfile to check correctness. Also checkdocs/index.htmlto see your exam is being displayed.
python run.py
Traceback (most recent call last):
File "..../practice.dsc40a.com/run.py", line 1, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
Example Behavior:
(base) practice.dsc40a.com % python run.py
Traceback (most recent call last):
File "practice.dsc40a.com/run.py", line 1, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
(base) practice.dsc40a.com % pip3 install PyYAML
[notice] A new release of pip is available: 24.2 -> 25.3
[notice] To update, run: python3.12 -m pip install --upgrade pip
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.
If you wish to install a Python library that isn't in Homebrew,
use a virtual environment:
python3 -m venv path/to/venv
source path/to/venv/bin/activate
python3 -m pip install xyz
If you wish to install a Python application that isn't in Homebrew,
it may be easiest to use 'pipx install xyz', which will manage a
virtual environment for you. You can install pipx with
brew install pipx
You may restore the old behavior of pip by passing
the '--break-system-packages' flag to pip, or by adding
'break-system-packages = true' to your pip.conf file. The latter
will permanently disable this error.
If you disable this error, we STRONGLY recommend that you additionally
pass the '--user' flag to pip, or set 'user = true' in your pip.conf
file. Failure to do this can result in a broken Homebrew installation.
Read more about this behavior here: <https://peps.python.org/pep-0668/>
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Solution:
- If you have already installed the above packages but still encounter this issue, and have taken DSC 80, use DSC 80 environment either in terminal or in VS code.
- Otherwise, there will be some rocky troubleshooting with your python environment. Wish you the best of luck (from struggling former tutor).
File "practice.dsc40a.com/run.py", line 549, in <module>
write_all_pages()
File "practice.dsc40a.com/run.py", line 508, in write_all_pages
write_page(path, called_from_write_all_pages=True)
File "practice.dsc40a.com/run.py", line 421, in write_page
page, title = process_page(path, is_discussion=is_discussion)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "practice.dsc40a.com/run.py", line 389, in process_page
out += stitch(params['problems'], params['show_solution'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "practice.dsc40a.com/run.py", line 121, in stitch
r = open(path, 'r', encoding='UTF-8').read()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'problems/ss2-24-final\\ss2-24-final-q01.md'
Cause: Windows and mac have different ways of doing pathnames.
Solution: In run.py, you can see the following line:
def stitch(files, show_solution, toc=False):
...
for i, path in enumerate(paths):
# Comment the line below out if you are using windows.
path = path.replace('\\', '/')
# Coment the line above out if you are using windows.
path = os.path.normpath(path)
...Follow the instruction of the comments. If you have issue with pathname, the cause is likely somewhere in this function.