401 exam Flashcards

(28 cards)

1
Q

What are the four stages of SDLC?

A
  1. Requirement analysis: to analyse a given scenario, and work out what are the requirements of this programme
  2. Design: to outline the blueprint of the programme, including all functionalities, according to the requirements gathered.
  3. Implementation: to implement the design into source code using a programming language to reflect the design. * Your computer needs to be told what to do step by step.
  4. Testing: to test the source code to verify that it has met the requirements and reflects the design, and it can execute without errors.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the fifth stage of SDLC ?

A

Maintenance: to discover and repair software defects (aka bugs), and to roll out software updates (aka patches) to the clients’ environments.

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

Two different models of SDLC. What are they?

A

Waterfall Model:
Step-by-step process. Finish one stage before starting the next.
Agile Model:
Work in small parts (sprints). Keep improving and changing as you go.

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

What are advantages and disadvantages of Waterfall and agile model?

A

Waterfall Model
Advantages:
-Simple and easy to understand.
-Good for small projects with clear requirements.
Disadvantages:
-Hard to go back to a previous phase.
-Not flexible for changes during development.

Agile Model
Advantages:
-Flexible and adaptable to changes.
-Continuous user feedback.
Disadvantages:
-Requires close collaboration.
-Can be hard to predict time and cost early on.

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

What are the 3 properties of an IDE. What can IDE not do.

A

Three properties of an IDE:
1.Code editor – Helps write code with color and auto-complete.
2.Debugger – Finds and fixes errors step by step.
3.Build tools – Compiles and runs the program.

What an IDE cannot do:
- Write your code for you.
- Fix logic errors in your program.
- Replace testing.

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

Using a labelled diagram briefly explain what a flowchart is. Advantages and disadvantages.

A

[Start]
|
[Input]
|
[Process]
|
[Decision]–Yes–>[Action A]
|
No

[Action B]
|
[End]
Advantages:
-Easy to understand.
-Visual representation of logic.
Disadvantages:
-Can get complex.
-Not suitable for large systems.

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

Using a labelled diagram briefly explain what a pseudocode is. Advantages and disadvantages.

A

Start
Input number
If number > 0
Print “Positive”
Else
Print “Negative”
End

Advantages:
Easy to understand
Good for planning code
No need to know exact syntax

Disadvantages:
Not real code (can’t run)
Different people may write it differently
Needs to be turned into real code later

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

What is casting?

A

Casting is converting a variable from one data type to another.
Ex:
x = int(“5”) # cast string to integer

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

Using a labelled diagram briefly explain what a variable is.

A

[Variable Name: age]
|

[Memory Location] → Value: 25
VARIABLE – named storage location

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

List the rules for naming variables.

A

*Must begin with a letter or underscore.
*Cannot contain spaces or special characters.
*Cannot be a reserved keyword.
*Should be meaningful.
*Case-sensitive (Age ≠ age).

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

Arithmetic operators

A

+ (Addition),
- (Subtraction),
* (Multiplication),
/ (Division),
% (Modulus),
** or ^ (Exponentiation)
// Floor Division

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

Three types of selection?

A

(Unary)Simple selection: if condition
(Binary)Two-way selection: if…else
(Ternary)multi-way selection: if…elif…else

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

List the comparison operators

A

== (Equal to),
! = (Not equal to),
> (Greater than),
< (Less than),
>= (Greater than or equal to),
<= (Less than or equal to), === (Strict equal

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

Labelled diagram for (Unary)Simple selection: if condition

A

Uses only one condition to decide if a block should run.

[Condition]
↓ Yes
[Execute this block]

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

Labelled diagram for (Binary)Two-way selection: if…else

A

Chooses between two paths: if the condition is true or false.

[Condition]
↓ Yes ↓ No
[Do A] [Do B]

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

Labelled diagram for (Ternary) multi-way selection: if…elif…else

A

Chooses from many options based on several conditions.

[Condition 1] → Yes → [Do A]
↓ No
[Condition 2] → Yes → [Do B]
↓ No


[Else] → [Do Default]

17
Q

What are the two main types of iteration

A

(while loop)Conditional Iteration: A loop that keeps running as long as a condition is true. It stops when the condition becomes false.

(for loop)Count Iteration: A loop that runs a set number of times, no matter what.

18
Q

With examples, briefly explain three simple data types

A

Integer (int): This data type represents whole numbers (positive, negative, or zero).
Example: 5, -3, 0

Boolean: boolean is a type of data that can only have two values:
True (yes, it is)
False (no, it isn’t)

Float: This data type represents numbers with decimal points (floating-point numbers).
Example: 3.14, -0.5, 2.0

19
Q

With an example briefly explain what a string is and how it is not the same as a simple data type

A

A string is a sequence of characters enclosed in quotes (single ‘ ‘ or double “ “)
Example of a string: “Hello, World!”, “12345”, “Python is fun!”

Strings represent textual data, while simple data types like integers and floats are used for numeric values.
Example: “123” (string) versus 123 (integer).

20
Q

Using a small piece of code, briefly explain the syntax of a function and how a function works

A

def greet():
print(“Hello!”)

def starts the function.
greet is the function name.
() is where inputs (parameters) go, if needed.
: starts the function body.
print(“Hello!”) runs when the function is called.

How it works:
You call the function like this: greet()
It will print: Hello!

21
Q

Using an example, briefly explain what concatenation is.

A

Concatenation means joining two or more strings together.
Example:
word1 = “Python”
word2 = “code”
sentence = word1 + “ “ + word2 # Combines the strings with a space
print(sentence)
# Output: Python code

22
Q

Write a piece of code to convert the keyboard entry to be converted to an int

A

user_input = input(“Enter a number: “)
number = int(user_input)
print(“You entered:”, number)

Explanation:
input() gets text from the keyboard.
int() converts the text to an integer.
print() shows the number.

23
Q

Using a piece of code briefly explain what is meant string slicing

A

String slicing is a way to get a part (a “slice”) of a string using its index positions.

text = “Python”
slice = text[1:4]
print(slice)
Output
yth

24
Q

What a function is?

A

Named reusable block of code

25
Write a syntactically correct program to for a function and a function call?
Define the function def say_hello(): print("Hello, welcome!") Call the function say_hello()
26
Briefly explain black box and white box testing:
Black box testing means testing the program without looking at the code. You just check if it gives the right output for the input. White box testing means testing the program by looking at the code. You check if each part of the code works correctly.
27
During black box testing if the user prompt is 'Please enter your age: ' three data items you would use to test the program and why?
1. **Negative number (-5):** To check if the program can tell that ages can't be negative. 2. **Normal age (25):** To make sure it works correctly when you enter a valid age. 3. **Wrong input ("abc"):** To see if the program can stop you from typing letters instead of a number.
28
Why are functions used ?
To reuse code easily. To organize code into smaller parts. To make programs easier to read and fix.