SDD Basics Flashcards

1
Q

Programs can be planned by using something called the IPO model.
What do the letters IPO stand for?

A

Input
Process
Output

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

What is “pseudocode” and what is its purpose in creating programs?

A

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

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

State the function that would replace the ? to display the message on the screen:

?(“Hello, World “)

A

print

Remember: Other functions that you have learned so far are input() and randint()

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

A ? is a random piece of code built into Python that does a specific action for you. An example would be print()

A

function
Remember: Other functions are input() and randint()

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

State the name of the function that is used to allow users to enter something while the program is running.

A

input()

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

Explain how to correct the error in this code:

age=input(int(“Enter your age.“)

A

There is a bracket missing. It should look like this:

age=input(int(“Enter your age.“))

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

State the name of the variable type used for keyboard characters.

A

string

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

State the type of variable used for whole numbers.

A

integer

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

State the type of variable that would be used to store decimal numbers.

A

float

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

What type of data would a Boolean variable store?

A

either true or false

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

Which type of variable should be used to store aveTemperature?

A

float

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

Explain why a float type would not be the best variable type to store numberOfCars.

A

You would only have whole numbers for cars; so integer would be the best type.
You would store 2.5 cars, for example.

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

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.

A

These lines declare variables AND set up their starting values.

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

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?

A

input

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

Which Python operator (mathematical symbol) should be used instead of the ? to multiply the variables should below.
a= 12
b= 3

print(a ? b)

A

*

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

What is the output from the following code?

x = 12
y = 3

print(x / y)

17
Q

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”

18
Q

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’’)

A

The variable for the licence is declared as licenceID, but when trying to get input, the Bob has mistyped the variable as licenseID.

19
Q

What symbol is used to comment a line in Python?

20
Q

What does ‘print()’ do in Python?

A

It outputs text or variables to the console.

21
Q

True or False: Indentation is important in Python.

22
Q

What data type is used to represent true or false values in Python?

23
Q

What is a conditional statement?

A

Code that helps the program select an action to take.

25
What is the purpose of a fixed loop in programming?
To repeat a block of code multiple times.
26
What keyword is used to create a loop to repeat a set number of times?
for
27
Fill in the blank: The _____ function is used to convert a string to an integer in Python.
int
28
Which of the following is an example of a conditional statement? a) if b) for c) while
a) if
29
A program is being written to tell the user to wear a coat if the temperature is at least 10 degrees C, but some of the code is missing in two places at ?. Complete the missing code: temperatureC=10 if temperature ? 0 : ?("Wear a coat.")
The example again was: temperatureC=10 if temperature ? 0 : ?("Wear a coat.") The answer is: temperatureC=10 if temperature > = 0 : print("Wear a coat.")
30
Customers of the Birthday Cafe get a free coffee if the month of their birth is selected by their app. The months are represented by numbers. Complete this line of code at ? to randomly select a month of birth. winningMonth=0 winningMonth=random.?(?,?)
The example again was: winningMonth=0 winningMonth=random.?(?,?) The answer is winningMonth=0 winningMonth=random.randint(1,12)
31
What keyword is used to create a fixed loop in Python?
for
32
True or False: A fixed loop in Python can run indefinitely.
False
33
Fill in the blank: The syntax for a fixed loop is 'for ___ in range(n):'.
variable name there - you probably selected i as this is what we usually use to refer to the loop counter
34
Which of the following is a correct way to start a fixed loop? a) while x < 10 b) for x in range(10) c) repeat x < 10
b) for x in range(10)