Programming Fundamentals Flashcards

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

What is a data type?

A

The kind of values that can be used in a data item

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

What are some examples of 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

What are arithmetic operators?

A

A symbol that will perform an operation on numbers

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

What are the arithmetic operators?

A

+, -, *, /, ^, MOD, DIV

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

What is ^

A

Exponent (power of)

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

What data type is the variable ‘numberOfStudents’

A

Integer

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

What data type is the variable ‘circleArea’

A

Real/Floating point number

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

What data type is the variable ‘found’

A

Boolean

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

What data type is the variable ‘answer’

A

Character

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

What data type is the variable ‘studentName’

A

String

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

What type of data is a char

A

A single ASCII character such as A, b, 3, ! or space

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

What type of data is a string

A

Zero or more characters

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

What can you define other than variables

A

Constants

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

What are some examples of constants

A

const PI = 3.14157926535
const VAT = 0.2
const MAX_PLAYERS = 6

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

What is snake case

A

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

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

Why declare a constant instead of a variable?

A

This prevents the value from being changed accidentally by a part of code
It shows a programmer that the value should stay the same throughout the program

17
Q

Can a constant ever change its value?

A

A constant cannot be changed when the program is running
A constant can be changed by a programmer before the program is compiled or translated

18
Q

What is DIV used for

A

Integer division, also known as quotient
e.g. 31 DIV 7 = 4 (remainder 3)

19
Q

What is MOD (modulus) used for

A

Used to find the remainder when dividing one integer by another
e.g. 31 MOD 7 = 3 (remainder)

19
Q

What is MOD (modulus) used for

A

Used to find the remainder when dividing one integer by another
e.g. 31 MOD 7 = 3 (remainder)

20
Q

What is represented differently in binary

A

Strings and numbers

21
Q

What is the string “17” represented in binary as

A

0011000100110111

22
Q

What is the integer 17 held in binary as

A

00010001

23
Q

What are functions/casting

A

They are used to convert data types

24
Q

What does the function int(s) do (written in pseudocode)

A

converts a string s to an integer

25
Q

What does the function float(s)/real(s) do (written in pseudocode)

A

converts a string s to a number with a decimal point

26
Q

What does the function str(x) do (written in pseudocode)

A

converts an integer or floating point number x to a string

27
Q

What does the function bool(s) do (written in pseudocode)

A

converts a string (e.g. “True”) to a Boolean

28
Q

What does the function ASC(‘a’) do (written in pseudocode)

A

evaluates to 97, using ASCII

29
Q

What does the function CHR(97) do (written in pseudocode)

A

evaluates to ‘a’

30
Q

What is wrong with the variable tickets = input(“Please enter number of tickets required: “)

A

You need to convert the variable to an integer, as the inputs from the user are strings e.g. tickets = int(tickets) or tickets = int(input(“Please enter number of tickets required: “))

31
Q

What is concatenating

A

Means joining together strings
e.g.
firstname = “Rose”
surname = “Chan”
fullname = firstname + “ “ + surname
print(fullname)
output = Rose Chan (not part of code)

x = “6” + “3”
print(x)
output = “63” (not part of code)

32
Q

Examples of string handling functions

A

word = “Algorithm”

print(word.length) = 9
print(word.substring(3,6)) = “orit”
print(word.left(3)) = “Alg”
print(word.right(4)) = “ithm”

zooName = “London Zoo”

zooName.length = 10
zooName.substring(1,4) = ondo
zooName.left = London Z
zooName.right(5) = n Zoo

33
Q

How can characters be converted to their ASCII value and vice versa?

A

Using the functions: ASC(character) and CHR(integer)
e.g.
x = ASC(‘a’) // sets x = 97
y = CHR(97) // sets y to ‘a’

34
Q

How can I convert a string to uppercase or lowercase?

A

phrase1 = “Good morning”
phrase2 = “HAPPY BIRTHDAY”
print(phrase1.upper) //”GOOD MORNING”
print(phrase2.lower) //”happy birthday”

35
Q

Why should I use comments in my programs?

A

to describe the purpose of the program
to state the author of the program
to explain what the code does

36
Q

How do comments start in different languages?

A

Pseudocode - //
Python - #
Visual Basic - ‘