Docsity

Swift Programming: Syntax, Data Types, Functions, and Control Flow UPDATED Study Guide Q, Exams of Medicine

Toggle sidebar
bg1
Swift Programming: Syntax, Data Types,
Functions, and Control Flow UPDATED
Study Guide QUESTIONS AND
CORRECT ANSWERS
- Swift - CORRECT ANSWERS A powerful and intuitive
programming language for Apple platforms, designed to be safe,
modern, and fast.
Syntax - CORRECT ANSWERS The set of rules that define
how a program's structure and code must be written for the compiler
to understand it.
Syntax Error - CORRECT ANSWERS A mistake in the code's
grammar (e.g., a typo or missing parenthesis) that prevents the code
from compiling.
Logical Error - CORRECT ANSWERS A flaw in the
program's design or logic; the code runs but produces an incorrect or
unintended result.
print - CORRECT ANSWERS The function used to output
text, variables, or expressions to the console or standard output.
Comment - CORRECT ANSWERS Non-executable lines of
code used for program documentation and to explain code logic.
pf3
pf4
pf5

Partial preview of the text

Download Swift Programming: Syntax, Data Types, Functions, and Control Flow UPDATED Study Guide Q and more Exams Medicine in PDF only on Docsity!

Swift Programming: Syntax, Data Types,

Functions, and Control Flow UPDATED

Study Guide QUESTIONS AND

CORRECT ANSWERS

  • Swift - CORRECT ANSWERS A powerful and intuitive programming language for Apple platforms, designed to be safe, modern, and fast. Syntax - CORRECT ANSWERS The set of rules that define how a program's structure and code must be written for the compiler to understand it. Syntax Error - CORRECT ANSWERS A mistake in the code's grammar (e.g., a typo or missing parenthesis) that prevents the code from compiling. Logical Error - CORRECT ANSWERS A flaw in the program's design or logic; the code runs but produces an incorrect or unintended result. print - CORRECT ANSWERS The function used to output text, variables, or expressions to the console or standard output. Comment - CORRECT ANSWERS Non-executable lines of code used for program documentation and to explain code logic.

Keyword - CORRECT ANSWERS A reserved word (like let, var, func) in Swift that has a predefined meaning and cannot be used for naming. Input - CORRECT ANSWERS Data that is provided to the program from an external source (e.g., keyboard or file). Output - CORRECT ANSWERS Data that the program sends out (e.g., text displayed on the screen). Types - CORRECT ANSWERS Defines the kind of data a value can store (e.g., whole number, decimal, text). Strings - CORRECT ANSWERS An ordered collection of characters used to represent textual data (e.g., "Hello, World"). Double - CORRECT ANSWERS A floating-point type used to store numbers with a decimal component (high precision). Integer - CORRECT ANSWERS A whole number (positive, negative, or zero) with no fractional component. Constant - CORRECT ANSWERS Declared with let; its value is set once and cannot be changed later. Variable - CORRECT ANSWERS Declared with var; its value can be changed after it is initially set.

if vs. else if vs. else - CORRECT ANSWERS Control flow statements used for conditional execution to run different code based on different conditions. Function - CORRECT ANSWERS A self-contained block of code that performs a specific, reusable task. Parameter - CORRECT ANSWERS The name and type defined in a function's declaration to receive an input value. Argument - CORRECT ANSWERS The actual value passed into a function when it is called, corresponding to a parameter. Defining your function - CORRECT ANSWERS Writing the actual structure of the function using the func keyword. Calling your function - CORRECT ANSWERS Executing the function by using its name followed by parentheses containing arguments. Methods - CORRECT ANSWERS Functions that are associated with a specific type (e.g., a class or struct); they perform actions on the data. Properties - CORRECT ANSWERS Constants or variables that are part of a type; they store values associated with an instance.

Arrays - CORRECT ANSWERS An ordered collection of values where all elements must be of the same type. For Loop - CORRECT ANSWERS A control flow statement used to iterate over a sequence (like an array) and execute code for each element. Arrays in Functions - CORRECT ANSWERS Passing an array as an argument to a function or returning an array as the function's output. Initializing Empty Array - CORRECT ANSWERS Creating an array with zero elements, allowing data to be added later (e.g., var data: [String] = []).