Merge Sort Analysis Worst-case time complexity for applying the merge function to a size-k subarray: M(k) = 18k-7. template template Etype> void merge(Etype source[], void merge(Etype source[], Etype Etype dest[], dest[], int int lower, lower, int int middle, middle, int int upper) upper) { int int s1 s1 = = lower; lower; int // int s2 s2 = = middle middle + + 1; 1; // 1 1 TU TU int int d d = = lower; lower; do do { if if (source[s1] (source[s1] < < source[s2]) source[s2]) // // If If block: block: { // 14 { // 14 TU TU dest[d] dest[d] = = source[s1]; source[s1]; s1++; s1++; } else else { { dest[d] dest[d] = = source[s2]; source[s2]; s2++; s2++; } d++; // d++; // 1 1 TU TU } while ((s1 <= middle) && // } while ((s1 <= middle) && // k-m k-m iter. iter. (s2 // @ (s2 <= <= upper)); upper)); // @ 3 3 TU TU } } if (s1 > middle) do do { { dest[d] dest[d] = = source[s2]; source[s2]; s2++; s2++; d++; } } while while (s2 (s2 <= <= upper); upper); else else do do { { dest[d] = source[s1]; s1++; s1++; d++; d++; } } while while (s1 (s1 <= <= middle); middle); CS 340 // 1 TU // // // // // // // 6 6 1 1 1 m m TU TU TU TU TU iter. iter. @ @ 1 1 TU TU Time complexity for applying the order function to a size-k subarray: R(k), where R(1)=1 and R(k) = 5+M(k)+2R(k/2) = 18k-2+2R(k/2). This recurrence relation yields R(k) = 18klogk-logk+2. template template void order(Etype source[], Etype dest[], int lower, int upper) { int middle; if (lower != upper) { middle = (lower + upper) / 2; order(dest, source, lower, middle); order(dest, source, middle + 1, upper); merge(source, dest, lower, middle, upper); } } // 1 TU // // // // 3 TU R(k/2) TU R(k/2)+1 TU M(k) TU Time complexity for applying the mergesort function to a sizen subarray: T(n) = 8n+1+R(n) = 18nlogn+8n-logn+3. template void mergeSort(Etype A[], const int n) { Etype Acopy[n+1]; // 1 TU int size; for (int k = 1; k <= n; k++) // n iter. @ 2 TU Acopy[k] = A[k]; // 6 TU order(Acopy, A, 1, size); // R(n) TU } While While this this O(nlogn) O(nlogn) time time complexity complexity is is favorable, favorable, the the requirement requirement of of aa duplicate duplicate array array is is detrimental detrimental to to the the Merge Merge Sort Sort algorithm, algorithm, possibly possibly making making it it less less popular popular than certain alternative choices. than certain alternative choices. Page 16
View full slide show




Merge Sort void order(list source, list dest, int lower, int upper); void merge(list source, list dest, int lower, int middle, int upper); void sort(list L, int n) { list Lcopy; for (int k = 0; k < n; k++) Lcopy[k] = L[k]; order(Lcopy, L, 0, n - 1); } void order(list source, list dest, int lower, int upper) { int middle; if (lower != upper) { middle = (lower + upper) / 2; order(dest, source, lower, middle); order(dest, source, middle + 1, upper); merge(source, dest, lower, middle, upper); } } CS 240 void merge(list source, list dest, int lower, int middle, int upper) { int s1 = lower; int s2 = middle + 1; int d = lower; do { if (source[s1] < source[s2]) { dest[d] = source[s1]; s1++; } else { dest[d] = source[s2]; s2++; } d++; } while ((s1 <= middle) && (s2 <= upper)); if (s1 > middle) do { dest[d] = source[s2]; s2++; d++; } while (s2 <= upper); else do { dest[d] = source[s1]; s1++; d++; } while (s1 <= middle); } 57
View full slide show




Excel Methods to Create Frequency Distribution • COUNTIFS Excel function with two criteria • Count between the lower and upper limit • Because you have control over the comparative operators, you can create any type of Upper and Lower Limit. • This is different than with the PivotTable Grouping feature and the FREQUENCY Array Function. • PivotTables and the Grouping feature • When Grouping in a PivotTable: • Integer data yields unambiguous labels • Decimal data yields ambiguous labels • Remember: when you are counting between an upper and lower limit, the Upper Limit is NOT included and the Lower Limit IS included; unlike formulas we do not have control over how the upper and lower limits work when grouping. • FREQUENCY Array Function: • Next slide has full details about this function • One note here: For FRQUENCY Array Formula when you are counting between an upper and lower limit, the Upper Limit IS included and the Lower Limit is NOT included; unlike formulas we do not have control over how the upper and lower limits work when grouping. • FREQUENCY Array Function and Data Analysis Tools, Histogram yield the same answer. • Data Analysis Tools, Histogram • You must add this feature in: File tab, Options, Add-ins, Manage: Excel Ass-ins, Click Go, Check box for Analysis Toolpak, Click OK • This feature will create the Frequency Table (just like the FREQUENCY Array Function), a Histogram and a Cumulative Distribution. If Gap Width in Chart is not zero, you must change it!! • FREQUENCY Array Function and Data Analysis Tools, Histogram yield the same answer. 33
View full slide show




IEEE Std 1076.3 Packages Numeric_Bit  Comparison operators - various combinations of signed and unsigned arguments FUNCTION FUNCTION “>” “>” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION “<” (l,r:unsigned) RETURN boolean; FUNCTION “<” (l,r:unsigned) RETURN boolean; FUNCTION FUNCTION “<=” “<=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION “>=” (l,r:unsigned) RETURN boolean; FUNCTION “>=” (l,r:unsigned) RETURN boolean; FUNCTION FUNCTION “=” “=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION FUNCTION “/=” “/=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean;  Shift and rotate functions FUNCTION FUNCTION shift_left shift_left (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION shift_right (arg:unsigned; count:natural) RETURN FUNCTION shift_right (arg:unsigned; count:natural) RETURN unsigned; unsigned; FUNCTION rotate_left (arg:unsigned; count:natural) RETURN unsigned; FUNCTION rotate_left (arg:unsigned; count:natural) RETURN unsigned; FUNCTION FUNCTION rotate_right rotate_right (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION FUNCTION sll sll (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION slr (arg:unsigned; count:natural) RETURN unsigned; FUNCTION slr (arg:unsigned; count:natural) RETURN unsigned; FUNCTION FUNCTION rol rol (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION ror (arg:unsigned; count:natural) RETURN unsigned; FUNCTION ror (arg:unsigned; count:natural) RETURN unsigned; 24/03/19 UAH-CPE528 8
View full slide show




IEEE Std 1076.3 Packages Numeric_Bit  Comparison operators - various combinations of signed and unsigned arguments FUNCTION FUNCTION “>” “>” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION “<” (l,r:unsigned) RETURN boolean; FUNCTION “<” (l,r:unsigned) RETURN boolean; FUNCTION FUNCTION “<=” “<=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION “>=” (l,r:unsigned) RETURN boolean; FUNCTION “>=” (l,r:unsigned) RETURN boolean; FUNCTION FUNCTION “=” “=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean; FUNCTION FUNCTION “/=” “/=” (l,r:unsigned) (l,r:unsigned) RETURN RETURN boolean; boolean;  Shift and rotate functions FUNCTION FUNCTION shift_left shift_left (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION shift_right (arg:unsigned; count:natural) RETURN FUNCTION shift_right (arg:unsigned; count:natural) RETURN unsigned; unsigned; FUNCTION rotate_left (arg:unsigned; count:natural) RETURN unsigned; FUNCTION rotate_left (arg:unsigned; count:natural) RETURN unsigned; FUNCTION FUNCTION rotate_right rotate_right (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION FUNCTION sll sll (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION slr (arg:unsigned; count:natural) RETURN unsigned; FUNCTION slr (arg:unsigned; count:natural) RETURN unsigned; FUNCTION FUNCTION rol rol (arg:unsigned; (arg:unsigned; count:natural) count:natural) RETURN RETURN unsigned; unsigned; FUNCTION ror (arg:unsigned; count:natural) RETURN unsigned; FUNCTION ror (arg:unsigned; count:natural) RETURN unsigned; 24/03/19 UAH-CPE528 24
View full slide show




Jagged arrays  Implemented as arrays of arrays , 4 index type index lower bound index upper bound address address , 3 , 3 index type index type index lower bound index lower bound index upper bound index upper bound address address , 7 , 7 index type index type index lower bound index lower bound index upper bound index upper bound address address , 4 , 4 index type index type index lower bound index lower bound index upper bound index upper bound address address , 5 , 5 index type index type index lower bound index lower bound index upper bound index upper bound address address 24
View full slide show




Merge Sort Recursively sort both halves of the list, and then quickly merge the two sorted halves to form the entire sorted list.int s1 = lower; int s2 = middle + 1; int d = lower; do { if (source[s1] < source[s2]) { dest[d] = source[s1]; s1++; } else { dest[d] = source[s2]; s2++; } d++; } while ((s1 <= middle) && (s2 <= upper)); template void mergeSort(Etype A[], const int n) { Etype Acopy[n+1]; int size; for (int k = 1; k <= n; k++) Acopy[k] = A[k]; order(Acopy, A, 1, size); } template void order(Etype source[], Etype dest[], int lower, int upper) { int middle; if (lower != upper) { middle = (lower + upper) / 2; order(dest, source, lower, middle); order(dest, source, middle + 1, upper); merge(source, dest, lower, middle, upper); } } template void merge(Etype source[], Etype dest[], int lower, int middle, int upper) { CS 340 } if (s1 > middle) do { dest[d] = source[s2]; s2++; d++; } while (s2 <= upper); else do { dest[d] = source[s1]; s1++; d++; } while (s1 <= middle); Page 14
View full slide show




Suppose you have regression results based on quarterly data for a particular household. SPENDING 10.0  0.70 (INCOME)  3.0 (WINTER)  2.0 (SPRING) - 1.0 (SUMMER) SPENDING and INCOME are in thousands of dollars. WINTER equals 1 if the quarter is winter and 0 if it is fall, spring or summer. SPRING is 1 if the quarter is spring and 0 if it is fall, winter or summer. SUMMER is 1 if the quarter is summer and 0 if it is fall, spring or winter. Suppose, household income is 10 thousand dollars for all 4 quarters of a particular year. In the fall, spending would be expected to be 17 thousand dollars. In the spring, spending would be expected to be 2.0 thousand dollars higher than in fall or 19 thousand dollars. In the winter, spending would be expected to be 3.0 thousand dollars higher than in the fall or 20 thousand dollars. In the summer, spending would be expected to be 1.0 thousand dollars less than in the fall or 16 thousand dollars.
View full slide show




IEEE Std 1076.3 Packages Numeric_Bit  Resize functions FUNCTION FUNCTION resize resize (arg:unsigned;new_size:natural) (arg:unsigned;new_size:natural) RETURN RETURN unsigned; unsigned; FUNCTION resize (arg:signed;new_size:natural) RETURN signed; FUNCTION resize (arg:signed;new_size:natural) RETURN signed;  Conversion functions FUNCTION FUNCTION to_integer to_integer (arg:unsigned) (arg:unsigned) RETURN RETURN natural; natural; FUNCTION to_unsigned (arg,size:natural) RETURN FUNCTION to_unsigned (arg,size:natural) RETURN unsigned; unsigned;  Logical operators FUNCTION FUNCTION “not” “not” (l:unsigned) (l:unsigned) RETURN RETURN unsigned; unsigned; FUNCTION “and” (l,r:unsigned) RETURN FUNCTION “and” (l,r:unsigned) RETURN unsigned; unsigned; FUNCTION FUNCTION “or” “or” (l,r:unsigned) (l,r:unsigned) RETURN RETURN unsigned; unsigned; FUNCTION “nand” (l,r:unsigned) RETURN FUNCTION “nand” (l,r:unsigned) RETURN unsigned; unsigned; FUNCTION “nor” (l,r:unsigned) RETURN unsigned; FUNCTION “nor” (l,r:unsigned) RETURN unsigned; FUNCTION FUNCTION “xnor” “xnor” (l,r:unsigned) (l,r:unsigned) RETURN RETURN unsigned; unsigned;  Edge detection functions FUNCTION FUNCTION rising_edge(SIGNAL rising_edge(SIGNAL s:bit) s:bit) RETURN RETURN boolean; boolean; FUNCTION falling_edge(SIGNAL s:bit) RETURN FUNCTION falling_edge(SIGNAL s:bit) RETURN boolean; boolean; 24/03/19 UAH-CPE528 9
View full slide show




IEEE Std 1076.3 Packages Numeric_Bit  Resize functions FUNCTION FUNCTION resize resize (arg:unsigned;new_size:natural) (arg:unsigned;new_size:natural) RETURN RETURN unsigned; unsigned; FUNCTION resize (arg:signed;new_size:natural) RETURN signed; FUNCTION resize (arg:signed;new_size:natural) RETURN signed;  Conversion functions FUNCTION FUNCTION to_integer to_integer (arg:unsigned) (arg:unsigned) RETURN RETURN natural; natural; FUNCTION to_unsigned (arg,size:natural) RETURN FUNCTION to_unsigned (arg,size:natural) RETURN unsigned; unsigned;  Logical operators FUNCTION FUNCTION “not” “not” (l:unsigned) (l:unsigned) RETURN RETURN unsigned; unsigned; FUNCTION “and” (l,r:unsigned) RETURN FUNCTION “and” (l,r:unsigned) RETURN unsigned; unsigned; FUNCTION FUNCTION “or” “or” (l,r:unsigned) (l,r:unsigned) RETURN RETURN unsigned; unsigned; FUNCTION “nand” (l,r:unsigned) RETURN FUNCTION “nand” (l,r:unsigned) RETURN unsigned; unsigned; FUNCTION “nor” (l,r:unsigned) RETURN unsigned; FUNCTION “nor” (l,r:unsigned) RETURN unsigned; FUNCTION FUNCTION “xnor” “xnor” (l,r:unsigned) (l,r:unsigned) RETURN RETURN unsigned; unsigned;  Edge detection functions FUNCTION FUNCTION rising_edge(SIGNAL rising_edge(SIGNAL s:bit) s:bit) RETURN RETURN boolean; boolean; FUNCTION falling_edge(SIGNAL s:bit) RETURN FUNCTION falling_edge(SIGNAL s:bit) RETURN boolean; boolean; 24/03/19 UAH-CPE528 25
View full slide show




Appendix 4 Financing Your Franchise: Average Maximum Initial Investments From highest to lowest, investment amounts are: Restaurants: 1,900 thousand dollars Autos: 1,110 thousand dollars Fast food: 708 thousand dollars Personal services: 442 thousand dollars Retail stores: 426 thousand dollars Real estate: 384 thousand dollars Commercial services: 275 thousand dollars Business services: 163 thousand dollars Return to original slide ©McGraw-Hill Education.
View full slide show




Appendix 1 Figure 16.4 Estimated U.S. Advertising Expenditure in 2016 by Medium (in Billions of Dollars) From highest to lowest projected advertising spending: • TV: approximately 37 billion dollars • Digital: approximately 35 billion dollars • Radio: approximately 8 billion dollars • Newspapers: approximately 7.5 billion dollars • Magazines: approximately 7 billion dollars • Outdoor: approximately 4 billion dollars • Directories: approximately 2 billion dollars Return to original slide ©McGraw-Hill Education.
View full slide show




Intensive Care Lab Assessing Process Capability Example 6.5 Cp = Cp = Upper specification - Lower specification 30 - 20 6(1.35) 6 = 1.23 Process Capability Ratio Does not meet 4 (1.33 Cp) target Before Process Modification Upper specification = 30.0 minutes Lower specification = 20.0 minutes Average service = 26.2 minutes  = 1.35 minutes Cpk = 0.94 Cp = 1.23 After Process Modification Upper specification = 30.0 minutes Lower specification = 20.0 minutes Average service = 26.1 minutes  = 1.2 minutes Cpk = 1.08 Cp = 1.39 © 2007 Pearson Education
View full slide show




Readback of Error Count CDL Readback of ERROR_COUNT Block: RCA 0x1000, FC 5 COUNT DESCRIPTION LIMIT 0 No Known cause 1 Temperature Greater than Upper Limit Error. > 50.0 C. 2 28V Voltage Lower Limit Error. < 27.0 V. 3 28V Voltage Upper Limit Error. > 29.0 V. 4 Rectifier High Voltage Error. 5 Rectifier Low Voltage Error. 6 1.8V Voltage Upper Limit Error. > 2.2 V. 7 3.3V Voltage Upper Limit Error. > 3.6 V. 8 5.0V Voltage Upper Limit Error. > 5.5 V. 9 Rectifier Over Temperature Alert. 10 1.8V Current Upper Limit Error. > 60.0 A. 11 9UBPS 3.3V Current Upper Limit Error. > 50.0 A. 12 5.0V Current Upper Limit Error. > 3.0 A. 13 QCC V1.8 Lower Limit Error. < 1.6 V. 14 QCC V3.3 Lower Limit Error. < 3.0 V. 15 QCC V5.0 Lower Limit Error. < 4.5 V. 16 QCC V1.8 Upper Limit Error. > 2.2 V. 17 QCC V3.3 Upper Limit Error. > 3.6 V. ALMA Correlator Workshop, May 2016 11
View full slide show




Text Functions to Transform Data • TEXT function: converts a number to text with a Custom Number Format that you specify. TEXT(number, "Custom Number Format in quotes") • RIGHT function: extracts a given number of characters from the right • LEFT function: extracts a given number of characters from the lef • MID function: extracts from the middle given a starting point and the number of characters that you want • SEARCH function: tells you the starting position in a text string of text you specify. FIND is similar to SEARCH, but it is case sensitive. • TRIM function: removes spaces from a text string except for single spaces between words • REPLACE function: function replaces part of a text string with text you specify, given a starting number and the number of characters • SUBSTITUTE function: finds some text and replaces it with some different text • PROPER function: changes all capital letters or all lower case letters to all lower case except for first letter in each word • LEN function: counts characters • LOWER function: converts all letters to lower case • UPPER function: converts all letters to upper case 5
View full slide show




Effects of Money Market and Output Market Changes on the Long-Run Nominal Dollar/Euro Exchange Rate, E$/€ Change Effect on the long-run nominal $/€ exchange rate, E$/€ Money Market 1. Increase in U.S. money supply level Proportional increase (nominal depreciation of $) 2. Increase in European money supply level Proportional decrease(nominal depreciation of €) 3. Increase in U.S. money supply growth rate Increase (nominal depreciation of $) 4. Increase in European money supply growth rate Decrease (nominal depreciation of €) Output Market 1. Increase in demand for U.S. output Decrease (nominal appreciation of $) 2. Increase in demand for European output Increase (nominal appreciation of €) 3. Output supply increase in the U.S. Ambiguous 4. Output supply increase in the Europe Ambiguous
View full slide show




QC - Perpendicularity 25 20 20 15 10 5 Point I After Tack Weld H Pe rpendicularity (Actual - Nominal) (in) Point L After Tack W eld Per p en d icu la r ity (A ctu a l - N o m in al ) (in ) Perpendicula rity (Actual - Nom ina l) (in) I 12 10 J 20 15 16 14 12 10 8 6 4 2 0 K 25 0 Perpendicularity (Actual - Nominal) (in) 2 12 30 5 0 4 0 Frequency 5 6 P o int K A ft e r T a c k W e ld F req u en cy 10 8 B F re quency 10 40 35 25 G Perpendicularity (Actual - Nominal) (in) Perpe ndicularit y (Act ual - Nominal) ( in) Point J After Tack Weld 15 5 Point H After T ack Weld 16 14 12 10 8 6 4 2 0 Perpendicularity (Actual - Nominal) (in) 20 10 Pe rpendicularity (Ac tual - Nominal) (in) Freq uency 14 12 10 8 6 4 2 0 15 0 0 Point G After Tack Weld Freque nc y Frequency 25 Perpe ndicularity (Actual - Nominal) (in) Frequency Point F After Tack Weld Point E After Tack Weld Fre quenc y Freque ncy Point D After Tack Weld 16 14 12 10 8 6 4 2 0 Pe rpendicula rity ( Ac tual - Nom ina l) ( in) Pe rpendicularity (Actua l - Nom inal) (in) 12 Perpendicularity (Actual - Nominal) (in) F 0 • QC Sheet 12 4 2 0 C 6 A 5 8 14 12 10 8 6 4 2 0 L 10 10 Frequency Freq uency 15 E 12 20 Frequency Point C After Tack Weld D Point B After Tack Weld Point A After Tack Weld
View full slide show




IUC’s scope will focus on two functions (Finance and IT) Adherence to process definitions within the Hackett taxonomy is key to comparability; processes are defined end to end Selling and General Administrative Scope Finance Finance Human Human Resources Resources Sales* Sales* Executive Executive and and Corporate Corporate Services Services**  Total  Sales  General Cash Cash Disbursements Disbursements Total Rewards Rewards Administration Administration Sales Execution Execution General Administration Administration Management Management    Revenue Cycle Payroll Services Sales Operations   Travel and  Revenue Cycle Payroll Services Sales Operations Travel and Transportation Transportation Services Services  Planning  Real Accounting Accounting and and External External Reporting Reporting  Data Data Mgmt., Mgmt., Reporting Reporting & & Compliance Compliance Planning and and Strategy Strategy Real Estate Estate & & Facilities Facilities Management Management  Staffing  Function  Government Tax Tax Management Management Staffing Services Services Function Management Management Government Affairs Affairs  Labor  Legal Treasury Treasury Management Management Labor Relations Relations Legal  Workforce  Quality Compliance Compliance Management Management Workforce Development Development Services Services Service* Quality Management Management Service*  Organisational  Planning Risk  Order  Planning & & Performance Performance Management Management Organisational Effectiveness Effectiveness Risk and and Security Security Management Management Order and and Contract Contract Management Management (OTC) (OTC)  Total  Corporate Fiscal Communications  Service Fiscal Analysis Analysis Total Rewards Rewards Planning Planning Execution Corporate Communications Service Execution  Strategic  Planning Function  Service Function Management Management Strategic Workforce Workforce Planning Planning Planning and and Strategy Strategy Service Operations Operations  Function  Executive Office  Planning Function Management Management and Strategy Executive Office Planning and Strategy  Function Function Management Management Information Technology          Information Technology            Infrastructure Infrastructure Management Management End End User User Support Support Infrastructure Infrastructure Development Development Application Application Maintenance Maintenance Application Application Development Development & & Implement. Implement. Quality Quality Assurance Assurance Risk Risk Management Management IT IT Business Business Planning Planning Enterprise Enterprise Architecture Architecture Planning Planning Emerging Emerging Technologies Technologies Function Function Management Management Procurement Procurement            Supply Supply Data Data Management Management Requisition Requisition and and PO PO Processing Processing Supplier Scheduling Supplier Scheduling Receipt Receipt Processing Processing Compliance Compliance Management Management Customer Customer Management Management Sourcing Sourcing Execution Execution Supplier Supplier Management Management and and Development Development Sourcing Sourcing & & Supply Supply Base Base Strategy Strategy Function Function Strategy Strategy and and Performance Performance Management Management Function Function Management Management Marketing* Marketing*      Marketing Marketing Communication Communication Brand Brand and and Product Product Management Management Planning and Planning and Strategy Strategy Market Market Research Research and and Analytics Analytics Function Management Function Management Capture FTEs and Costs as defined regardless of where they are organizationally located
View full slide show




More examples: def calcvol(length,width,depth): area = length * width vol = area * depth return(vol) #area only exists inside this function def bankaccount(x,add): dollars = 2.57 print("Currently, you have " + str(dollars) + " in your bank account") if add == 1: dollars = dollars + x # evaluate right, then assign to left else: dollars = dollars - x return("you now have " + str(dollars) + " in your bank account") #again, function ends when the return statement is executed. print(bankaccount(0.10,1) print(bankaccount(1.0, 0)
View full slide show