Section 1: Programming basics Flashcards

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

Algorithm and Pseudocode:

  • Algorithm; a __ of r___ or seq______ of ___ specifying ___ to s____ a _______.
  • Pseudocode; a halfway house between _______ and pr________ sta_______, used for the dev__________ of more co__________ programs.
A

Algorithm and Pseudocode:

  • Algorithm; a set of rules or sequence of steps specifying how to solve a problem.
  • Pseudocode; a halfway house between English and programming statements, used for the development of more complicated programs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Comments:

  • uses the symbol (), so any _____ with the symbol () will be tr______ as a ______.
  • _______ will have __ eff_____ on the _______.
  • used to do______ the code and ex_____ any _____ ____ of the code.
A

Comments:

  • uses the symbol (#), so any text with the symbol (#) will be treated as a comment.
  • comments will have no effect on the program.
  • used to document the code and explain any tricky parts of the code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Data type::

  • Integer; a _____ number can be po______ or ne______.
  • Real/float; a number with a de______, can be po_____ and ne______.
  • Boolean; a va_______ that can only take ____ or ____.
  • Character; a le_____ or nu_____, typically rep________ in _____.
  • String; anything en_______ in qu_____ ______ is a string.
A

Data type::

  • Integer; a whole number can be positive or negative.
  • Real/float; a number with a decimal, can be positive and negative.
  • Boolean; a variable that can only take TRUE or FALSE.
  • Character; a letter or number, typically represented in ASCII.
  • String; anything enclosed in quote marks is a string.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Arithmetic Operation:

  • the symbols (_, _, _, _) are com______ ar_________ operations.
  • Round function; [ r____(va______, ) ], used to r_____ any given va______ by ‘’ de______ places.
  • truncate function; r_____ a ___ nu_____ do_____ to is ______ number.
  • Exponentiation; to find the _____ of a nu____ to a po______ use [ _ = ** ].
  • Integer division; [ __ ], used to f____ the wh____ nu_____ of a division.
  • Remainder; [ _ ], used to f___ the re_______ in a division.
A

Arithmetic Operation:

  • the symbols (+, -, /, *) are common arithmetic operations.
  • Round function; [ round(variable, x) ], used to round any given variable by ‘x’ decimal places.
  • truncate function; rounds a real number down to is whole number.
  • Exponentiation; to find the value of a number to a power use [ x = y**n ].
  • Integer division; [ // ], used to find the whole number of a division.
  • Remainder; [ % ], used to find the remainder in a division.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

String-handling operation:

  • [ len(string) ], re_____ the le_____ of a ______.
  • [ string.substring(index1, index2) ], re_____ a por___ of _____ inclusive of the cha______ at each i_____ pos______.
  • [ string.find(str) ], det_______ if ‘str’ ______ in the _____, re_____ the index of the f___ cha______ or a __ if not found.
  • [ ord(‘a’) ], re_____ the in_____ value of a cha_____.
  • [ chr(97) ], re_____ the cha______ represented by an in____.
  • concatenate; to j__ two ____ using ‘_’.
A

String-handling operation:

  • [ len(string) ], returns the length of a string.
  • [ string.substring(index1, index2) ], returns a portion of string inclusive of the characters at each index position.
  • [ string.find(str) ], determines if ‘str’ occurs in the string, returns the index of the first character or a -1 if not found.
  • [ ord(‘a’) ], returns the integer value of a character.
  • [ chr(97) ], returns the character represented by an integer.
  • concatenate; to join two string using ‘+’.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

string conversion:

  • [ int(‘1’) ], con______ the cha_______ ‘1’ to the in______ 1.
  • [ str(123) ], con_______ the in______ to a st_____.
  • [ float(‘123.123) , con_______ the st______ to a r__ nu______.
  • [ date(year, month, day) ], re_____ a nu_____ that can be cal______ with.
A

string conversion:

  • [ int(‘1’) ], converts the character ‘1’ to the integer 1.
  • [ str(123) ], converts the integer to a string.
  • [ float(‘123.123) , converts the string to a real number.
  • [ date(year, month, day) ], returns a number that can be calculated with.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Constant and Variables:

  • Variables; this are ide______ given to a me______ location whose co_____ may _____ while _____ the program.
  • Constant; are ide_____ whose v_____ never _____ while _____ the program.
  • adv; no ____ that a pr_______ will _____ its value, makes it ____ rea_____.
A

Constant and Variables:

  • Variables; this are identifiers given to a memory location whose content may change while running the program.
  • Constant; are identifiers whose value never change while running the program.
  • adv; no chance that a programmer will change its value, makes it more readable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Program Constructs:

  • Sequence; __ or ____ sta_______ foll_______ one after the other.
  • Selection; sta______ are used to se_____ which sta______ will be exe______ next, dep_____ on some con______.
  • Iteration; sta_______ that per______ a ____ in the program, Ind______ where the _____ con______ until a co______ is met (while loops), de_____ where the nu_____ of ______ it ______ is _______ (for loops).
A

Program Constructs:

  • Sequence; two or more statements following one after the other.
  • Selection; statements are used to select which statement will be executed next., depending on some condition.
  • Iteration; statements that performs a loop in the program, Indefinite where the iteration continues until a condition is met (while loops), definite where the number of times it loops is defined (for loops).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Arrays:

  • 1-dimensional array; An ____ is defined as a fi____ ord_____ set of el______ of the ____ t_____. An array starts from 0.
  • 2-dimensional array; can be vis______ as t____, an el_____ can be ______ using [ array[x][y] ].
A

Arrays:

  • 1-dimensional array; An array is defined as a finite ordered set of elements of the same type. An array starts from 0.
  • 2-dimensional array; can be visualised as tables, an element can be called using [ array[x][y] ].
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Subroutines:

  • a na____ bl____ of _____ which per_____ a sp______ task.
  • Function; a named block of code that pr_____ an _____.
  • Procedures; a named block of code that ___ ___ pr_____ an _____.
  • parameters; this are va_____ that are ______ to other sub_______, by ____, ch_____ in the sub_____ to the par______ will __ affect its ____ outside it. by _______, the add______ of the par_______ is passed so any ch_______ to it will _______ on the _____ of the pr_______.
A

Subroutines:

  • a named block of code which performs a specific task.
  • Function; a named block of code that produces an output.
  • Procedures; a named block of code that does not produce an output.
  • parameters; this are variables that are passed to other subroutines, by value, changes in the subroutine to the parameter will not affect its value outside it. by reference, the address of the parameter is passed so any changes to it will reflect on rest of the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Subroutines:

  • global variables; va______ used in the ___ pro______ can be used __ wh_____ in the pro____.
  • local variables; are va_____ that can o___ be ____ within the sub______.
  • modular programming; a __-____ approached in which the pro_____ is br______ _____ into a ______ of sub______.
A

Subroutines:

  • global variables; variables used in the main program can be used any where in the program.
  • local variables; are variables that can only be used within the subroutine.
  • modular programming; a top-down approached in which the program is broken down into a number of subroutines.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Advantages of subroutines:

  • can be ea____ de____ and ma_____ as it can be ea___ und_____.
  • can be te_____ ind________, _________ the dev______ time.
  • it can be re_______ in other pro______.
A

Advantages of subroutines:

  • can be easily debug and maintain as it can be easily understood.
  • can be testes independently, shortening the developing time.
  • it can be reused in other programs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Files and exception handling:

  • a file con_____ of a nu______ of records con______ a nu_____ of fields.
  • eg. file = Student register, Records = specific information like class or name, fields = the data in each record.
A

Files and exception handling:

  • a file consists of a number of records containing a number of fields.
  • eg. file = Student register, Records = specific information like class or name, fields = the data in each record.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

File handling:

  • [ with open(file, w or r or a) as x: ], this will _____ the file with the ____ ‘file’ and it will either let you wr____ to that file ‘w’, only re____ the file ‘r’ or ap_____ it ‘a’.
  • [ x.write or read or append(variable) ], used to ma______ what data is _______ to the file or read from it.
A

File handling:

  • [ with open(file, w or r or a) as x: ], this will open the file with the name ‘file’ and it will either let you write to that file ‘w’, only read the file ‘r’ or append it ‘a’.
  • [ x.write or read or append(variable) ], used to manipulate what data is inputed tot he file or read from it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Exception handling:
- pr______ str______ that will pr______ an output when an ____ occurs, allowing for the pr______ to con_______ without _______.

A

Exception handling:
- programs statements that will produce an output when an error occurs, allowing for the program to continue without crashing.

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