Computer science programming section Flashcards

Learn the programming section of computer science

1
Q

What is the data type int?

A

Whole numbers only.

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

What is the data type float?

A

Numbers that have a decimal part.

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

What is the data type boolean?

A

Can only take 2 values usually true or false.

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

What is the data type char?

A

A single letter, number, symbol.

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

What is the data type string?

A

Used to represent text, is a collection of characters.

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

What is each data types allocated memory?

A
  1. int: 2 or 4 bytes
  2. float: 4 or 8 bytes
  3. boolean: 1 byte
  4. string: 1 byte for every character of string.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the mathematical operation for addition, subtraction and multiplication?

A
  1. Addition: +
  2. Subtraction: -
  3. Multiplication: *
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the mathematical operation for division, exponentiation (to the power of ), quotient and remainder?

A
  1. division: /
  2. exponentiation: **
  3. Quotient: DIV
  4. Remainder: MOD or %
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the assignment operator?

A

The assignment operator is used to assign values to constants or variables.

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

What are the comparison operators?

A

== : is equal to
!= : is not equal to
< : less than
> : more than
<= : less than or equal to
>= : more than or equal to.

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

Give the function of all string manipulator functions.

A

x.upper : changes all characters in string to upper case
x.lower : changes all characters to lowercase
x.length : returns the number of characters in a string.
x.left : extracts the first character from a string
x.right : extracts the last character from a string
x.substring(a,b) : extracts a string starting at position a with length b.

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

What do IF statements do?

A

IF statements allow you to check if a condition is true or false and carry out different actions on the outcome.

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

What are switch statements used for?

A

Used to check if a variable has specific values.

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

What are the drawback of switch statements?

A

They can only check the value of one variable.
IF statements can check if multiple conditions are true.

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

What are the advantages of switch statements compared to IF statements.

A

The advantage is they have a similar structure to IF statements but they give a neater way to test different values of a variable this makes them easier to maintain.

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