7.1 Programming Fundamentals Flashcards

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

What is a data type

A

Values than be used in a data item

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

Give some data types

A

Integer, float/real, character, string, Boolean

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

Integer

A

Whole numebers

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

Typical amount of memory for integer

A

2 bytes

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

Float/real

A

Number with a fraction part (1.3, 20.0)

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

Typical amount of memory for float/real

A

4 bytes

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

Char

A

A single ASCII char such as A, b, !, 3 and Space

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

Typical amount of memory for a char

A

1 byte

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

String

A

0 or more chars

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

Typical amount of memory for string

A

1 byte per char in string

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

Boolean

A

True or False

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

Typical amount of memory for a boolean

A

Theoretically 1 bit, but in high level languages often 1 byte

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

Difference between variables and constants

A

Variables can be changed while running and constants can only be changed before the program is run.

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

Input Statement

A

A way to gather inputted information from the user via the CLI (Command Line Interface)

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

Give some arithmetic operators

A

+, -, *, /, DIV, MOD

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

DIV

A

Used for integer division (quotient)

17
Q

MOD

A

Modulus is used to find the remainder when dividing one integer by another

18
Q

What rules do arithmetic operations follow?

A

BIDMAS (Brackets, indices, division, multiplication, addition, subtraction)

19
Q

What is the difference between the way the integer 17 is stored and the string “17” is stored?

A

17 is stored as binary 17, whereas the string “17” is stored as the string of “1” and then the string of “7”

20
Q

Casting

A

Functions to change the datatype of one variable to another

21
Q

Examples of casting functions

A
  • int()
  • float()
  • str()
  • bool()
  • ASC()
  • CHR()
  • b()
22
Q

What is string concatenation?

A

The operation of joining and manipulating the data held in strings

23
Q

What will “6” +”3” add to?

A

63 (because they are strings which means they are concatenated together)

24
Q

Give some string handling functions (written in python)

A
len(string)
string[x:]
string[:x]
string.upper()
string.lower()
25
Q

Why should you use comments?

A
  • To describe the purpose of the program
  • To state the author of the program
  • To explain what the code does
    (Comments are ignored when your program is translated to machine code and executed)