Section 2 Flashcards

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

What is a variable?

A

Is used in programming to store data

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

What is a constant?

A

Is a variable that cannot be changed during the execution of the program

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

Data Type: String

A

zero or more characters in a quote mark

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

Data Type: Real/Float

A

Decimals

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

Data Type: Boolean

A

Only accepting true or false

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

What is camelCase and its advantages?

A

To separate words by making first letter of second word capitalized
Advantages are: Easier to remember Consistent

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

What is snake_case?

A

Where all words are in lowercase and are separated by an underscore
E.G. max-number-of-players
Could be used to name functions

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

What is PascalCase?

A

Each word separated by capitalizing the first letter of each word?

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

String conversion: int(input(

A

Allows integer to be an input or part of string

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

String conversion: float(input(

A

Allows decimal to be an input or part of string

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

String conversion: str

A

Just means string

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

To add

A

+

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

To subtract

A

-

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

To multiply

A

*

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

To divide

A

/

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

MOD(modulus)

A

%(finds the remainder)

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

DIV(quotient)

A

// finds the quotient (the number before the decimal point)

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

Exponentiation

A

^/** used to find the power

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

not equal to

A

!=

18
Q

Equal to

A

==

19
Q

less than

A

<

20
Q

less than equal to

A

<=

21
Q

greater than

A

>

22
Q

greater than equal to

A

> =

23
Q

Selection

A

if and else statements

24
Q

condition controlled iteration

A

While, endwhile

25
Q

Iteration

A

A for end for loop is a definite count controlled loop

26
Q

Data Structure: Array

A

A structure used to hold multiple Items of the same type
e.g. day=[“MON”,”TUES”,”WED”]

27
Q

Two-Dimensional Arrays

A

Sales[58,56,43,67][etc,etc,etc][etc,etc,etc]

28
Q

String manipulation: What does concatenating mean?

A

Joining together

29
Q

String manipulation: Index

A

Starts at 0

30
Q

String Manipulation: If student name = “Jumal”
in terms of index what position is letter J?

A

studentName[0] = “J”

31
Q

Substrings: how to isolate part of a string?
e.g. productCode=”GAR201834”
Isolate into GAR2018

A

productType = productCode[0:3]
year=productCode[3:7]
print(“productType=”,productType)
print(“Year=”,year)
This will print:
Product type=GAR
Year=2018

32
Q

How to find length of string?

A

len(mystring)=length of my strength
It includes all characters and even spaces

33
Q

Find first n characters of a string?

A

nChars= myString[0:n]

34
Q

Subroutines

A

Named block of code, separated from the main program
two types: functions and procedures

functions returns a value to a variable with a specified call

35
Q

Advantages of subroutines

A

-debugging and maintaining is easier as they are short code
-Subroutines can be easily tested to be correct separately
-particular subroutine can be called several times saved in a library and used in other programs

36
Q

How to generate a random number?

A

First off import random for any random operation
Then random.randint(a,b)
a,b = between two numbers

37
Q

Robust and secure programming

A

Data validation techniques used to check validity of data the user has entered

38
Q

Testing

A

ensure only input or execution of program works properly

39
Q

Techniques for Robust and secure programming

A

-Length Check: string entered must be greater or equal to minimum length
-Presence Check: string should not be empty
-Range Check: data must lie within given range
-Authentication: test if person is who they say to be e.g. fingerprint, facial recognition, password

40
Q

Techniques for Testing

A

-Syntax error: prevent program running because of spelling or grammar mistake
-Logic error: harder to spot.May run but may crash or give an incorrect or unexpected output

41
Q

Selecting and using suitable test data:
Normal Data

A

using examples of typical data that the program is designed to handle

42
Q

Selecting and using suitable test data:
Boundary data

A

which includes both ends of the allowed range as well as invalid data

43
Q

Selecting and using suitable test data:
Erroneous data

A

data of the wrong type e.g. non-numeric characters numeric field