Section 1 Chapter 1 - Programming Basics Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm

A

A sequence of steps that can be followed to complete a task and that always terminates

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

What is pseudocode

A

A tool for developing programs which is halfway between English and program statements. There are no concrete rules or syntax for how it is to be written

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

Integer

A

A whole number

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

Real / Float

A

A number with a fractional part

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

Boolean

A

A variable that can be either true or false

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

Character

A

A letter, number or special character typically represented with ASCII

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

String

A

A sequence of characters

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

Syntax to round n

A

round(n, decimalPlaces)

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

Syntax for exponentiation

A

a**b

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

Syntax for integer division

A

a div b

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

Syntax for modulo

A

a mod b

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

Syntax for finding length of string

A

len(string)

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

Syntax for getting the index of a substring in a string

A

string.find(substring)

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

Syntax for getting the integer (ASCII) value of a character

A

ord(char)

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

Syntax for getting the character represented by an integer

A

chr(integer)

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

Syntax for converting a string to an integer

A

int(string)

17
Q

Syntax for converting an integer to a string

A

str(integer)

18
Q

Syntax for converting a string to a float

A

float(string)

19
Q

Characteristics of the bullshit returned by date(year, month, day)

A

Is a number but also a date >:(

(Assumptions)
When made via the date function and then printed it is so in the format “year-month-day”

When two dates are subtracted from each other the result is an integer representing the number of days difference between them

20
Q

What actually are variables

A

Identifiers given to memory locations whose contents can change over the course of the program

21
Q

Constant

A

An identifier given to a memory location whose contents cannot change over the course of the program

22
Q

Advantage of using constants

A

In a lengthy program there is no chance that they can be accidentally changed

23
Q

Why meaningful variable names should be used

A

Makes the program easier to update and follow

24
Q

Data Type

A

The ‘type’ of a piece of data describes how it is meant to be handled and what operations are valid/invalid for it,

25
Q

Record

A

A collection of fields. A table is a collection of records.

26
Q

Declaration

A

A variable or constant must be declared before it can be used. When declaring a variable or constant you specify the identifier, the initial value and in some languages the data type.

27
Q

Assignment

A

Sets the value in a variable

28
Q

Difference between variable and constant

A

The value of a variable can be changed during runtime, whereas the value of a constant cannot be changed.

29
Q

Python syntax for current time

A

import datetime

datetime.datetime.now()

30
Q

Pointer

A

A reference to a location in memory