Docsity

D278 SCRIPTING AND PROGRAMMING FOUNDATIONS COMPREHENSIVE LESSON NOTES, Exams of Programming Paradigms

Partial preview of the text

Download D278 SCRIPTING AND PROGRAMMING FOUNDATIONS COMPREHENSIVE LESSON NOTES and more Exams Programming Paradigms in PDF only on Docsity!

D278 SCRIPTING AND

PROGRAMMING FOUNDATIONS

COMPREHENSIVE LESSON NOTES

◉ Basic instruction types Answer: input, process, output ◉ input Answer: A program gets data, perhaps from a file, keyboard, touchscreen, network, etc. ◉ process Answer: A program performs computations on that data, such as adding two values like x + y. ◉ output Answer: A program puts that data somewhere, such as to a file, screen, network, etc. ◉ variable

Answer: programs use these because its value varies e.g. x, y, z; some name that can hold a value; named item ◉ Computational Thinking Answer: creating a sequence of instructions to solve a problem ◉ Algorithm Answer: A sequence of instructions that solves a problem ◉ Flowchart Answer: graphical language for creating or viewing computer programs ◉ coral language Answer: A language intended for learning to program ◉ program Answer: list/sequence of statements ◉ statement Answer: carries out some action and executes one at a time; specific action; set of instructions

Answer: consists of text (characters) within double quotes, as in "Go #57!". ◉ character Answer: includes any letter (a-z) or digit (0-9) or symbol (#,@,&,!, etc.) ◉ cursor Answer: indicates where the next output item will be placed in the output ◉ newline Answer: Special two-character sequence \n whose appearance in an output string literal causes the cursor to move to the next output line. ◉ put x to output Answer: outputting a variable's value is achieved by ◉ comment Answer: text a programmer adds to a program, to be read by humans to better understand code, but ignored by the program when executing; usually starts with "//"

◉ Whitespace Answer: refers to blank spaces (space and tab characters) between items within a statements, and to newlines; helps improve readability for humans, but is ignored during execution by program ◉ switch Answer: either a 1 (on) or a 0 (off) ◉ Moore's Law Answer: reducing switch sizes by half nearly every 2 years ◉ Information Age Answer: began in 1990s; human activity shifting to creating/managing/using computerized information; agricultural age - > industrial age - > ___ ◉ bit Answer: single 0 or a single 1 ◉ byte Answer: 8 bits ◉ American Standard Code for Information Interchange (ASCII)

◉ coral Answer: simple language for learning program; e.g. flowchart and code; looks like pseudocode, but follows rules that allow execution ◉ assignment statement Answer: assigns a variable with a value, such as x = 5 ◉ = Answer: symbol that puts a value into the variable; assignment in programming ◉ variable declaration statement Answer: declares a new variable, specifying the variable's name and type ◉ Integer Answer: All whole numbers (both positive and negative) and zero. ◉ Expression Answer: may be a number like 80, variable name like numApples, or a simple calculation like numApples + 1

◉ identifier Answer: A name created by a programmer for an item like a variable or function; must: start with a letter, contain letters (a-z; A-Z), underscores, and digits (0-9) ◉ reserved word Answer: key word; word that is part of the language, like an integer; cannot be used as an identifier; ◉ Naming Conventions Answer: a set of style guidelines when developing identifiers; e.g. camelcase and underscore separated ◉ camel case Answer: capitalizes the words except the first (e.g. numApples, peopleOnBus) ◉ underscore separated Answer: words are all lowercase and separated by underscores (e.g. num_apples or people_on_bus) ◉ literal Answer: a specific value in code like 2

◉ floating-point literal Answer: a number with a fractional part, even if that fraction is 0, as in 1.0, 0.0, or 99. ◉ Infinity or - Infinity Answer: Dividing a nonzero floating-point number by zero. ◉ Not a Number (NotANumber) Answer: when a dividend and divisor are both 0 ◉ function Answer: list of statements executed by invoking the function's name, with such invoking known as a function call ◉ Arguments Answer: The values that the programmer provides in the function call. ◉ Random Number Answer: Coral function that takes two arguments, lowValue and highValue, and returns an integer in that range; e.g. RandomNumber (1, 10) returns a random integer in the range 1 to 10

◉ pseudo-random Answer: integers generated by RandomNumber() ◉ seed Answer: built-in integer ◉ divide-by-zero error Answer: Occurs at runtime if a divisor is 0, causing a program to terminate. ◉ type conversion Answer: conversion of data, such as integer to floating ◉ implicit conversion Answer: automatic conversion ◉ type cast Answer: converts a value of one type to another type ◉ modulo operator Answer: %, evaluates the remainder of the division of two integer operands

◉ if-else branch Answer: has two branches: The first branch is executed IF an expression is true, ELSE the other branch is executed. ◉ if-elseif branches Answer: a series of decisions appear cascaded in each decision's false branch ◉ equality operator Answer: (==) evaluates to true if the left side and right side are equal ◉ nested branches Answer: Branches that can take on various forms, and the if-else branches may even use different variables. ◉ multiple if branches Answer: each decision is independent, and thus more than one branch can execute, in contrast to the if-elseif arrangement where only one branch can execute. ◉ != Answer: not equal

◉ Relational Operators Answer: Used to compare two values. Operators include =,<,>,<=,>=,<> ◉ logical operator Answer: Treats operands as being true or false, and evaluates to true or false; includes: and, or, not; ◉ implicitly vs explicitly Answer: no gaps = implicitly gaps = explicitly ◉ epsilon Answer: The difference threshold indicating that floating-point numbers are equal; its value depends on the program's expected values, commonly 0. ◉ nested branches Answer: ◉ loop

◉ Loop Variable Initialization, loop expression, loop variable update Answer: parts of a loop that iterate a specific number of times ◉ while loop Answer: a programming construct used to repeat a set of commands (loop) as long as (while) a boolean condition is true ◉ for loop Answer: type of loop that contains a loop variable initialization, a loop expression, and a loop variable update that typically describes iterating for a specific number of times. ◉ nested loop Answer: A loop inside the body of another loop; commonly referred to as inner loop and outer loop ◉ inner loop Answer: for loop that handles the printing of the asterisks ◉ outer loop Answer: while loop that handles executing until a negative number is entered

◉ do-while loop Answer: first executes the loop body's statements, then checks the loop condition ◉ vector Answer: construct similar to an array ◉ element Answer: each item in an array is known as... ◉ index Answer: each element's location number is called the... ; myArray[2] has an index 2; usually will start with 0 instead of 1: myArray[0], myArray[1], myArray[2]... ◉ swapping Answer: two variables swap value; e.g. x = 55 and y = 7 --> x = 7 and y = 55; typically will need a third variable (tmpVal) to hold one of the values while the swap occurs ◉ function is a ___ Answer: named list of statements; function definition, function call, local variable

Answer: value provided to a function's parameter during a function call; e.g. a pizza area function might be called PizzaArea(12.0) or PizzaArea(16.0) ◉ return variable Answer: A function may return one value and does so by assigning a return variable with the return value. ◉ Modular development Answer: The process of dividing a program into separate modules that can be developed and tested separately and then integrated into a single program. ◉ function stub Answer: a function definition whose statements have not yet been written ◉ function definition begins with ___ Answer: begins with word "Function," the function's name, and a list comma-separated parameters (if any) in parentheses, and a return indication ◉ return statement

Answer: explicitly returns the specified value and immediately exits the function ◉ algorithm time efficiency Answer: number of calculations it takes to solve a problem in an algorithm ◉ linear Answer: type of algorithm that starts at the beginning and checks each item until found; search may be slow ◉ binary Answer: type of algorithm that checks range's middle; if value is greater, will search in upper half and vice versa; essentially looking at half the data not all of it; can be faster than linear (e.g. used with search engines) ◉ computational problem Answer: specifies an input, a question about the input that can be answered using a computer, and the desired output. ◉ longest common substring