401 exam Flashcards
(28 cards)
What are the four stages of SDLC?
- Requirement analysis: to analyse a given scenario, and work out what are the requirements of this programme
- Design: to outline the blueprint of the programme, including all functionalities, according to the requirements gathered.
- 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.
- Testing: to test the source code to verify that it has met the requirements and reflects the design, and it can execute without errors.
What is the fifth stage of SDLC ?
Maintenance: to discover and repair software defects (aka bugs), and to roll out software updates (aka patches) to the clients’ environments.
Two different models of SDLC. What are they?
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.
What are advantages and disadvantages of Waterfall and agile model?
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.
What are the 3 properties of an IDE. What can IDE not do.
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.
Using a labelled diagram briefly explain what a flowchart is. Advantages and disadvantages.
[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.
Using a labelled diagram briefly explain what a pseudocode is. Advantages and disadvantages.
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
What is casting?
Casting is converting a variable from one data type to another.
Ex:
x = int(“5”) # cast string to integer
Using a labelled diagram briefly explain what a variable is.
[Variable Name: age]
|
↓
[Memory Location] → Value: 25
VARIABLE – named storage location
List the rules for naming variables.
*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).
Arithmetic operators
+ (Addition),
- (Subtraction),
* (Multiplication),
/ (Division),
% (Modulus),
** or ^ (Exponentiation)
// Floor Division
Three types of selection?
(Unary)Simple selection: if condition
(Binary)Two-way selection: if…else
(Ternary)multi-way selection: if…elif…else
List the comparison operators
== (Equal to),
! = (Not equal to),
> (Greater than),
< (Less than),
>= (Greater than or equal to),
<= (Less than or equal to), === (Strict equal
Labelled diagram for (Unary)Simple selection: if condition
Uses only one condition to decide if a block should run.
[Condition]
↓ Yes
[Execute this block]
Labelled diagram for (Binary)Two-way selection: if…else
Chooses between two paths: if the condition is true or false.
[Condition]
↓ Yes ↓ No
[Do A] [Do B]
Labelled diagram for (Ternary) multi-way selection: if…elif…else
Chooses from many options based on several conditions.
[Condition 1] → Yes → [Do A]
↓ No
[Condition 2] → Yes → [Do B]
↓ No
…
↓
[Else] → [Do Default]
What are the two main types of iteration
(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.
With examples, briefly explain three simple data types
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
With an example briefly explain what a string is and how it is not the same as a simple data type
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).
Using a small piece of code, briefly explain the syntax of a function and how a function works
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!
Using an example, briefly explain what concatenation is.
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
Write a piece of code to convert the keyboard entry to be converted to an int
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.
Using a piece of code briefly explain what is meant string slicing
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
What a function is?
Named reusable block of code