Unit 4 - Variables, Conditionals, and Functions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

comparison operators

<, >, <=, >=, ==, != indicate a Boolean expression

variable

A placeholder for a piece of information that can change.

local variable

A variable that can only be accessed from a specific portion of a program

global variable

A variable whose scope covers the entire program, it can be used and updated by any part of the code. Its scope is typically derived from the variable being declared (created) outside of any function, object, or method.

Logic Error

An error in a program that makes it do something other than what the programmer intended.

Boolean expression

An expression that evaluates to either true or false

string

Any sequence of characters between quotation marks.

evaluate

Expressions are evaluated to produce a single value.

logical operator

NOT, AND, and OR, which evaluate to a Boolean value.

Conditionals

Statements that only run under certain conditions.

if-statement

The common programming structure that implements "conditional statements".

expression

a combination of operators and values that evaluates to a single value

function call

a command that executes the code within a function

Boolean value

a data type that is either true or false.

pseudocode

a description of the actions of a program or algorithm, using a mixture of English and informal programming language syntax

procedure

a named group of programming instructions that may have parameters and return values. Also referred to as a "function".

function

a named group of programming instructions. Also referred to as a "procedure".

expression

a programming statement that can consist of a value, a variable, an operator, or a procedure call that returns a value.

Iteration

a repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.

algorithm

a step-by-step procedure for solving a problem

conditional statement

affect the sequential flow of control by executing different statements based on the value of a Boolean expression.

assignment operator

allows a program to change the value represented by a variable

selection

determines which parts of an algorithm are executed based on a condition being true or false

Many conditionals example - if this compound condition or that compound condition

if (((condition 1) && (condition2)) || ((condition3) && (condition4))) { // Run this code } Parentheses are needed for: 1) the entire compound conditional statement 2) the first compound conditional statement 3) the second compound conditional statement 4) All individual conditions.

Compound conditional AND example

if ((condition 1) && (condition2) ) { //Run this code }

Compound conditional OR example

if ((condition1) || (condition2)) { //Run this code }

if-else-if statement syntax (App Lab)

if (condition) { // Run this code } else if (condition) { // Run this code } else { // Run this default code } The if-else-if statement is used when you want to have levels of conditions. You can add as many else if statements as you need. "Check one condition first. If it is false, check another condition", etc.

if-else statement syntax (App Lab)

if (condition) { // Run this code } else { // Run this default code }

if statement syntax (App Lab)

if (condition) { //Run this code }

concatenation

joins together two or more strings end-to-end to make a new string.

arithmetic operators

part of most programming languages and include addition, subtraction, multiplication, division, and modulus operators.

MOD

performs the modulo operation between two numbers. It is represented by the % sign. The modulo operation finds the remainder. For example, 5 MOD 2 or 5%2 returns the value of 1. The remainder of 5 divided by 2 is 1.


Set pelajaran terkait

Geografia y cultura mundial Repaso Nov 30

View Set

Chapter 1: Perspectives on Maternal and Child Health Care PREP U

View Set

Exploring Data: Measures of Central Tendency Definitions & Terminology

View Set

أسئلة عشوائية - تاريخ الأردن

View Set