Programming Flashcards

(69 cards)

1
Q

MOD

A

Remainder of division

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

DIV

A

Answer without remainder

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

Subprogram

A

Large program broken down into smaller subprograms.
Focus on specific function
Help decompose complex programs

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

Return in subprograms

A

Send value (perhaps a variable only in the subprogram ) back to line where function was called on- so it can be used on the line
Ie: to be printed

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

Two types of subprogram

A

Function
Procedure

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

Function

A

Subprogram that returns a value (using return)

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

Procedure

A

Doesn’t return value

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

Advantage of using subprograms

A

Breaks down complex problems into smaller parts- easier to design and test
Each can be tested separately and use abstraction to simply the problem
Reuse the code, quicker to develop other programs
Avoids code repetition, shorter programs (which are easier to develop and maintain and debug)
Split work between different programmers to work on different subprograms at a time.

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

Array

A

Static data structure, hold fixed number of same data type elements
Python does not use array (uses lists)

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

How is an element in an array accessed?

A

Using it’s index (location number)
Usually starts at 0

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

Static data structure

A

Fixed number of elements (cannot be resized)
Elements can change

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

Dynamic data structure

A

Memory efficient and not fixed capacity
Number of data items is only constrained by overall memory allocated to program

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

How to transverse an array?

A

Transverse (‘move through’)
Use for loop
For I in Array:
Print (I)

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

How to add a value to an array?

A

Cannot change amount of elements, change value of already existing element

Array[3] = “change”
Remember the 3 is the 4th value

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

How to delete a value from an array?

A

Fixed size so cannot delete value but overwrite as blank

Array[2] = “ “
The 2 is the 3rd value

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

How to search for value in an array?

A

Use for loop and see if equal to item
For value in Array:
If value == “change”
Print(value)

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

What is a two dimensional array

A

Same data type but multiple rows and columns

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

How to measure in two dimensional array?

A

Row first, then column
Row (down), column (across)

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

How to search two dimensional array?

A

Print(Array[3][5])
Prints 5th column on 3rd row
x,y,z,a,(3,5)
That’s the 3rd row, 5th column

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

Record

A

Store data of different types which are made of information of one person or thing
Each piece of information in the record is a field

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

Field (record)

A

A row name (piece of info)

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

What is a key field (records)?

A

Unique data that indentifies each record

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

How to present records and fields/database tables?

A

2D array

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

SQL

A

Structured query language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is SQL used for?
Used to search for data in a database
26
Format of SQL
Select (field/ wildcard (all)) From (table- usually given) Where (criteria, truth/boolean)
27
Wildcards
* -presents all fields
28
Name all data types
Integer Float (real) Boolean Character String Null (nothing)
29
What is the code for all data types?
Integer= int Float(real)= float Boolean= bool Character= char String= str
30
What is an integer?
Whole numbers (positive and negative)
31
What is a real/float?
Numbers including decimal places
32
What is a Boolean?
Based on logic, True or False (only two options) bool(1) #itll be True bool(0) #itll be False
33
What is a character?
Single letter, number, symbol
34
What is a string?
Represents text (collection of characters)
35
What is casting?
Converting one data type into another
36
Using ASC and CHR (psuedocode)
ASC converts the character into its ASCII number CHR converts ASCII number into its character
37
What is sequence?
Order in which instructions occur and are processed
38
What is selection?
A block of code is executed depending on whether a condition is true or false
39
Example of selection statement:
If statements Switch statements (unsupported in python)
40
What is iteration?
Repeating a section/ block of code until a certain condition is met (or a number of times)
41
What is a condition-controlled iteration?
ie: indefinite iteration Block of code is repeated based on a condition that is evaluated
42
Example of condition-controlled iteration:
While loops Do while Repeat until
43
Difference between Do-until and Do-while
Do-until= execute block of code, stops once condition is true Do-while= executes block of code as long as the condition is true (break by condition being false)
44
How does Do-until loop work?
Controlled by condition at the end of the loop Code always runs at least once!!
45
How does a while loop work?
Controlled by condition at the start of the loop The code may never be run (if condition is false)
46
What is a count-controlled iteration?
ie: definite iteration Group of instructions is repeated a specific amount of times
47
Examples of count-controlled iteration:
For loops
48
What would be printed in: for count in range(1,6) print(count)
1 2 3 4 5
49
What would be printed in: for i in range(3, 31, 3) print(i)
3 6 9 12 15 18 21 24 27 30 (Prints all 3 time tables from 3 to 30)
50
Sign for exponentiation
** (To the power of ie: 2**3 = 8)
51
//
DIV Division without the remainder
52
%
MOD (modulo) Only reminder of a division
53
How to use ‘NOT’ in an if statement?
If NOT score == “2”:
54
If you wanted to print 006290 would it be str or int?
Str(“006290”) As an int, the 0 in the front would be dropped
55
How to find length of string?
len() ie: Password = input (“ Enter: “) LengthOfPassword = len (Password)
56
How to make a string with a length of 0?
String = “” (No spaces, a space is a character)
57
How to make whole string uppercase?
Uppercase = (string).upper()
58
How to make whole string lowercase?
Lowercase = (string).lower()
59
Can a variable name start with a letter?
Yes
60
Can a variable name start with a number?
No
61
Is the variable ‘hello’ the same as ‘Hello’?
No, they’re case-sensitive
62
How to convert ASCII code into letter (code)?
chr(code)
63
How to convert letter into ASCII code (code)?
ord(“ “)
64
What is concatenation?
Joining of string
65
How to code string concatenation?
Print( “hello” + name )
66
How to code concatenation with other data types?
Print ( “You have ” + str(newMessages) + “ new messages”) Or Print (f “You have {newMessages} new messages”)
67
How to append to list?
List.append(“add this”)
68
How to insert an item into a specific integer of a list?
List.insert(2,”insert this”) #this will insert into the 3rd position because it starts at 0
69
How to loop 5 times?
for i in range(5): #will only go 5 times