[X X -> Boolean]
comparison. how do i know if its sorted function
[X X -> Boolean]
comparison. how do i know if its sorted function
cmp
sorting criteria function. you want to apply this guy to some list eventually. cmp tells us what it means to be sorted
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
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
If you have any questions, be sure to ask. Good luck.
OUTPUT is air filter model number
INPUT
EXAMPLE
Edsel 1986 6
E8606
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
type: floating point allocation: 4 bytes precision: you get 6 significant figures (decimal) example declaration
float is smallest decimal type next is double
strings, lists, and tuples
strings, lists, tuple
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
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
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
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
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
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{ } Dbefore 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.
A basic building block of all programs is to be able to repeat some code over and over again.
for i in range(n): #do something
while <condition>:
this loops continues until the conidtion evaluates false
#looping through string s = 'cat' for char in s: #listanimals = ['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
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
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.
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
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.
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
atomic data types
atomic in the sense that these days types are not composed of any other data types