VARIABLES, DATA TYPES and CONSTANTS Flashcards

1
Q

What does Variable do?

A

They hold values

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

Int -

A

Whole number such as 156, 0, -54

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

Float/Real

A

Float

Number with a fractional part such as 1.5276, -68.4, 20.0

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

Char or Character

A

A single ASCII character

str

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

String

A

str

zero or more characters

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

Boolean

A

bool

Can only take the values true or false

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

Why declare a constant

A

Prevents the code accidently being changed by a part of code

It shows a programmer that the value that the value should stay the same throughout the program.

Constants are typically shown in uppercase

Words are separated with an underscore, e.g. MIN_AGE

This is known as snake case

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

A CONSTANT CAN NEVER CHANGE ITS VALUE

A CONSTANT CAN BE CHANGED BY A PROGRAMMER BEFORE THE PROGRAM IS COMPILED OR TRANSLATED.

A

A CONSTANT CAN NEVER CHANGE ITS VALUE

A CONSTANT CAN BE CHANGED BY A PROGRAMMER BEFORE THE PROGRAM IS COMPILED OR TRANSLATED.

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

31 // 7

A

how many times it goes in

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

31 % 7

A

the remainder

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