Section 2 Flashcards

(45 cards)

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

18
Q

Equal to

19
Q

less than

20
Q

less than equal to

21
Q

greater than

22
Q

greater than equal to

23
Selection
if and else statements
24
condition controlled iteration
While, endwhile
25
Iteration
A for end for loop is a definite count controlled loop
26
Data Structure: Array
A structure used to hold multiple Items of the same type e.g. day=["MON","TUES","WED"]
27
Two-Dimensional Arrays
Sales[58,56,43,67][etc,etc,etc][etc,etc,etc]
28
String manipulation: What does concatenating mean?
Joining together
29
String manipulation: Index
Starts at 0
30
String Manipulation: If student name = "Jumal" in terms of index what position is letter J?
studentName[0] = "J"
31
Substrings: how to isolate part of a string? e.g. productCode="GAR201834" Isolate into GAR2018
productType = productCode[0:3] year=productCode[3:7] print("productType=",productType) print("Year=",year) This will print: Product type=GAR Year=2018
32
How to find length of string?
len(mystring)=length of my strength It includes all characters and even spaces
33
Find first n characters of a string?
nChars= myString[0:n]
34
Subroutines
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
Advantages of subroutines
-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
How to generate a random number?
First off import random for any random operation Then random.randint(a,b) a,b = between two numbers
37
Robust and secure programming
Data validation techniques used to check validity of data the user has entered
38
Testing
ensure only input or execution of program works properly
39
Techniques for Robust and secure programming
-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
Techniques for Testing
-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
Selecting and using suitable test data: Normal Data
using examples of typical data that the program is designed to handle
42
Selecting and using suitable test data: Boundary data
which includes both ends of the allowed range as well as invalid data
43
Selecting and using suitable test data: Erroneous data
data of the wrong type e.g. non-numeric characters numeric field