computer science 1000 spreadsheets ii permission to redistribute these slides is strictly prohibited...

47
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Upload: leon-mcdaniel

Post on 28-Jan-2016

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Computer Science 1000

Spreadsheets II

Permission to redistribute these slides is strictly prohibited without permission

Page 2: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Spreadsheet Computing spreadsheets can be used exclusively for data

formatting and layout however, their most common application is to

process data what does this mean?

in the context of spreadsheets, it means that the spreadsheet provides new information based on what we supply

this information can be in the form of data, but also in formatting (e.g. display negative numbers in red)

Page 3: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Formula a statement in a cell that performs a computation

e.g. math equation, table lookup, etc …

every formula has a value the result of the computation this is the value that is displayed the formula itself will be displayed in the formula bar

formulas can be combined indicated by an initial = sign

in other words, when the data in a cell begins with =, Excel interprets the remainder to be a formula

Page 4: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Formulas - Constant constant: a formula whose value is itself examples include:

numbers text dates

by themselves, constants are not typically expressed as a formula

they are usually used in other formulas

Page 5: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Constant a number

Page 6: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Constants by themselves, numeric constants aren’t that useful

as formulas they have the same functionality outside of formula

instead, they are usually used as part of another formula

these include: numeric operators function inputs

Page 7: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Excel accepts the standard math operators

+, -, * (times), / (divide), ^ exponent

these operators are used in typical binary format e.g. to compute 3+4, enter the formula =3+4

Page 8: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Question: what happens if I omit the equal sign?

Excel interprets the formula as text, as it cannot be interpreted directly as a number or a date (due to the + in the middle).

Remember to use = when using formulae.

Page 9: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Question: what happens when I combine

operators?Excel honours the order of operations that you are used to:

highest: ^next: * /lowest: + -

Page 10: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Question: suppose I want to perform operations out of order

(e.g. perform the add before the multiply)?

Use parentheses to reorder your operations. Operations in parentheses have the highest priority.

Page 11: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Example: compute the average of 1,2,3 and 4.

Use parentheses to perform the addition before the division.

Page 12: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Numeric Operators Example 2: Recall our transaction spreadsheet. We used all

numeric constants. Use formulas to compute the final three amounts:

Page 13: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission
Page 14: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Text Constants text can also be used as a constant in a formula however, not as simple as putting the text after the

= sign

Whenever you see a computed value that starts with #, it often indicates an error.

In this case, Excel does not know that Kev is meant to be text

Page 15: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Text Constants when text constants are used in a formula, enclose

them in double quotes

Page 16: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Text Concatenation like numeric constants, not often used by

themselves can be used in concatenation – combine multiple

text elements into a single version use the operator &

Page 17: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Text Concatenation when using concatenation, you must specify all of

the characters you want to appear a common mistake is to forget about spaces

Page 18: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Mixing Typeswhat happens when we do the following?

Excel will attempt to convert the values based on the operator type. In this example, because & accepts two text items, it converts 1000 to “1000”

Page 19: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Mixing Typeswhat happens when we do the following?

In this example, because + accepts two numbers, it converts “4” to 4

Page 20: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Mixing Typeswhat happens when we do the following?

In this example, because - accepts two numbers, it tries to convert “CS ” to a number. Since this fails, an error is generated.

Page 21: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Mixing Types - Precedence question: what’s the output of the following?

The & operator has lower precedence than all of the math operators. Hence, the formula is parsed as:

“1” & ( “2” – 4 )“1” & -2“1” & “-2”“1-2”

Page 22: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions a preset formula in Excel each function has a name functions accept a set of zero or more inputs

surrounded by parentheses separated by commas

a function has a value usually, the function performs some computation, and its

value is the result of that computation

Page 23: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Function - First Examplesuppose you want to know the square root

of a numberExcel has a function called sqrt

accepts one input – a value or formula

Page 24: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Function - Inputs note that the input to a function can be another

formula, if you like the inside formula is evaluated before its value is sent to

the function

Page 25: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Function - Inputs the input to a function can even be another function

the inside function is evaluated first its value is sent as the input to the outside function

Page 26: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Function - Inputs your function will expect a particular type as its

input will convert if necessary

Page 27: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Function - Inputs your function will expect a particular type as its

input an error occurs if it can’t convert

Page 28: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions – No Input some functions have no inputs

they always return the same value the parentheses are still required, to indicate that it’s a

function nothing is placed inside

e.g. pi() - returns the value π

Page 29: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions – Example compute the volume of a cylinder of radius 10.4 and height

25.6 Formula: V = πr2h

Page 30: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions – Example spot the error in the formula

pi is a function, and hence must have parentheses to indicate this

Page 31: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions – Multiple Inputs some functions accept more than one input each input should be separated by commas example: max

returns the maximum value amongst all of its inputs

Page 32: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Functions – Multiple Inputs not all inputs need to have the same type e.g. left

left accepts a text input S, and a number X, and returns the first X characters in S

Page 33: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Boolean Values a type that can be one of the two following values:

TRUE FALSE

think of it like yes (TRUE) or no (FALSE) these values can be on their own, or in a formula

Page 34: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Boolean Values some function inputs require boolean values e.g. vlookup (from your lab)

the last parameter indicates whether the value you are looking can be an approximate match

approximate: TRUE exact: FALSE

Page 35: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Boolean Values instead of specifying Boolean values, they are often

computed this is done using comparison operators

= (equal) <> (not equal) < (less than) > (greater than) <= (less than or equal to) >= (greater than or equal to)

Page 36: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Comparison Operatorscan be used on text typescan be used on mixed types

Page 37: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

If Statement one of the most useful functions in Excel takes three inputs

a Boolean value remember: can be a formula that returns a Boolean

a “True” value the value of the function if the first input is true

a “False” value the value of the function if the first input is false

in other words, it selects either the second or third input as its value, depending on whether its first input is true or false

Page 38: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission
Page 39: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

If Statement remember: any of the inputs can be formula themselves

Since 3 < 4 is true, the value of this formula is the second input, or sqrt(16)

Page 40: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

If Statement remember: any of the inputs can be formula themselves

Since 3 > 4 is true, the value of this formula is the third input, or max(6,7)

Page 41: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Excel Functions there are many functions built into ExcelMath

abs – returns the absolute value of its inputsin, cos, tan – returns the sine/cosine/tan value

of its inputaverage – returns the average value of its input

Page 42: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Excel Functions there are many functions built into ExcelText

len – returns the number of characters in its input string

lower – converts all characters in its input to lower case

upper – converts all characters in its input to upper case

Page 43: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Excel Functions – HelpExcel has a handy feature that assists users

in function recallclicking on the formula bar label will activate

a dialog that lists all of the functions available in Excel

this includes a categorization, and a search feature

Page 44: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission
Page 45: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission

Excel Functions – Help furthermore, selecting a function from this

list shows a dialog with a place to insert each input, with a description of what it does

Page 46: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission
Page 47: Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission