Back to 课程

Computer Science GCES AQA

0% Complete
0/0 Steps
  1. Representing Algorithms Aqa
    4 主题
  2. Efficiency Of Algorithms Aqa
    1 主题
  3. Searching Algorithms Aqa
    3 主题
  4. Sorting Algorithms Aqa
    3 主题
  5. Data Types Aqa
    1 主题
  6. Programming Concepts Aqa
    5 主题
  7. Arithmetic Relational And Boolean Operations Aqa
    1 主题
  8. Data Structures Aqa
    3 主题
  9. String Manipulation Aqa
    1 主题
  10. Random Number Generation Aqa
    1 主题
  11. Structured Programming Aqa
    2 主题
  12. Robust And Secure Programming Aqa
    4 主题
  13. Number Bases Aqa
    2 主题
  14. Converting Between Number Bases Aqa
    3 主题
  15. Units Of Information Aqa
    9 主题
  16. Hardware And Software Aqa
    4 主题
  17. Boolean Logic Aqa
    3 主题
  18. Programming Languages And Translators Aqa
    2 主题
  19. Cpu Architecture Performance And Embedded Systems Aqa
    4 主题
  20. Memory Aqa
    2 主题
  21. Secondary Storage Aqa
    3 主题
  22. Fundamentals Of Computer Networks Aqa
    8 主题
  23. Fundamentals Of Cyber Security Aqa
    1 主题
  24. Methods Of Preventing Cyber Security Threats Aqa
    1 主题
  25. Relational Databases Aqa
    2 主题
  26. Ethical Legal And Environmental Impacts Aqa
    2 主题
课 Progress
0% Complete

Exam code:8525

What is a programming concept?

  • A programming concept, also known as a construct, determines the order in which lines of code are executed

  • They control the logic and behaviour of code

  • There are three core programming constructs:

    • Sequence

    • Selection

    • Iteration

Sequence

What is sequence?

  • Sequence refers to lines of code which are run one line at a time

  • The lines of code are run in the order that they written from the first line of code to the last line of code

  • Sequence is crucial to the flow of a program, any instructions out of sequence can lead to unexpected behaviour or errors

Example

  • A simple program to ask a user to input two numbers, number two is subtracted from number one and the result is outputted

Line

Python

01

print("Enter the first number")

02

Num1 = input()

03

print("Enter the second number")

04

Num2 = input()

05

Result = Num1 - Num2

06

print(Result)

  • A simple swap of line 01 and line 02 would lead to an unexpected behaviour, the user would be prompted to input information without knowing what they should enter

Selection

What is selection?

  • Selection is when the flow of a program is changed, depending on a set of conditions

  • The outcome of this condition will then determine which lines or block of code is run next

  • Selection is used for validation, calculation and making sense of a user’s choices

  • if… then… else… statements are used when you test conditions sequentially

if-else-if-else-statement-pseudocode-computer-science-revision-notes

Example

Concept

Pseudocode

Python

IF-THEN-ELSE

IF answer == "Yes" THEN

OUTPUT("Correct")

ELSE IF answer == "No" THEN

OUTPUT("Wrong")

ELSE

OUTPUT("Error")

ENDIF

if answer == "Yes":

print("Correct")

elif answer == "No":

print("Wrong")

else:

print("Error")

Nested Selection

What is nested selection?

  • Nested means to be ‘stored inside the other’

  • An example of nested selection is one IF statement inside of another

  • It is worth noting that iteration can be nested as well and this can be seen in the iteration revision note

Examples of nested selection

Prgm_Basic Programming Concepts

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注