SDD Basics Flashcards
Programs can be planned by using something called the IPO model.
What do the letters IPO stand for?
Input
Process
Output
What is “pseudocode” and what is its purpose in creating programs?
Pseudocode is a simple plan of a program that uses simple language and steps.
If you were asked to write a program to calculate the area of a rectangle, you might write pseudocode something like this, but there are other ways you could write it. What is key is that you include all inputs (variable names), processing (this is calculations, if statements, loops) and outputs:
RECEIVE height FROM KEYBOARD
RECEIVE width FROM KEYBOARD
area = height * width
SEND area TO DISPLAY
State the function that would replace the ? to display the message on the screen:
?(“Hello, World “)
Remember: Other functions that you have learned so far are input() and randint()
A ? is a random piece of code built into Python that does a specific action for you. An example would be print()
function
Remember: Other functions are input() and randint()
State the name of the function that is used to allow users to enter something while the program is running.
input()
Explain how to correct the error in this code:
age=input(int(“Enter your age.“)
There is a bracket missing. It should look like this:
age=input(int(“Enter your age.“))
State the name of the variable type used for keyboard characters.
string
State the type of variable used for whole numbers.
integer
State the type of variable that would be used to store decimal numbers.
float
What type of data would a Boolean variable store?
either true or false
Which type of variable should be used to store aveTemperature?
float
Explain why a float type would not be the best variable type to store numberOfCars.
You would only have whole numbers for cars; so integer would be the best type.
You would store 2.5 cars, for example.
A Python program often starts with lines of code like these:
width=0.0
height=0.0
area=0.0
Explain what these lines of code do.
These lines declare variables AND set up their starting values.
A program calculates the area of a room. Here is a little sample of the start of it:
width=0.0
height=0.0
area=0.0
width= float( ?? (‘‘Enter the width of the room’’))
What should go in the ?? so that the user can type in the width?
input
Which Python operator (mathematical symbol) should be used instead of the ? to multiply the variables should below.
a= 12
b= 3
print(a ? b)
*
What is the output from the following code?
x = 12
y = 3
print(x / y)
4
People need to be at least 17 to drive in the UK.
What operator (mathematical symbol or symbols) should replace the ? in the pseudocode below:
IF age ? 17 THEN “You can drive”
age >=17
This code doesn’t work and an error message is displayed when Bob tried to run the code. Explain the error.
age=0
licenceID=’’ ‘’
age=input(int(“Enter your age.“)
licenseID=input(‘‘Enter your license ID’’)
The variable for the licence is declared as licenceID, but when trying to get input, the Bob has mistyped the variable as licenseID.
What symbol is used to comment a line in Python?
#
What does ‘print()’ do in Python?
It outputs text or variables to the console.
True or False: Indentation is important in Python.
True
What data type is used to represent true or false values in Python?
Boolean
What is a conditional statement?
Code that helps the program select an action to take.