Docsity

SWIFT PROGRAMMING BASICS: SYNTAX, DATA TYPES, AND CONTROL STRUCTURES UPDATED STUDY GUIDE, Exams of Medicine

Toggle sidebar
bg1
SWIFT PROGRAMMING BASICS: SYNTAX, DATA TYPES, AND
CONTROL STRUCTURES UPDATED STUDY GUIDE
QUESTIONS AND CORRECT ANSWERS
Computer
Programming
Writing instructions (code) that a computer follows to perform tasks.
Swift
A programming language created by Apple for building iOS, macOS, and other
Apple apps.
Syntax
The rules of the language—how code must be written to work correctly.
Syntax Error
Code breaks the rules of Swift (won't run).
Logical Error
Code runs but gives the wrong result.
print
Outputs text or values to the console.
Comments
(Program
Documentation)
Notes in code for humans. They do not run.
Types
(Data Types)
Define
what
kind
of data a value
holds.
String
Text inside quotes.
Double
Decimal
numbers.
Integer
Whole numbers.
Constants
Values that cannot change.
Variables
Values that can change.
Identifier
The
name
of
a variable,
constant,
function,
etc.
Arithmetic
Operators
+
addition,
-
subtraction,
*
multiplication,
/
division
Remainder
Operator
(MOD)
Returns
the
remainder
after
division.
Assignment Operator
Assigns a value.
Keywords
Reserved words with special meaning.
Input vs Output
Input:
Data
entered
into
a
program;
Output:
Data
shown
by a
program
(print).
Escape
Characters
Special
characters
inside
strings.
Placeholder
Used in formatted strings.
New Line
Moves text to the next line.
pf2

Partial preview of the text

Download SWIFT PROGRAMMING BASICS: SYNTAX, DATA TYPES, AND CONTROL STRUCTURES UPDATED STUDY GUIDE and more Exams Medicine in PDF only on Docsity!

SWIFT PROGRAMMING BASICS: SYNTAX, DATA TYPES, AND

CONTROL STRUCTURES UPDATED STUDY GUIDE

QUESTIONS AND CORRECT ANSWERS

Computer Programming Writing instructions (code) that a computer follows to perform tasks. Swift (^) A programming language created by Apple for building iOS, macOS, and other Apple apps. Syntax The rules of the language—how code must be written to work correctly. Syntax Error Code breaks the rules of Swift (won't run). Logical Error Code runs but gives the wrong result. print Outputs text or values to the console. Comments (Program Documentation) Notes in code for humans. They do not run. Types (Data Types) Define what kind of data a value holds. String Text inside quotes. Double Decimal numbers. Integer Whole numbers. Constants Values that cannot change. Variables Values that can change. Identifier The name of a variable, constant, function, etc. Arithmetic Operators + addition, - subtraction, * multiplication, / division Remainder Operator (MOD) Returns the remainder after division. Assignment Operator Assigns a value. Keywords Reserved words with special meaning. Input vs Output Input: Data entered into a program; Output: Data shown by a program (print). Escape Characters Special characters inside strings. Placeholder Used in formatted strings. New Line Moves text to the next line.

Tab Adds spacing. Inputting Quotations Use escape characters. String Literal A fixed string value. String Interpolation Inserting variables into strings. Compound Assignment Operator Shortened math + assignment. Increment Adds 1. Decrement Subtracts 1. Function A reusable block of code. Parameter A variable inside a function definition. Defining vs Calling a Function Defining: Creating the function; Calling: Using the function. Arguments Actual values passed into a function. Method A function that belongs to a type or object. Property A value that belongs to a structure or object. Array A collection of values. For Loop Repeats code for each item. Elements Individual items in an array. Identifying Position of an Element Arrays use index numbers, starting at 0. Dot Notation Access properties or methods. Structure (Struct) A custom data type. Property (Structure) Variables inside a struct. Sequence Code that runs top to bottom in order. Selection Making decisions. Iteration Repeating code (loops).