pre for exam Flashcards

1
Q
  1. An algorithm is:
    a. always written in a programming language like Python.
    b. the best method for calculating a value.
    c. the only correct answer to a puzzle or problem.
    d. a set of instructions to be followed to solve a problem.
    e. a mathematical formula used in programming.
A

d

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

y = “Is sunday”

what is y called in python language

A

variable

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

addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ), floor division ( // ), modulus ( % ), and exponentiation ( ** ).

what are this things called in python language?

A

numerical operators

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

Why it is necessary to use the eval() ?
a. To read in an integer from the user.
b. To read in a string number from the user.
c. To allow x to store the numeric representation of the number entered by the user.
d. To evaluate the number in it’s string representation.
e. Because input does not work without eval().

x = eval(input(“Enter a whole number:”))
y = x % 2

A

c

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

print(“2016”,”01”,”02” , sep =(“_”))

A

2016-01-02

sep function separates where there are commas….

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

What are the purposes of the break , continue statements?

A

Break exits immediately from a loop [1]
Continue immediately starts the next iteration of the loop [

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

What is the difference between primary and secondary storage? Give an example of each.

A

Primary storage: data not lost when PC switched off [1]
e.g. RAM [1]
Secondary storage: data accessible only when PC on [1]
e.g. HDD

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

Name two ways to convert a program from a high level language (e.g. Python) to machine
language. Give the differences (if any) between these two ways.

A

Compilation and interpretation [2]
Compilation: a program that translates a program one-shot .
Only reads the source code once. [1]
Interpretation: a program that analyses and executes
instruction by instruction as necessary. Need it every time
the program is to be run [1].

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

give types of errors

A
  1. compile - time error
    2 . Run time error=(Program structure is correct, but does not execute as expected like dividing by zero)
    3.synthax error
    4.logical error(e.g product = x+y)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

If you can create your test cases based on only the problem
specification

A

black box

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

Charles Babbage is famous for his design of:
a. The Vaucanson duck
b. The difference and analytical engines
c. The Python programming language
d. The integrated circuit

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. The Von Neumann Architecture:
    a. is important for compilers, but not interpreters.
    b. is used for low-level languages, but not high-level languages.
    c. is the method of designing an algorithm to solve a particular problem
    d. is a description of how a conceptual computing device works.
A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. An algorithm is:
    a. always written in unambiguous pseudocode.
    b. the best method for calculating a value.
    c. the only correct answer to a puzzle or problem.
    d. a set of instructions to be followed to solve a problem.
    e. all of the above
A

D

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

An interpreter is:
a. a high level language
b. needed every time a program is run
c. one-shot translation
d. very fast
e.C and D

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. On a computer, secondary storage is :
    a. volatile
    b. read-only
    c. modifiable
    d. the ‘brain’ of the computer
    e. C and D
A

c

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

In the context of computer programming, what is an object?
a. A data type that combines data and code.
b. A variable that once set cannot be changed.
c. A form of infinite loop.
d. A type of syntax error in Wing101.
e. Another name for an elif clause.

A

A

17
Q

The following is an example of a Glass Box
testing method:
a) Equivalence Classes
b) Path Coverage Testing
c) Random Testing
d) Exhaustive Testing
e) None of the above

A

b

18
Q

. What do we call the values inside the
brackets of a function?
a. The function definition
b. The function name
c. The return value
d. Parameters
e. The function invocation

A

d

19
Q

The CPU follows which process?
a. The instruction cycle
b. The process paradigm
c. The execute paradigm
d. The fetch-execute cycle
e. The compute cycle

A

d

20
Q
A