Module 1 - the way of the program Flashcards

1
Q

What is a program?

A

A set of instructions that tells a computer what to do (follows to perform a task, it specifies how to perform a computation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Input

A

Data collected from input device (keyboard, network, file, hard drive)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Output

A

Data produced by the computer and displayed on an output device (screen, printer, save it in a file, send it over a network)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Conditional execution

A

Check for certain conditions and run appropriate code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What appears in almost every language?

A

Input/output, math, conditional execution, repetition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Python interpreter

A

A program that reads and executes python code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

First three lines of python interpreter

A

Python 3.4 = version number
Operating system
Prompt (“»>” which means interpreter is ready for you to enter code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to display “Hello World!” in python

A

Print(“Hello world!”)

This is called a print statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do parenthesis indicate?

A
Function
Print("Hello world") is a function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Arithmetic Operator

A

Special symbol in python that represents computations like addition and multiplication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s the arithmetic operator for exponentiation (exponents)?

A

**

So, 6**2 is 6^2 = 36

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does ^ mean in python?

A

Bitwise operator XOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a value?

A

Basic unit of data, like a letter or number, that a program manipulates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the different types of values?

A

Integer, floating-point number, and string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If you’re not sure what the type is, how can you find out?

A

Ask the interpreter!
»>type(2)

(If you put ‘2’ it will show up as string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Natural vs. formal languages

A
Natural languages (English, Spanish) evolved naturally and not designed by people
Formal languages (Python, Math) are designed by people for specific applications, they have syntax rules, they are unambiguous, literal, concise
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is syntax? What are the two types of syntax rules?

A

Set of coding rules; tokens and structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are tokens?

A

Basic elements of a language, such as words, numbers, and chemical elements
For example, 3+=3$6 doesn’t work because $ is not a legal token in math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are structure rules?

A

Pertains to the way tokens are combined

3+/3 is illegal in math because, although tokens are valid, you can’t have + and / next to each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Parsing

A

Figuring out the structure of a language

Separating a string of commands and analyzing for correct syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Programming errors are called ___. What is the process of finding and correcting them called?

A

Bugs, debugging

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Portability

A

Property of a program that allows it to run on more than one kind of computer

23
Q

Prompt

A

Characters displayed by the interpreter to indicate it is ready to take input from the user (»>)

24
Q

Microprocessor

A

CPU on a small chip

25
Q

Main Memory (RAM)

A

Random Access Memory
Volatile (temporary)
Contents are erased when the computer is off

26
Q

Secondary Storage (Hard drive)

A

Programs are stored here and loaded to main memory when needed
Examples include disk drive, hard drive, SSD (solid state drive - faster than disk drive), flash memory (portable)

27
Q

What are the two categories of software?

A

Application (programs used by end user) and System (control and manage basic operations of a computer = operating system, utility - to enhance computer operation, software development tools)

28
Q

How many bits in a byte?

A

8

29
Q

What are byte size limits?

A

0-255
0 = all bits off
255 = all bits on

*a byte is 8 bits, so if you have 11111111 and you convert to decimal system, you get 256 (1x2^7 + 1x2^6…)

30
Q

Why is RAM called that?

A

It is called Random, because the data stored in RAM can be accessed with the same amount of ‘Access’ time, regardless of the location.

This is as opposed to sequential memory like a tape, where items at the beginning of the tape are accessed faster than items at the middle of the tape, as we need to roll the tape to the middle to get the data stored there.

31
Q

A byte in memory is identified by a unique number called its _____.

A

Address

32
Q

The decimal equivalent of the binary numeral 10101 is ______. How to calculate?

A

(12^0) + ( 02^1) + (12^2) + (02^3) + (1*2^4) = 16+4+1 = 21

value* 2^(j-1) where j is the position

33
Q

The rules that govern the correct order and usage of the elements of a language are called the _____ of the language.

A

Syntax

34
Q

What is the difference between 2 and 1+1?

A

1+1 is called an expression. Anything that requires simplification is referred to as an expression, while 1 or 2, or “hello’ are referred to as literals. They can not be further simplified.

35
Q

How do you perform integer division (i.e., no remainder) in Python?

A
// 
for example, 7//2 will be 3
36
Q

Count to 10 in binary

A
0
1
10
11
100
101
110
111
1000
1001
1010

*even numbers always end in 0

37
Q

How to convert: decimal > binary? For example, 13

A
Divide by 2 and write down the remainder
13/2 = 6, R1
6/2 = 3, R0
3/2 = 1, R1
1/2 = 0, R1
Your last remainder is your first number
1101
38
Q

How to convert: binary > decimal? For example, 110

A
To convert 110 - Start w/ the last digit, 0: 
0 x 2^0 = 0 x 1 = 0
1 x 2^1 = 1 x 2 = 2
1 x 2^2 = 1 x 4 = 4
Add them up! = 6
39
Q

How is data stored in a computer? What is the format?

A

As a bit = binary digit! 0 or 1

Everything is converted to numeric code

40
Q

What is ASCII? (“ask-ee”)

A

American Standard Code for Information Interchange

Represents 128 English Characters as numbers; each letter is assigned a number 0-127 (for example capital m (“M”) is 77)

41
Q

What is unicode?

A

Compatible w/ ASCII - represents characters from other languages too

42
Q

Digital

A

Any device that stores data as binary numbers
For example, digital images are composed of pixels, each pixel is converted to binary number representing that pixel’s color

43
Q

What is program cycle for CPU?

A

Program copied from secondary memory to RAM:

  1. CPU fetches the instruction
  2. Decodes it to determine which operation to perform
  3. Executes the instruction
44
Q

Assembler, Compiler, Interpreter

A
  1. Assembler translates assembly language to machine language for execution by CPU
  2. Compiler translates one language to another (usually high-level language to machine language)
  3. Interpreter translates AND executes line by line - not an entire separate program
45
Q

Operators

A

Perform operations on data

For example, math operators perform arithmetic

46
Q

What are the two modes of Python?

A

Interactive (enter statements, limited, use to test functions) and Script Mode (save statements in python script)

47
Q

Literal

A

A value that cannot be simplified (“Hello world!”, 6, etc.)

48
Q

Statement vs. expression

A

A statement does something (e.g., print statement)
An expression evaluates to a value (e.g., 1+2)

A statement is a complete line of code that performs an action
An expression is any combination of variables, operations, and values that yields a result value

49
Q

Operation

A

Action involving an operator

50
Q

What is a script?

A

Can be executed without compiler

A script or scripting language is a computer language with a series of commands within a file that is capable of being executed without being compiled (ie translated to machine language)

51
Q

Compile

A

The process of creating an executable program from code written in a compiled programming language

Compiling allows the computer to run and understand the program without the need of the programming software used to create it

52
Q

Which of these will cause an error message in Python?

  1. print(“hello world)
  2. print (“hello world”
  3. 2++2
  4. 09
  5. 4 5
A

1, 2, 4, 5. These will return syntax error:
Leaving out parentheses or quotes (for strings) in print statement
Leading 0s, as in 09 or 011
Two values with no operator between them

53
Q

In a binary numbering system, what is the formula to determine value of digit j?

A

2^(j-1)