DPR 2 Mr Seisay Paper Flashcards

Memorise all

1
Q

Describe three commonly found features in an IDE that will help programmers to find any bugs in their code
(100% going to be in paper)
B: Helps you to stop at specfic points in the code…
S: Allows the programmer to observe each stage…
CD: Shows you the state of the program…

A

Breakpoints: Helps you to stop at specfic points in the code to see if their are any errors.

Stepping: Allows the programmer to observe the behavior of the code at each stage and identify where errors or unexpected behavior occurs.

Crash dump: Shows you the state of the program at the end of execution

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

Write a linear search in a list
1) Write a variable called num_list and put numbers in there, then create target and ask what number they are looking for
2) Set Index to 0, then under set found to false
3)Create a while loop which states that the len of num_list is bigger than index. Remember to Indent.
4) Create a if statement stating that num_list [index] is equal to target. Indent again. Then state the oppposite of 2. Break
5) Create else statement then set index to index plus one to find the number. Then print No item found

A

num_list=[1,4,11,20,66]
target=int(input(“What are you looking for))
Index=0
Found=False
While index<len (num_list):
if num_list[Index]== target:
print(“Found number”)
Found=True
break
else:
Index=Index + 1
print(“No item found)

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

Write a binary search in a sorted list.
1) Create a variable called sorted and make it equal to the numbers in a list.

2) Create another called target and make it equal to the question to the user

3) Set low to 0 and high to the len(sorted)

4) Create a while loop stating high is smaller or equal to high. Then indent. Calculate the mid point by adding them together within brackets and dividing it by 2

5) Create an if statement stating sorted[mid] is equal to target. Then indent. The print number found. The break

6) Create elif statement stating sorted[mid] is smaller than target. Then make low= mid +1

7) Lastly make else statement. Ident and make high = mid -1

A

Sorted= [1,4,11,20,66]
target=int(input(“What are you looking for)
low=0
high= len(sorted)
While low<= high:
mid= (low + high)/2
If sorted[mid] == target:
print (Number found”)
break
elif sorted [Mid] < target
low=mid + 1
else:
high = mid - 1

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