Additional Resources when preparing for React:
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). |
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 objects and values using the terms “equivalent” and “identical”. Illustrate the difference using your own examples with Python lists and the “is” operator. | |
✓ Describe the relationship between objects, references, and aliasing. Again, create your own examples with Python lists. | |
(Very bottom) | |
✓ Create your own example of a function that modifies a list passed in as an argument. Describe what your function does in terms of arguments, parameters, objects, and references. | |
""" | |
print('\n') |
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: |
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 |
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 how tuples can be useful with loops over lists and dictionaries, and give Python code examples. Create your own code examples. Do not copy them from the textbook or any other source. | |
✓ Your descriptions and examples should include the following: the zip function, the enumerate function, and the items method. | |
""" | |
# Tuples are immutable and are therefore excellent choices for immutable data, this includes dealing with through the managing out of issues such as 'aliasing' which can cause unintended assignment bugs (Downey, A. 2015). Also Tuples should be used as the data type of choice with data that is typically permanently linked ex. phone number and name, eye colour, etc (Pythonist 2019). Another example of good data to link is geo-data and post code. | |
# An example could be a Tuple for the class and objects within the Tuple for the grades that change, but the size and make up of the class shouldn't; I'm ignoring drop outs in this example. | |
def grade_tracker(): |
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 |
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. |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- | |
The following 2 meta tags *must* come first in the <head> | |
to consistently ensure proper document rendering. | |
Any other head element should come *after* these tags. | |
--> | |
<meta charset="UTF-8"> |
NewerOlder