Programming Fundamentals Study Guide: Algorithms, Data Types, and Operators, Exams of Advanced Education

This study guide provides a comprehensive overview of fundamental programming concepts, including algorithms, computation, semantics, and syntax. It covers essential elements such as input and output, execution, and interactivity. The guide also explains identifiers, values, memory locations, and variables, along with different data types like strings, integers, floats, and booleans. It details assignment statements, constants, functions, operators, operands, and expressions, including mathematical and relational operators. Additionally, it discusses decision-making processes using if, elif, and else statements, as well as loops, lists, and functions. Designed to help students grasp the core principles of programming and build a solid foundation for more advanced topics. It is useful for university and high school students.

Typology: Exams

2024/2025

Available from 07/11/2025

Prof-Cornel
Prof-Cornel 🇺🇸

4.9K documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Engr 103 Study Guide With
Complete Solution
Algorithm - ANSWER A set of instructions to perform a task or solve a
problem, must be precise enough for a computer to execute
your code
Computation - ANSWER When a computer executes an algorithm
"run" or \.program.py
Semantics - ANSWER Refers to meaning, concepts/vocabulary used across
programming languages
Syntax - ANSWER Programming language specific, like a grammar that a
compiler can recognize
Input - ANSWER The data or information passed into a computational system
before a program is run
e.g., input()
Output - ANSWER The data or information passed out of a computational
system once the computation is complete
e.g., print()
Execution - ANSWER The process by which a computer interprets our
program or performs the instructions of our program
Interactivity - ANSWER The ability of the code to detect events from a user,
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Programming Fundamentals Study Guide: Algorithms, Data Types, and Operators and more Exams Advanced Education in PDF only on Docsity!

Engr 103 Study Guide With

Complete Solution

Algorithm - ANSWER A set of instructions to perform a task or solve a problem, must be precise enough for a computer to execute your code Computation - ANSWER When a computer executes an algorithm "run" or .program.py Semantics - ANSWER Refers to meaning, concepts/vocabulary used across programming languages Syntax - ANSWER Programming language specific, like a grammar that a compiler can recognize Input - ANSWER The data or information passed into a computational system before a program is run e.g., input() Output - ANSWER The data or information passed out of a computational system once the computation is complete e.g., print() Execution - ANSWER The process by which a computer interprets our program or performs the instructions of our program Interactivity - ANSWER The ability of the code to detect events from a user,

e.g., mouse clicks, sensor-based information Identifier - ANSWER Name given to item in program letters and _ Value - ANSWER Value assigned to identifier Memory location - ANSWER Location where identifier and value are stored Variable - ANSWER Memory location with name and type to store value, A representation for a value. Value (2nd) - ANSWER e.g. 'flower' or 237 Identity - ANSWER Unique memory location id() Type - ANSWER Description of the information that guides how a programming language interprets the content Type() String - ANSWER A sequence of characters string() Integer - ANSWER Whole numbers Int() Float - ANSWER Floating point numbers float () Boolean - ANSWER Considered numeric type, value can be True or False

Add - ANSWER Operation that adds two operands

Subtract - ANSWER Operation that subtracts second operand from first

Multiply - ANSWER Operation that multiplies two operands

Divide - ANSWER Operation that divides first operand by second / Remainder - ANSWER Operation that computes remainder after a division % Floor division - ANSWER Operation that divides and round down to closest whole number // Exponential - ANSWER Operation that raises the previous operand to the power of the next operand ** Precedence - ANSWER Binding power of operator, e.g., multiplication evaluated before addition in a*b+c, can override with parentheticals () Compound operator - ANSWER Syntax to perform more than one operation at once, e.g., var += 2 is equivalent to var = var + 2

Incrementing - ANSWER Update value by a repeated positive factor, usually additive or multiplicative x = x + , +=, *= Decrementing - ANSWER Update value by a repeated negative factor x = x + , -=, /= Relational Operators - ANSWER Relational Operators Operation to compare values that has a true or false output -Less Than < -Greater Than > -Less Than or Equal To <= -Greater Than or Equal To >= -Equal to == -Not Equal To !=

Decision - ANSWER Any executable step in an algorithm that requires a "yes" or "no" (also "true" or "false") answer to a question.

e.g., if, else, elif

Branch - ANSWER Branching statements allow the flow of execution to jump

Escape sequence - ANSWER Tells interpreter to do something different than what a character normally means outside a string

', \

Raw string - ANSWER Take sequence of text as is; ignore escape sequences

Assignment operators - ANSWER Operation that assigns a value to a variable =, +=, -=

Boolean/Logical Operators - ANSWER - And *Returns true if both operands are true (and)

  • Or *Returns true if either is true (or)
  • Xor (xor)
  • Not (not)

Operator chaining - ANSWER "For example, a < b < c determines whether b is greater-than a but less-than c. Chaining performs comparisons left to right, evaluating a < b first. If the result is true, then b < c is evaluated next. If the result of the first comparison a < b is false, then there is no need to continue evaluating the rest of the expression. Note that a is not compared to c."

Flow chart - ANSWER Way of representing decision making in code

Psuedocode - ANSWER Way of communicating code logic with flexible syntax, generally follows special structure of code with indentations and carriage returns

Program memory - ANSWER Sometimes when we run our code, we use variables to store concepts occurring in this instatiation of running that code

e.g., player1_score, player2_

Programming errors - ANSWER System outputs that are intended to aid a programmer in debugging their code

Syntax errors - ANSWER Violate programming language rules

Logic errors - ANSWER Doesn't perform task correctly (aka. bugs)

Runtime errors - ANSWER Impossible operations; stops the program from running

For statement - ANSWER A for loop enables a particular set of conditions to be executed repeatedly until a condition is satisfied

for()

Iteration - ANSWER Each pass through a loop or repeated operation

Infinite loops - ANSWER If the loop's expression is always true, an infinite loop will be created in which code execution never ends

List - ANSWER Data structure used to store multiple items in a single variable; can contain items of different types

[ ]

Item - ANSWER Descriptor for one unit or one member of a group.

Array - ANSWER Data structure used to store multiple items in a single variable; items must have same types

numpy.array()

List - ANSWER Mutable data structure used to store multiple items in a single variable; can contain items of different types [ ]

Tuple - ANSWER Immutable data structure; can have multiple types ( ,)

Nested List - ANSWER List of lists, e.g., a 2D list could reference a row and a column e.g., tic_tac_toe[1][0]

Item/Element - ANSWER Descriptor for one unit or one member of a group.

Sequence - ANSWER Data structures store values in a particular order

Index - ANSWER Identifier(s) for where in a sequence to look for a value. Forward indices index at 0.

Reading to a list/array - ANSWER Pulling out the value from an array e.g., val = list1[2]

values from the function (outputs) after the execution of the code inside the function return

function definition (v. define) - ANSWER def Function_is_defined

defining does not call the function

function call (v. call) - ANSWER can call with self. call and add variables for the function to work

pass in parameters - ANSWER limits / gives variability to the function and makes it more abstract or general

Function interface - ANSWER The set of input and output parameters needed from or expected by a function.

  • an outside user does not necessarily need to know how function is implemented to use it, if they have a well-defined interface
  • purpose of function is often to transform inputs to unique outputs- this enables abstraction, as it gives variability to the function and makes it more general.

up to programmer, can be documented for other users or self

Function stubs - ANSWER Contain interfacing but not backend code; cannot have empty function body; acts as placeholder allowing us to test code as we write it e.g., def do_stuff() print "in do_stuff()"

Execution flow - ANSWER The order in which lines of code are executed, often designated by referring to lines of code, e.g., how some error messages might report syntax errors that block execution on line 57

Universal design - ANSWER Design and composition of an environment so that it can be accessed, understood and used to the greatest extent possible by all people regardless of their age, size, ability or disability.

e.g., deciding what the users of your code would benefit from and incorporating those ideas into your design, functions, and i/o with user.

More universal design - ANSWER - Equitable Use

  • Flexibility in Use
  • Simple and Intuitive Use

e.g., integers, floats, strings, tuples

Mutable objects - ANSWER -values can change-values do not share memory locations e.g., variables, lists, dictionaries

Namespace - ANSWER As a rule, names in a namespace cannot have more than one meaning; that is, different meanings cannot share the same name in the same namespace. For example: Each time you call a function, it creates a new function namespace that is deleted at the end of the function execution.

e.g. mainframe namespace vs. function namespace

String operations - ANSWER -concatenate -repetition -slicing -access all values

concatenate - ANSWER combine two strings into one

repetition - ANSWER repeats string multiple times

slicing - ANSWER subselect part of string, e.g., , returning index from positive index a to positive index b, also works for a list

[a:b]

access all values - ANSWER show all values, also works for list

e.g., newlist[:]=oldlist[:] [:]

Abstraction - ANSWER Through this process, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency.

Program front end/ Interface - ANSWER What a user sees ; their options for interfacing with program operations