返回卡包市场

2.2.1

暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。

卡片总数: 19内容版本: v4公开卡包更新时间: 8/1/2026

卡片预览 (19 张)

#1
正面 (问题)

sequence

背面 (解答)

Code is executed line-by-line, (one after the other) from top to bottom. Qty = input() Total = qty * price

#2
正面 (问题)

branching

背面 (解答)

• Branching (selection) Allows program to change directions depending on the outcome of a condition (Boolean expression). A certain block of code is run if a specific condition is met, using IF statements. If a > b Print(“A is bigger than b”)

#3
正面 (问题)

iteration

背面 (解答)

• Iteration (looping) A block of code is executed a certain number of times or while a condition is met. Iteration uses FOR, WHILE or REPEAT UNTIL loops. Iteration can be either: • Count-controlled Iteration is repeated a given number of times. for i in range (0,10): print i next i • Condition-controlled Iteration continues until a given condition is met. while i <= 20: print “Not true”; i=i+1 endwhile

#4
正面 (问题)

why while instead of for

背面 (解答)

becasue the user needs to keep enetring their password until its correct and a while loop will continue looping until the correct password is inputted. As well as this the number of attempts isnt known the program need sto carry on looping until the correct input is entered and a while loop will carry on looping until the correct input is eetered, a for loop will repeat only a certain number of times so it wouldnt work. As well as this the number of attempts isnt known

#5
正面 (问题)

recursion

背面 (解答)

Is when a subroutine (often a function) call itself from within its own subroutine. Recursive function characteristics: Contains a topping condition For any input value other than stopping condition, the subroutine should call itself(recursion). The stopping point should be reachable within a finite number of times. Without these, stack overflow can occur. Each time the function calls itself, a new stack frame is created within the call stack, where parameters, local variables and return addresses are stored. This information allows the subroutine to return to that particular point during its execution. A finite number of stack frames are created until the stopping condition, or base case, is reached at which point the subroutine unwinds.

#6
正面 (问题)

recursion adv and dis

背面 (解答)

The advantage of using recursion for certain problems is that they can be represented in fewer lines of code, which makes them less prone to errors. Inefficient use of memory. If the subroutine calls itself too many times, there is a danger of a stack overflow, which is when the call stack runs out of memory. This would cause the program to crash. Another problem with recursion is that it is difficult to trace, especially with more and more function calls.

#7
正面 (问题)

recursion vs iteration

背面 (解答)

卡片背面图片
#8
正面 (问题)

global

背面 (解答)

unnecessary use of global can make program hard to test, debug and maintain.

卡片背面图片
#9
正面 (问题)

local

背面 (解答)

卡片背面图片
#10
正面 (问题)

difference between local and global

背面 (解答)

卡片背面图片
#11
正面 (问题)

function

背面 (解答)

Is a block of zero that performs a specific task, taking in zero, one or more parameters and also returning a value.

#12
正面 (问题)

procedure

背面 (解答)

Is a block of code that performs a set task, taking in zero, one or more parameters.

#13
正面 (问题)

passing by reference

背面 (解答)

 Memory location of data is sent  Changes are made to the original data  Changes remain after the subprogram exits

#14
正面 (问题)

passing by value

背面 (解答)

 A local copy of the data is used  Data is discarded when the subprogram exits  Does not override/change the original data

#15
正面 (问题)

why by reference and not by value

背面 (解答)

ByRef changes the value in the variable passed. ByRef passes the address/location [1] ByVal only a copy of the data is passed [1] ByVal the change would be lost when the procedure ended [1]

#16
正面 (问题)

Compare the use of parameters to global variables in recursive functions.

背面 (解答)

Parameter allows a value to be sent to a sub-program  Global variables can be accessed throughout the scope of the program  Local variables can only be accessed within the scope of the sub-program it’s defined within – a parameter becomes a local variable in the function If global, equivalent of by reference -value would be over-ridden  Global variable takes more memory than a local variable  In recursion, each call produces a new local variable for num1  Global would require altering the algorithm as the value would be over-ridden on each call  Global would mean that memory space is kept throughout the running of the program, not just the sub-program  Parameter enables memory to be reallocated  Many more memory spaces needed for parameter

#17
正面 (问题)

IDE

背面 (解答)

Integrated Development Environment (IDE), is a program which provides a set of tools to make it easier for programmers to write, develop and debug code. Examples of IDEs include PyCharm, Eclipse, IDLE and Microsoft Visual Studio. Common features of IDEs include: • Stepping This allows you to monitor the effect of each individual line of code by executing a single line at a time. • Variable watch Sometimes used to pinpoint errors, this is a useful feature to observe how the contents of a variable change in real-time through the execution of a program. • Breakpoint IDEs allow users to set a point in the program at which the program will stop. This can either be based on a condition or set to occur at a specific line. This can help to pinpoint where an error is occurring. • Source code editor The editor aims to make the coding process easier by providing features such as autocompletion of words, indentation, syntax highlighting and automatic bracket completion. • Debugging tools Some IDEs also provide run-time detection of errors with a guide as to where in the code they are likely to have occurred through line numbers and highlighting.

#18
正面 (问题)

Iteration adv and dis

背面 (解答)

#19
正面 (问题)

Variable

背面 (解答)

Identifier of a memory location used to store data