View number_game.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var target, guess_input, guess_input_text; | |
var finished = false; | |
var guesses = 0; | |
function guessing_game() { | |
var random_number = Math.random() * 100; | |
var random_number_integer = Math.floor(random_number); | |
target = random_number_integer + 1; | |
while (!finished) { | |
guess_input_text = prompt("Guess what number I'm thinking of? "); |
View list-to-thinkful-gists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I was thinking about making this a nice HTML page... another day perhaps | |
Working with Strings: | |
[textNormalizer.js] https://gist.github.com/misterhtmlcss/b6f1ef8a76308c975c2faac4951acdd5 | |
[Shouter.js] https://gist.github.com/misterhtmlcss/6bb9b08d140b57b0dddf472eb26c4443 | |
[wisePerson.js] https://gist.github.com/misterhtmlcss/20126d550d9019652639b38ae8079e0b | |
Working with Numbers: |
View learning-journal-u2-a.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# Part 1 | |
The volume of a sphere is 4/3πr3, where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called print_volume (r) that takes an argument for the radius of the sphere, and prints the volume of the sphere. | |
✓ Call your print_volume function three times with different values for radius. | |
✓ Include all of the following in your Learning Journal: | |
- The code for your print_volume function. | |
- The inputs and outputs to three calls of your print_volume. |
View learning-journal-u2-b.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# Part 2 | |
Write your own function that illustrates a feature that you learned in this unit. The function must take at least one argument. The function should be your own creation, not copied from any other source. Do not copy a function from your textbook or the Internet. | |
Include all of the following in your Learning Journal: | |
✓ The code for the function that you invented. | |
✓ The inputs and outputs to three calls of your invented function. | |
✓ A description of what feature(s) your function illustrates. |
View discussion-unit-3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Describe the difference between a chained conditional and a nested conditional. Give your own example of each. Do not copy examples from the textbook. | |
Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional. Do not copy the example from the textbook. | |
✓ Describe the difference between a chained conditional and a nested conditional. | |
✓ Give your own example of each. | |
✓ Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional. | |
✓ Describe a strategy for avoiding nested conditionals (bottom). |
View unit-3-princewill.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# x = -10 | |
# x = 0 | |
# x = 2 | |
if x != 0: | |
print("This number ", x, " is not 0.") | |
else: | |
print(x, " is 0") | |
# I think the not operator is interesting. |
View learning-journal-unit-3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from colorama import Fore | |
# 1. countdown & countup application | |
# ✓ The code of your program. | |
# ✓ Output for the following input: a positive number, a negative number, and zero. | |
# ✓ An explanation of your choice for what to call for input of zero. | |
# Count down from a positive number | |
def countdown(n): | |
if n == 0: |
View discussion-unit4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CS1101 - Discussion Forum Unit 4 | |
# Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working. | |
# ✓ Define "precondition" and "postcondition" as part of your description. (First two paragraphs) | |
# ✓ Describe each possibility in your own words. (All three paragraphs) | |
# A precondtion is a problem before the function’s arguments are passed into the parameters (Downey, A. 2015). Are there arguments being passed? Sometimes a function is called a long ways away from where it’s defined. With languages like Python it’s often critical to name parameters effectively so that the correct arguments are passed. This can be as simple as missing a type e.g. ‘5’ instead of 5. | |
# A postcondition is a problem that follows from the point immediately following the arguments being passed (Downey, A. 2015). A really simple example could be `function (a, b) { b -a }`. No matter the language we can all see how it’s unlikely that a human mind would order the parameters as a follow |
View output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is_power(10, 2) returns: False | |
is_power(27, 3) returns: True | |
is_power(1, 1) returns: True | |
is_power(10, 1) returns: False | |
is_power(3, 3) returns: True |
View discussion-unit-5.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ************************** | |
# CS1101 - Discussion Unit 5 | |
# ************************** | |
# ************************** | |
# Instructions | |
# 1. Check whether its argument has any lowercase letters | |
# 2. Describe what it actually does when called with a string argument and if it does not correctly check for lowercase letters. | |
# 4. Give an example argument that produces incorrect results. (SEE BOTTOM for 3 calls to all functions!) | |
# 5. Describe why the result is incorrect. (SEE inline comments) |
OlderNewer