Core Elements of Programs Flashcards Preview

6.00.1x > Core Elements of Programs > Flashcards

Flashcards in Core Elements of Programs Deck (45)
Loading flashcards...
1

What are the types of programming language?

Compiled (High level language)
Instructions are converted to low level ahead of time

Interpreted (Low level language)
Instructions are processed on the fly at the basic level of the computer

Interpreted (High Level language)
Instructions are processed on the fly at a high level which enables more abstract computation

2

What is a program?

A program/script is a sequence of definitions and commands. It manipulates data objects.
Definitions are evaluated.
Commands are are executed by the shell.

3

What is a shell?

Provides access to operating system services.

4

What is a command?

A command/statement instructs the interpreter to do something.

5

What are the types of data objects?

Scalar: int (5, 47)
float (4.7, 3.14)
bool (True, False)
NoneType

Non-scalar:

6

What is an expression?

Composed of operators and data objects.

7

What arithmetic operators are used on ints and floats?

i+j - Sum
i-j - Difference
i*j - Multiplication
i/j - Division
i//j - Division (int)
i%j - Remainder
i**j - Power

8

What comparison operators are used on ints and floats?

i>j - Greater than
i>=j - Greater than or equal to
i

9

What logic operators are used on bools?

a and b - True if both are True
a or b - True if either are True
not a - True if a is False, False if a is True

10

What are type conversions?

float(3) = 3.0
int(3.4) = 3

11

How do you bind values to variables and names?

=

12

What is operator overloading?

Using the same operator to achieve different things based on the type of object.

Depending on the type of the object, number or string the operator will decide what the right operation is to do.

13

What is string indexing vs slicing?

Indexing selects an individual letter from a string of characters

Slicing selects a portion of a string

14

How do you index an individual character from a string?

'abc'[2] >>> 'c'

15

How do you slice a set of characters from a string?

'Python'[1:5] >>> 'ytho'

'Python'[0:0:2] >>> 'Pto'

16

How do you denote a comment in a script?

#

17

How do you prompt for user input?

name = raw_input('Enter your name:')

18

What are the syntax for nested conditionals?

if - checks a specific value
elif - checks a specific value if not already found
else - default if no criteria are met

19

How do you get the remainder from numbers?

%

20

How do you print a calculation externally without the value being used for computation?

print(

i.e: print(5+3)

21

What are the arguments for string slicing?

'string'[start:stop:step]

22

When changing the value of an object that is bound to a value what is important to consider?

Changing that value will not effect any other objects that previously used the object

23

When using strings why use " or '?

"is used if the string contain's an apostrophe"

24

What is the syntax for a while loop?

while

25

What does a += b stand for?

a = a + b

26

What does a -= b stand for?

a = a - b

27

What does a*= b stand for?

a = a * b

28

What does a /= b stand for?

a = a / b

29

What is the equivalent to a = a + b?

a += b

30

What is the equivalent to a = a - b?

a -= b