- Jul 2022
-
htdp.org htdp.org
-
[X X -> Boolean]
comparison. how do i know if its sorted function
-
-
htdp.org htdp.org
-
cmp
sorting criteria function. you want to apply this guy to some list eventually. cmp tells us what it means to be sorted
-
- Mar 2020
-
htdp.org htdp.org
-
The first language always provides some forms of atomic data; to represent the variety of information in the real world
for example, real world data might be a temperature. We need some language of describing the temperature data such as a number
-
-
eloquentjavascript.net eloquentjavascript.net
-
Methods are nothing more than properties that hold function values. This is a simple method
Many built in objects have methods such as
Array.forEach
-
- Feb 2020
-
classes.mst.edu classes.mst.edu
-
If you have any questions, be sure to ask. Good luck.
OUTPUT is air filter model number
INPUT
- make
- year
- cylindres
EXAMPLE
Edsel 1986 6
E8606
-
-
classes.mst.edu classes.mst.edu
-
You'll need to round up the calculation on the right-hand-side of this formula. If the result calculated for N above has no fractional part, add an extra gallon for safety sake.
for this its okay to use ceil or round http://www.cplusplus.com/reference/cmath/ceil/
-
Make your prompt for input friendly and clear. The same goes for the output. You should always start with a "welcoming" message in your programs. Something like:
then and only after you did part 1, make a commnd line interface
COMMANDS
do 3 separate inputs
enter children amount (cant be partial) enter surface area enter days
-
Specifications: You are to write a simple program to help a painter decide how much paint to buy for a job dependent on certain relevent and irrelevent input data. Here's how it works
write a function that takes nc, S, nd
output N where N is number of galls of paint to purchase
-
-
classes.mst.edu classes.mst.edu
-
type: floating point allocation: 4 bytes precision: you get 6 significant figures (decimal) example declaration
float is smallest decimal type next is double
-
-
runestone.academy runestone.academy
-
strings, lists, and tuples
strings, lists, tuple
-
-
runestone.academy runestone.academy
-
type conversion function
int('3') # produces the integer 3 </prei
-
modulus operator
3 % 2 # 1 </pre
-
logical operator
True and False # False True or False # True </pre
-
integer division
3 // 2 # 1
-
literal
x = 'cat' #x is assigned to the string literal cat
-
-
developer.mozilla.org developer.mozilla.org
-
Hyperlinks are really important — they are what makes the Web a web
-
Active learning: creating a navigation menu
exercise
-
Paths specify where in the filesystem the file you are interested in is loca
-
Active learning: creating your own example link
Exercise 1
-
-
classes.mst.edu classes.mst.edu
-
someValue = static_cast<int>(Num1 + Num2); // no warning – OK
casts a double to an integer.
-
val++; //increment ++val; val--; //decrement --val;
increment/decrement
-
static_cast<float>
this is used to cast a value to another type. since we are casting an integer to float we do not lose any information
-
-
classes.mst.edu classes.mst.edu
-
float celc; // output variable 15. float fahr; // input variable
variable declaration
definition would actually given that variable a value
celc = 30.5; //definition int x = 5; //declaration and definition int y; //just declaration
-
06. #include <iostream>
include directive which brings in the code from iostream into your program for use
-
-
classes.mst.edu classes.mst.edu
-
what is an algorithm? I define it as a clear, concise, correct step-by-step sequence of steps to solve a problem
algorithm should be 1) finite 2) correct 3) efficient
-
Example 1
do these examples as much as you can before looking at the solution
-
-
runestone.academy runestone.academy
-
Flow of control is often easy to visualize and understand if we draw a flowchart. This flowchart shows the exact steps and logic of how the for statement executes.
a forloop will alter the control flow
A B C REPEAT 10 times{ } D
before this program can do D is must repeat 10 times which is altering the sequential flow of the program so that we get a loop. instead of going directly to D, program does something 10 times.
-
-
runestone.academy runestone.academy
-
A basic building block of all programs is to be able to repeat some code over and over again.
- repeat something n number of times
for i in range(n): #do something
- do something until some condition
while <condition>:
this loops continues until the conidtion evaluates false
- looping through a colllection/or sequence
#looping through string s = 'cat' for char in s: #list
animals = ['cat', 'rabbit', 'dog'] for a in animals: print(a)
over the course of this loop character is going to be equal to each individual character in s
- repeat something n number of times
-
-
runestone.academy runestone.academy
-
ist is a sequential collection of
lists are mutable. (mutable means subject to change) it means you can mutate the list, add stuff remove stuff etc
-
parentheses
1 element tuple must be initaliexed like this
t = (1,)
-
[10, 20, 30, 40]
list literal
-
-
runestone.academy runestone.academy
-
assign 71 to a variable that represents current temperature
this means they want you to create a new variable and set its value to 71. don't over think it, just set the variable to 71 and name the variable temp or something like that.
-
-
classes.mst.edu classes.mst.edu
-
Suppose that you are playing football on a large field with several friends and one of you discovers that a house key has been lost. Write an algorithm for finding the key that is designed to find it as quickly as possible. Write another algorithm designed to take a long time to find the key. Can you reason whether your algorithms are the best possible or worst possible algorithms for this particular task?
This is not meant to be written in c++. just use pseudo code or plain english to describe the algorithm
for example, a horrible algorithm that fails to find solution is this
function::badFunction() -> key returns key if key found otherwise returns null check the spot you are currently standing on the football field if key is there then return true otherwise return key is not there
-
2. Programming Fundamentals 2.0. Algorithms 2.1. C++ Basics 2.2. Variable Declarations 2.3. Reserved Words
read this before feb 15
-
In order to fix the flat yourself, you need a lug-wrench, a jack, and an inflated spare tire. If you don't have any one of these, you must call for help. Write a step-by-step description of how you are able to continue your drive.
basically you got two choices 1) you have all the tools dont need to all for help 2) your missing at least one tool and you need to call for help
-
- Dec 2019
-
runestone.academy runestone.academy
-
protected member variable or function is similar to a private member but it has the additional benefit that they can be accessed by derived classes.
In other words, any class inheriting from "LogicGate" will have access to its parents protected members.
-
-
runestone.academy runestone.academy
-
if 𝑛nn does not divide 𝑚mm evenly, then the answer is the greatest common divisor of 𝑛nn and the remainder of 𝑚mm divided by 𝑛nn.
m = 20, n = 10 20 / 10 = 2 CASE 1
m = 100, n = 70 100 / 70 CASE 2 gcd(100, 100 % 70) =
gcd(100, 30) gcd(100,30) CASE 2 gcd(100, 100 % 30) =
gcd(100, 10) 100 / 10 = 10 CASE 1
gcd(100, 70) = 10
-
- Oct 2019
-
runestone.academy runestone.academy
-
atomic data types
atomic in the sense that these days types are not composed of any other data types
-