1/58
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Input
A program gets data, perhaps from a file, keyboard, touchscreen, network, etc
Process
A program performs computations on that data, such as adding two values like x + y.
Output
A program puts that data somewhere, such as to a file, screen, or network.
algorithm
A sequence of instructions that solves a problem
interactive interpreter
a program that allows the user to execute one line of code at a time
Code
common word for the textual representation of a program
line
a row of text
prompt
What the interactive interpreter displays that indicates the interpreter is ready to accept code
statement
a program instruction. (A program mostly consists of a series of statements, and each statement usually appears on its own line)
Expressions
are code that return a value when evaluated;
for example, the code wage hours weeks is an expression that computes a number.
The symbol * is used for multiplication.
The names wage, hours, weeks, and salary are variables, which are named references to values stored by the interpreter.
print()
) function displays variables or expression values
comments
# denote comments, which are optional but can be used to explain portions of code to a human reader.
variables
store values for later use
string literal
Text enclosed in quotes
Ex:print('hello world')
end=' '
Each call to print() outputs on a new line. However, sometimes a programmer may want to keep output on the same line. A programmer can add end=' ' inside of print() to keep the output of a subsequent print statement on the same line separated by a single space. Ex: print('Hello', end=' ').
Value of variable
The value of a variable can be printed out without quotes
Ex:print(variable_name)
newline character
Output can be moved to the next line by printing "\n"
Ex: print('1\n2\n3') prints "1" on the first line, "2" on the second line, and "3" on the third line of output.
whitespace
Any space, tab, or newline
input()
Reading input is achieved using the input() function. The statement best_friend = input() will read text entered by the user and the best_friend variable is assigned with the entered text. The function input() causes the interpreter to wait until the user has entered some text and has pushed the return key.
string
represents a sequence of characters.
For example, the string 'Hello' consists of the characters 'H', 'e', 'l', 'l', and 'o'.
type
srings and integers are each an exampleof a type. a type determines how a value can behave.
ex: integers can be divided by 2, but not strings (what sense would "Hello" / 2 make?)
int()
used to indicate an integer
A programmer can combine input() and int() to read in a string from the user and then convert that string to an integer for use in a calculation.
Example: num1 = int(input()) num2 = int(input()) print(num1 + num2)
syntax error
is to violate a programming language's rules on how symbols can be combined to create a program.
An example is putting multiple prints on the same line.
runtime error
a program's syntax is correct but the program attempts an impossible operation
Ex: dividing by zero or multiplying strings together (like 'Hello' * 'ABC').
A runtime error halts the execution of the program
crash
Abrupt and unintended termination of a program
IndentationError
The lines of the program are not properly indented.
ValueError
An invalid value is used - can occur if giving letters to int().
NameError
The program tries to use a variable that does not exist.
TypeError
An operation uses incorrect types - can occur if adding an integer to a string.
logic error
Some errors may be subtle enough to silently misbehave, instead of causing a runtime error and a crash,called logic error because the program is logically flawed
bug
a logic error
integrated development environment, or IDE
what Code development is usually done with
Switches
controls whether or not electricity flows through a wire
An electronically controlled switch, a positive voltage at the control input allows electricity to flow, while a zero voltage prevents the flow.
Such switches were useful, for example, in routing telephone calls.
Engineers soon realized they could use electronically controlled switches to perform simple calculations.
The engineers treated a positive voltage as a "1" and a zero voltage as a "0". 0s and 1s are known as bits (binary digits).
They built connections of switches, known as circuits, to perform calculations such as multiplying two numbers.
bits (binary digits)
The engineers treated a positive voltage as a "1" and a zero voltage as a "0". 0s and 1s are known as bits
circuits
They built connections of switches, known as circuits, to perform calculations such as multiplying two numbers.
processors
circuits called processors were created to process (aka execute) a list of desired calculations, each calculation called an instruction
memory
is a circuit that can store 0s and 1s in each of a series of thousands of addressed locations, like a series of addressed mailboxes that each can store an envelope (the 0s and 1s). Instructions operate on data, which is also stored in memory locations as 0s and 1s.
program, application, or just app
programmer-created sequence of instructions
machine instructions
Instructions represented as 0s and 1s
executable program
a sequence of machine instructions together
assemblers / (assembly language)
0s and 1s are hard to comprehend, programmers soon created programs called assemblers to automatically translate human readable instructions, such as "Mul 97, #9, 98", known as assembly language instructions, into machine instructions. The assembler program thus helped programmers write more complex programs.
high-level languages
in the 1960s and 1970s, programmers created high-level languages to support programming using formulas or algorithms, so a programmer could write a formula like F = (9 /5 ) * C + 32. Early high-level languages included FORTRAN (for "Formula Translator") or ALGOL (for "Algorithmic Language"), which were more closely related to how humans thought than were machine or assembly instructions.
compilers
are programs that automatically translate high-level language programs into executable programs
Input/output devices: A screen and keyboard
screen (or monitor) displays items to a user
the keyboard allows a user to provide input to the computer, typically accompanied by a mouse for graphical displays.
disk
stores files and other data
Disks are non-volatile, meaning they maintain their contents even when powered off. They do so by orienting magnetic particles in a 0 or 1 position.
RAM(random-access memory)
temporarily holds data read from storage and is designed such that any address can be accessed much faster than disk, in just a few clock ticks (see below) rather than hundreds of ticks. The "random access" term comes from being able to access any memory location quickly and in arbitrary order, without having to spin a disk to get a proper location under a head. RAM is volatile, losing its contents when powered off
byte
a byte is 8 bits (Memory size is typically listed in bits, or in bytes where )
Processor
runs the computer's programs, reading and executing instructions from memory, performing operations, and reading/writing data from/to memory.
BIOS (basic input/output system)
When powered on, the processor starts executing the program whose first instruction is (typically) at memory location 0.
It sets up the computer's basic peripherals.
OS). operating system
allows a user to run other programs and interfaces with the many other peripherals. Processors are also called CPUs (central processing unit) or microprocessors
cache
Because speed is so important, a processor may contain a small amount of RAM on its own chip, called cache memory, accessible in one clock tick rather than several, for maintaining a copy of the most-used instructions/data.
clock
A processor's instructions execute at a rate governed by the processor's clock, which ticks at a specific frequency.
Examples of clock tik rates : 1 MHz (1 million ticks/second) for an inexpensive processor ($1) like those found in a microwave oven or washing machine, to 1 GHz (1 billion ticks/second) for costlier ($10-$100) processors like those found in mobile phones and desktop computers.
transistors
smaller switches
integrated circuit or IC
a single chip which is the computer
Moore's Law
The doubling of IC capacity roughly every 18 months,
scripting languages
programmers began creating scripting languages to execute programs without the need for compilation.
script
is a program whose instructions are executed by another program called an interpreter
open-source language
meaning the community of users participate in defining the language and creating new interpreters, and is supported by a large community of programmers