From 38f17179b2275708e0efe7cf02bb9bd73ca9cb67 Mon Sep 17 00:00:00 2001
From: Chris Harrelson
This is the CS10 version of The Beauty and Joy of Computing course during
Spring 2021.
diff --git a/llab b/llab
index 9dffce4dc..df13c5d33 160000
--- a/llab
+++ b/llab
@@ -1 +1 @@
-Subproject commit 9dffce4dccf7d630e80ad3cc85695f9c348ce722
+Subproject commit df13c5d33237ad090b3a3a0b634f2cc99a2716a4
From ba80e1a0532c8f8b334ce02d306393b50a2da69b Mon Sep 17 00:00:00 2001
From: Chris Harrelson Downloading MoviePy
(For Mac - in the code below you can also replace 'python3' with 'python' if you have an older version)
-Alonzos-Laptop:~ alonzo$ python3 -m pip install moviepy
+Alonzos-Laptop:~ alonzo$$ python3 -m pip install moviepy
(For Windows)
-Alonzos-Laptop:~ alonzo$ py -m pip install moviepy
+Alonzos-Laptop:~ alonzo$$ py -m pip install moviepy
That is all that is necessary to get the MoviePy Library onto your device! Next you will need to download diff --git a/cur/programming/python/csed_python/open_python.html b/cur/programming/python/csed_python/open_python.html index e58c3033c..ca2b349f1 100755 --- a/cur/programming/python/csed_python/open_python.html +++ b/cur/programming/python/csed_python/open_python.html @@ -48,7 +48,7 @@
>>>, the command line window has an active python interpreter open. That means we can't do commands like cd, or ls, because the program is expecting Python code. To leave the python interpreter, type the exit command exit() and press enter.
>>> exit()
-Alonzos-MacBook:~ alonzo$
+Alonzos-MacBook:~ alonzo$$
Any functions or variables created in the python interpreter are erased when the exit() command is run.
diff --git a/cur/programming/python/finding_a_bar.html b/cur/programming/python/finding_a_bar.html
index f3bb9614e..8e835990b 100755
--- a/cur/programming/python/finding_a_bar.html
+++ b/cur/programming/python/finding_a_bar.html
@@ -18,7 +18,7 @@
Now it's time to seriously write some code. Start by right clicking on this link and select save as. Make sure to save this file to the PythonLab1 directory that we made earlier. Head back to the shell and enter the ls command to make sure that the file made it into our PythonLab1 directory.
-Alonzos-MacBook:PythonLab1 alonzo$ ls
+Alonzos-MacBook:PythonLab1 alonzo$$ ls
virus.py
@@ -31,13 +31,13 @@
Head back to the shell and you can try running this file by entering python3 virus.py as shown below:
-Alonzos-MacBook:PythonLab1 alonzo$ python3 virus.py
+Alonzos-MacBook:PythonLab1 alonzo$$ python3 virus.py
Next try running the first exercise by entering python3 virus.py first_even_nums 5 (if it's working this should print the first 5 even numbers, starting with the number 2):
-Alonzos-MacBook:PythonLab1 alonzo$ python3 virus.py first_even_nums 5
+Alonzos-MacBook:PythonLab1 alonzo$$ python3 virus.py first_even_nums 5
2
4
6
@@ -47,7 +47,7 @@
Uh oh...it looks like we've only printed the first 4 even numbers. Head back to Sublime and edit the function called first_even_nums so that we get the correct behavior:
-Alonzos-MacBook:PythonLab1 alonzo$ python3 virus.py first_even_nums 5
+Alonzos-MacBook:PythonLab1 alonzo$$ python3 virus.py first_even_nums 5
2
4
6
diff --git a/cur/programming/python/hug_text_processing/python_basic_files.html b/cur/programming/python/hug_text_processing/python_basic_files.html
index 0175987bf..09abf7dd9 100644
--- a/cur/programming/python/hug_text_processing/python_basic_files.html
+++ b/cur/programming/python/hug_text_processing/python_basic_files.html
@@ -30,7 +30,7 @@
Run this file and you should see something mysterious that looks something like:
- $ python word_analyzer.py
+ $$ python word_analyzer.py
<_io.TextIOWrapper name='horse_ebooks.txt' mode='r' encoding='UTF-8'>
@@ -47,7 +47,7 @@
Try running word_analyzer.py, and you should get a print out of the contents of the file "horse_ebooks.txt".
- $ python word_analyzer.py
+ $$ python word_analyzer.py
Fruits and Vegetables and Vegetables on a Budget and Vegetables at a Store and Vegetables to Clean Fruit and Vegetables
If we look to the Python code, f.read() is the important part. read is a function that is built into every file object (just like .append is built into any list and .join is built into any string). Here, we're telling the file object to give us the information in the file for which it is responsible (horse_ebooks.txt). Note that this was not possible in Snap!, given the restrictions that our web browser places on the Snap! interpreter.
diff --git a/cur/programming/python/hug_text_processing/python_language_games.html b/cur/programming/python/hug_text_processing/python_language_games.html
index 2a5f32f52..ba4ac92ce 100644
--- a/cur/programming/python/hug_text_processing/python_language_games.html
+++ b/cur/programming/python/hug_text_processing/python_language_games.html
@@ -41,7 +41,7 @@
Pig Latin
Try running word_analyzer.py, and you should get:
- $ python word_analyzer.py
+ $$ python word_analyzer.py
Ellohay
-izzle Speak
@@ -117,7 +117,7 @@
Higher Order Manipulation
text = read_file("text_processing/gettysburg.txt")
print(apply_language_game(text, izzle))
- $ python word_analyzer.py
+ $$ python word_analyzer.py
Foizzle scorizzle izzle sevizzle yeizzle agizzle oizzle fathizzle broizzle ...
\ No newline at end of file
diff --git a/cur/programming/python/hug_text_processing/python_text_processing_intro.html b/cur/programming/python/hug_text_processing/python_text_processing_intro.html
index be8c4e74c..1ffeb2286 100644
--- a/cur/programming/python/hug_text_processing/python_text_processing_intro.html
+++ b/cur/programming/python/hug_text_processing/python_text_processing_intro.html
@@ -35,11 +35,11 @@
Download the data for this lab from this link.
Unzip this file into the datalab folder. You can unzip this file through the command line by using the unzip command.
- $ unzip text_processing.zip
-$ ls
+ $$ unzip text_processing.zip
+$$ ls
text_processing.zip text_processing
-$ cd text_processing
-$ ls
+$$ cd text_processing
+$$ ls
beatles.txt nietzsche.txt
democratic_debate_2015.txt presedential_debate_2016.txt
ee_cummings.txt republican_debate_2015.txt
diff --git a/cur/programming/python/hug_text_processing/python_top_words.html b/cur/programming/python/hug_text_processing/python_top_words.html
index 62907888d..e0f1cea4f 100644
--- a/cur/programming/python/hug_text_processing/python_top_words.html
+++ b/cur/programming/python/hug_text_processing/python_top_words.html
@@ -52,7 +52,7 @@
-$ python word_analyzer.py
+$$ python word_analyzer.py
['on', 'Budget', 'to', 'Fruit', 'Clean', 'Fruits', 'Store', 'at', 'a', 'and', 'Vegetables']
diff --git a/cur/programming/python/introduction-to-the-terminal.html b/cur/programming/python/introduction-to-the-terminal.html
index 9bfe2b92f..034552add 100644
--- a/cur/programming/python/introduction-to-the-terminal.html
+++ b/cur/programming/python/introduction-to-the-terminal.html
@@ -23,7 +23,7 @@ Opening a Terminal
If you're on one of the lab computers or on your own Mac, search for the application Terminal and open it. If you're using Windows, search for cmd.exe instead. After you open the program, you should have a window that has something like this in it:
-Alonzos-MacBook:~ alonzo$
+Alonzos-MacBook:~ alonzo$$
The little bit of text that's already in the window is called the prompt. It gives you a bit of information about the computer that you're on. When you type commands, they appear to the right of the prompt.
@@ -36,7 +36,7 @@
ls: listing contents of a directory
To see what's in the current directory, we can use the command ls (use dir instead if on Windows). The ls command lists the contents of our current directory. To use a command, type it in the terminal, then press 'enter'. Try it out. You should see something like this:
-Alonzos-MacBook:~ alonzo$ ls
+Alonzos-MacBook:~ alonzo$$ ls
Applications Downloads Pictures
Library Public Music
Desktop Movies Documents
@@ -46,8 +46,8 @@ cd: navigating to another directory
We can see that the home directory has some other directories in it, such as Documents and Desktop. If we want to go into one of those directories, we can use the command cd, followed by that directory's name. Try it out by using the command cd Documents.
-Alonzos-MacBook:~ alonzo$ cd Documents
-Alonzos-MacBook:Documents alonzo$
+Alonzos-MacBook:~ alonzo$$ cd Documents
+Alonzos-MacBook:Documents alonzo$$
Now you're in the Documents directory. We can use ls again to see the contents of Documents.
@@ -56,23 +56,23 @@
cd: navigating to another directory
How can we get back to the home directory from here? cd .. moves us upward one directory, which puts us back in home. The "dot dot" always means "parent directory". This means we can use cd .. to go to upward one directory. Try it out!
-Alonzos-MacBook:Documents alonzo$ cd ..
-Alonzos-MacBook:~ alonzo$
+Alonzos-MacBook:Documents alonzo$$ cd ..
+Alonzos-MacBook:~ alonzo$$
mkdir: making a new directory
Okay, now that we've tried that, let's go back to Documents. (If you're in home, use the command cd Documents). You're probably used to making new folders on your computer by using a menu action like "File > New Folder", or a keyboard shortcut like "shift-cmd-N". To make a new directory (folder) using the terminal, we can use the command mkdir followed by the name we want for the new directory. Try the command mkdir PythonLab1.
-Alonzos-MacBook:~ alonzo$ cd Documents
-Alonzos-MacBook:Documents alonzo$ mkdir PythonLab1
+Alonzos-MacBook:~ alonzo$$ cd Documents
+Alonzos-MacBook:Documents alonzo$$ mkdir PythonLab1
Nice! now use ls to confirm that your directory has been created! We can use cd PythonLab1 to go into our new directory.
-Alonzos-MacBook:Documents alonzo$ cd PythonLab1
-Alonzos-MacBook:PythonLab1 alonzo$
+Alonzos-MacBook:Documents alonzo$$ cd PythonLab1
+Alonzos-MacBook:PythonLab1 alonzo$$
diff --git a/cur/programming/python/open_python.html b/cur/programming/python/open_python.html
index 286adf0b7..919e7ed03 100755
--- a/cur/programming/python/open_python.html
+++ b/cur/programming/python/open_python.html
@@ -12,60 +12,3 @@
gtag('config', 'UA-176402054-1');
-
-
-
- Python can be tricky to run at first on some computers. Always ask if you're having trouble.
-
- On Mac OS X: (including in-lab computers)
-
- You'll be running python from the Terminal application that we learned about on the last page.
-
- On Windows
-
- Python may not be set up properly on windows. If you are unable to get python to work from the command line (as explained below) here is a link that will help you get things set up if you'd like to work on your Windows machine.
-
- Running Python
-
- The first step is to open the Python interpreter. On the command line in your terminal, use the command python3. If you see something like "command not found", then use the command python instead. You should see something similar to the following:
-
-
-Alonzos-MacBook:~ alonzo$ python3
-Python 3.4.0 (v3.4.0:04f714765c13, Month DD YYYY, HH:MM:SS)
-[GCC X.X.X] on darwin
-Type "help", "copyright", "credits" or "license" for more information.
->>>
-
-
- python and python3, what's the difference? When you open Python with one of these commands, check out the text that appears like above. You'll see something like Python 3.4.0 or Python 2.7.10. These are just different versions of Python. The folks who develop Python release updates as new versions, just like apps on the App Store. Don't worry, both versions will work for this lab.
-
-
- We're now using Python! Notice that we still have a prompt, but it looks like this now: >>>. The >>> indicates that we're using Python right now, and is where we can type Python code. After typing a line of code, hitting enter will tell the python interpreter to run the instruction. Try typing the following into the interpreter:
-
-
->>> 3 + 5
-8
-
-
- If the text cursor is on a line beginning with >>>, the command line window has an active python interpreter open. That means we can't do commands like cd, or ls, because the program is expecting Python code. To leave the python interpreter, type the exit command exit() and press enter.
-
->>> exit()
-Alonzos-MacBook:~ alonzo$
-
-
- Any functions or variables created in the python interpreter are erased when the exit() command is run.
-
-
-
- Here are some basic concepts about the Python intepreter you should understand before you move on:
-
- - Open the interpreter with the command
python or python3.
- - The interpreter will run the code you typed every time you press
enter.
- -
- Exit the interpreter with the command
exit(). Now you can use commands like cd and ls again, and whatever you did in Python is lost.
-
-
-
-
-
-
diff --git a/cur/programming/python/parsons/exponent.html b/cur/programming/python/parsons/exponent.html
index 94ae47d59..34f955717 100644
--- a/cur/programming/python/parsons/exponent.html
+++ b/cur/programming/python/parsons/exponent.html
@@ -64,7 +64,7 @@ Exercise 2: Exponents
}
}
- $(document).ready(function(){
+ $$(document).ready(function(){
var parson = new ParsonsWidget({
'sortableId': 'sortable',
'trashId': 'sortableTrash',
@@ -73,15 +73,15 @@ Exercise 2: Exponents
});
parson.init(initial);
parson.shuffleLines();
- $("#newInstanceLink").click(function(event){
+ $$("#newInstanceLink").click(function(event){
event.preventDefault();
parson.shuffleLines();
});
- $("#feedbackLink").click(function(event){
+ $$("#feedbackLink").click(function(event){
event.preventDefault();
parson.getFeedback("exponent");
});
- $("#exportLink").click(function(event){
+ $$("#exportLink").click(function(event){
event.preventDefault();
parson.export("exponent.py");
});
diff --git a/cur/programming/python/parsons/hello_world.html b/cur/programming/python/parsons/hello_world.html
index fe662133e..cee4f2a15 100644
--- a/cur/programming/python/parsons/hello_world.html
+++ b/cur/programming/python/parsons/hello_world.html
@@ -48,7 +48,7 @@ Exercise 0: Hello World
}
}
- $(document).ready(function(){
+ $$(document).ready(function(){
var parson = new ParsonsWidget({
'sortableId': 'sortable',
'trashId': 'sortableTrash',
@@ -57,15 +57,15 @@ Exercise 0: Hello World
});
parson.init(initial);
parson.shuffleLines();
- $("#newInstanceLink").click(function(event){
+ $$("#newInstanceLink").click(function(event){
event.preventDefault();
parson.shuffleLines();
});
- $("#feedbackLink").click(function(event){
+ $$("#feedbackLink").click(function(event){
event.preventDefault();
parson.getFeedback("hello_world");
});
- $("#exportLink").click(function(event){
+ $$("#exportLink").click(function(event){
event.preventDefault();
parson.export("hello_world.py");
});
diff --git a/cur/programming/python/parsons/palindrome.html b/cur/programming/python/parsons/palindrome.html
index 8ff53d911..4b119df49 100644
--- a/cur/programming/python/parsons/palindrome.html
+++ b/cur/programming/python/parsons/palindrome.html
@@ -57,7 +57,7 @@ Exercise 3: Palindrome
}
}
- $(document).ready(function(){
+ $$(document).ready(function(){
var parson = new ParsonsWidget({
'sortableId': 'sortable',
'trashId': 'sortableTrash',
@@ -66,15 +66,15 @@ Exercise 3: Palindrome
});
parson.init(initial);
parson.shuffleLines();
- $("#newInstanceLink").click(function(event){
+ $$("#newInstanceLink").click(function(event){
event.preventDefault();
parson.shuffleLines();
});
- $("#feedbackLink").click(function(event){
+ $$("#feedbackLink").click(function(event){
event.preventDefault();
parson.getFeedback("palindrome");
});
- $("#exportLink").click(function(event){
+ $$("#exportLink").click(function(event){
event.preventDefault();
parson.export("palindrome.py");
});
diff --git a/cur/programming/python/parsons/sum_all_numbers.html b/cur/programming/python/parsons/sum_all_numbers.html
index 99f986cd7..a6fb51c85 100644
--- a/cur/programming/python/parsons/sum_all_numbers.html
+++ b/cur/programming/python/parsons/sum_all_numbers.html
@@ -64,7 +64,7 @@ Exercise 1: Sum All Numbers
}
}
- $(document).ready(function(){
+ $$(document).ready(function(){
var parson = new ParsonsWidget({
'sortableId': 'sortable',
'trashId': 'sortableTrash',
@@ -73,15 +73,15 @@ Exercise 1: Sum All Numbers
});
parson.init(initial);
parson.shuffleLines();
- $("#newInstanceLink").click(function(event){
+ $$("#newInstanceLink").click(function(event){
event.preventDefault();
parson.shuffleLines();
});
- $("#feedbackLink").click(function(event){
+ $$("#feedbackLink").click(function(event){
event.preventDefault();
parson.getFeedback("sum_all_numbers");
});
- $("#exportLink").click(function(event){
+ $$("#exportLink").click(function(event){
event.preventDefault();
parson.export("sum_all_numbers.py");
});
diff --git a/cur/programming/python/run_a_python_script.html b/cur/programming/python/run_a_python_script.html
index 579281573..7b805070d 100644
--- a/cur/programming/python/run_a_python_script.html
+++ b/cur/programming/python/run_a_python_script.html
@@ -40,7 +40,7 @@ Running a Python File
Now, let's run the file with Python. Head back to your terminal, and use the commands you learned earlier to navigate to the PythonLab1 directory we made earlier. Once you are there, use the ls command to verify that lab1.py is there!
-Alonzos-MacBook:PythonLab1 alonzo$ ls
+Alonzos-MacBook:PythonLab1 alonzo$$ ls
lab1.py
@@ -53,7 +53,7 @@
Interactive Mode
Did you notice that after the command python3 lab1.py, the prompt was back to something like:
- Alonzos-MacBook:PythonLab1 alonzo$?
+ Alonzos-MacBook:PythonLab1 alonzo$$?
This means that even though we opened Python to run our program, Python exited when it was done. Sometimes, we'd like to stay in Python after we run a file!
diff --git a/cur/programming/python/running_script_from_command_line.html b/cur/programming/python/running_script_from_command_line.html
index 058bff420..f31dfde67 100755
--- a/cur/programming/python/running_script_from_command_line.html
+++ b/cur/programming/python/running_script_from_command_line.html
@@ -35,7 +35,7 @@ How files are organized on a computer:
First, enter the command ls to view a list of all of the files and directories that are located in your current directory (if you're using windows the command is dir not ls). If you see a ~ next to your user name (alonzo is the username below) then we are in our home directory. To go directly to your home directory enter the command cd. When your enter ls in your home directory you should see something similar to the following:
-Alonzos-MacBook:~ alonzo$ ls
+Alonzos-MacBook:~ alonzo$$ ls
Applications Downloads Pictures
Library Public Music
Desktop Movies Documents
@@ -46,17 +46,17 @@ How files are organized on a computer:
Next, move into the Documents directory by entering the command cd Documents. This stands for change directory to the given directory name. The following should appear (notice that the ~ has now been replaced by the directory name Documents):
-Alonzos-MacBook:~ alonzo$ cd Documents
-Alonzos-MacBook:Documents alonzo$
+Alonzos-MacBook:~ alonzo$$ cd Documents
+Alonzos-MacBook:Documents alonzo$$
If we need to move back out of our directory we can enter the command cd .. Shown below is how to move out of our documents directory and then back into it:
-Alonzos-MacBook:Documents alonzo$ cd ..
-Alonzos-MacBook:~ alonzo$ cd Documents
-Alonzos-MacBook:Documents alonzo$
+Alonzos-MacBook:Documents alonzo$$ cd ..
+Alonzos-MacBook:~ alonzo$$ cd Documents
+Alonzos-MacBook:Documents alonzo$$
@@ -64,10 +64,10 @@ How files are organized on a computer:
Finally, let's make a directory that will hold our python files.We can enter the command mkdir PythonLab1 to create a directory called PythonLab1 as shown below. Now that we have made this new directory enter the command cd PythonLab1 to go to the directory.
-Alonzos-MacBook:Documents alonzo$
-Alonzos-MacBook:Documents alonzo$ mkdir PythonLab1
-Alonzos-MacBook:Documents alonzo$ cd PythonLab1
-Alonzos-MacBook:PythonLab1 alonzo$
+Alonzos-MacBook:Documents alonzo$$
+Alonzos-MacBook:Documents alonzo$$ mkdir PythonLab1
+Alonzos-MacBook:Documents alonzo$$ cd PythonLab1
+Alonzos-MacBook:PythonLab1 alonzo$$
Now we have a place to put all of our python files! Continue to the next page to download the starter file for this lab.
diff --git a/cur/programming/variables/reviewing-variables.html b/cur/programming/variables/reviewing-variables.html
index f972c52fd..b2dea5b19 100755
--- a/cur/programming/variables/reviewing-variables.html
+++ b/cur/programming/variables/reviewing-variables.html
@@ -8,4 +8,4 @@
gtag('config', 'UA-176402054-1');
-
The previous lab was aimed at getting you comfortable with using variables to store values and thus to do things you couldn't do before. Variables are one of the central concepts in computer science and one of the most powerful tools in a programmer's toolbox. They will pop up steadily throughout the rest of the semester.
These are two blocks that we will be seeing a lot in the coming months. Make sure that you are clear with the differences are between them.

As we mentioned in the last lab, you can use these two blocks to accomplish the same thing, but it probably makes more sense to use one over the other depending on what you are trying to do. If you are trying to set the value relative to what it already is (such as adding $5 to a variable storing a bank balance), you will probably be better off using a change block. If you are trying to set it to a totally new, unrelated value (such as resetting someone's score in a video game), then you will probably want to use a set block.