Level 104 Level 106
Level 105

Object Orientated Practice


38 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
Python is a scripting language. What is a scripting language?
A scripting language is a particular type of programming language that allows for its programs, or scripts, to be interpreted by another high level program at runtime rather than being compiled by the CPU.
RAM, random access memory is volatile. What does this mean?
RAM is volatile, which means that once the power goes off the contents of RAM are lost.
Python and Java.
Give examples of two high level programming languages.
Assembly language and machine language.
Give examples of two low level programming languages.
Why must high level computing language programs be compiled or interpreted?
High level programming languages must be compiled or interpreted because CPUs can only run programs written in their own low level machine language.
What is the difference between a program that is interpreted and one that is compiled?
A compiled program is one which is completely translated from its source code to machine language using a specialized tool called the compiler which creates an executable file. A interpreted program is translated 'on-the-fly'. …
What is a variable and what rules in python govern how a variable is named?
Variables are names that refer to data in memory. Variable names, also known as identifiers in Python, may consist of upper and lower alphabetic characters, the underscore (_), and, except the first character, the di…
What is meant by the syntax of a computer language?
The syntax of a programming language is the set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.
What is an assignment statement? Give an example in python.
Assignment statements are used to give variables a value. The syntax of an assignment is
Give two examples of a python print statement, with and without quotation marks. How do they differ?
print('string') and print(8 + 2). Expressions inside quotation marks (either single or double) are printed literally, whereas expressions outside quotation marks have their value printed. print('string') will print string while print(8+2) will print 10.
from math import pi
Give an example of an import statement in python.
What are data types? Give three examples.
Data types are particular kinds of data items, as defined by the values they can take, the programming language used, or the operations that can be performed on them e.g. in Python strings which…
Give an example of an input expression in Python.
name = input('What is your name?') prints What is your name? and if the user inputs their name it is then stored as the variable name.
List six arithmetic operators used in Python and note what each does.
+ for addition, - for subtraction, ** for multiplication, / for division, // for integer division and *** for raising to a power.
What are the rules of operator precedence used in python?
Exponentiation is done first, then multiplication and division (left to right), and finally addition and subtraction (also left to right).
How are lines in a python program commented and what is the effect of commenting?
Lines in a python program are commented by beginning the comment with a hash sign (#) and anything that follows that is completely ignored by the interpreter.
What is a function in python and give an example?
Functions in Python is something that allows you to break a task down into appropriate sub-tasks e.g.
What is the difference between code that is outside all function calls and code that is within a function?
Code that is outside all function definitions is directly executed when the program is run while code within a function is only executed when the function is called.
What does the main() function do?
The main() function is known as the driver because it 'drives' the execution of the whole program and it is outiside all function definitions so it will be executed when the program is run.
The syntax of a function looks like this:
What is the syntax used to define a function? Give an example.
The syntax for a function call is <function>(<arguments>) e.g.
What is the syntax for calling a function? Give an example.
What syntax is used for a return expression and what does it do when executed inside a function?
return <expression>. When this is executed inside a function, it immediately terminates the function and returns the value of its <expression> as the value of the function call. If no expression is given, the v…
What is meant by the scope of a variable?
The scope of a variable is the part of the program in which the variable may be accessed.
What is a local variable and how does it differ from a global variable?
A local variable is one which is used for the first time inside of a function definition because its use is limited to within the definition of that function. A global variable is one w…
What scope do parameters in a function have?
The same scope as local variables i.e. they may not be accessed outside of the function definition.
A string.
What data type does the input() function return?
What is the difference between a float and an integer?
A float is a value that uses a decimal point while an integer is a whole number value.
They truncate towards zero giving 3 and -2 respectively.
What happens if the numbers 3.34456 and -2.765 are converted to integers?
List three basic principles of testing?
Test all important families of inputs
The for loop and the while loop.
Name two types of loop used in python.
for i in [1, 2, 3]:
Give an example of a for loop and its output.
range(stop) - Begin at 0. Take steps of size 1. End just before stop
The built in range() function can be called in three ways. What are they and give an example of each.
What is an accumulation loop? Give an example.
An accumulation loop is a loop where one of the variables, known as the accumulator, gradually accumulates some quantity as the loop runs. All accumulation loops look
Because sum is a built-in Python function.
Why can the word sum not be used as a variable name in an accumulation loop?
#Area of a Circle
Write a short program to calculate the area of a circle.
def hypot(x, y):
Write a short function to calculate the hypotenuse of a triangle.
def harmonic(n):
Write a short function using a loop to calculate a harmonic sum.
list(range(6,3,-1))?
list(range(5)) = [0, 1, 2, 3, 4]