pre for exam Flashcards
- 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.
d
y = “Is sunday”
what is y called in python language
variable
addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ), floor division ( // ), modulus ( % ), and exponentiation ( ** ).
what are this things called in python language?
numerical operators
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
c
print(“2016”,”01”,”02” , sep =(“_”))
2016-01-02
sep function separates where there are commas….
What are the purposes of the break , continue statements?
Break exits immediately from a loop [1]
Continue immediately starts the next iteration of the loop [
What is the difference between primary and secondary storage? Give an example of each.
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
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.
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].
give types of errors
- 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)
If you can create your test cases based on only the problem
specification
black box
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
B
- 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.
D
- 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
D
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
B
- On a computer, secondary storage is :
a. volatile
b. read-only
c. modifiable
d. the ‘brain’ of the computer
e. C and D
c