Вы находитесь на странице: 1из 6

Candidate name: ..................................................

Centre number: ..................................................

Index number: ..................................................

Programming language used: .....................................................................

Question 1
Evidence 1
Program code

Evidence 2
Program code

Evidence 3
The sort algorithm used was :……………………………

Program code

Evidence 4
Screenshot

Evidence 5
Screenshot

Question 2
Evidence 6
Program code
def Converter(denNum):
if denNum==0 or denNum==1:
print(denNum)
else:
remainder= denNum%2
print(remainder, end='')
quotient= denNum//2
Converter(quotient)

def main():
denNum= int(input('Enter denary number: '))
print('Binary Number:', end=' ')
Converter(denNum)

main()
Screenshot
Evidence 7
Error in line : print(remainder, end='')
The binary number is printed in the reverse order

Evidence 8
Amended Program Code
def Converter(denNum, binDigits):
if denNum==0 or denNum==1:
binDigits.append(denNum)
else:
remainder= denNum%2
binDigits.append(remainder)
quotient= denNum//2
Converter(quotient, binDigits)
return binDigits

def main():
denNum= int(input('Enter denary number: '))
print('Binary Number:', end=' ')
binDigits=[]
binDigits= Converter(denNum, binDigits)
for i in range(len(binDigits)-1,-1,-1):
print(binDigits[i], end='')

main()

DenaryNumber Purpose of the test Expected


Output
56 Valid denary value that will loop through the whole 111000
converter function.

To check if the converter function works and will


print out the correctly ordered binary number.

1 Valid boundary denary value that will only pass 1


through the if statement of the converter function.

To check if the converter function will exit after


first condition, denNum==1 is met.

0 Valid boundary denary value that will only pass 0


through the if statement of the converter function.
To check if the converter function will exit after
first condition, denNum==0 is met.

Screenshot 1

Screenshot 2

Question 3
Evidence 9
Program code
def LicenseKey():
# generate random letters
import random
key= '' #licenese key
lenKey= 10
total=0 #total of random letters
for i in range(lenKey-1):
#add letter to license key
value= random.randint(ord('A'), ord('Z'))
ch=(chr(value)).upper()
key+=ch

#add to total
total+= value* (i+1)

# generate check digit


checkDig= total%11

if checkDig==10:
key+='X'
else:
key+=str(checkDig)

return key

def main():
for i in range(3):
print('New license key', i+1, ':', end=' ')
key=LicenseKey()
print(key)

main()

Screenshots X 3
Evidence 10
Program code

Screenshots X 2

Evidence 11
Program code

Screenshots X 3

Evidence 12
Program code
Question 4
Evidence 13
Test Number User ID Return value Explanation of the test case

1 2015_0987 0 Valid User ID

2 2015_897 1 The User ID was not 9 characters

The last 4 characters of User ID of format


3 2015_A112 2 2015_NNNN contained characters other than
digits

The first 5 characters of User ID format


4 2014-0234 3
2015_NNNN is not 2015_

Evidence 14
Program code
def ValidateUserID(ThisUserID):
lenUserID= 9
if len(ThisUserID)!= lenUserID:
return 1
elif not ThisUserID[5:].isdigit():
return 2
elif ThisUserID[:5]!= '2015_':
return 3
else:
return 0

Screenshots X 3
Test 2:

Test 3:

Test 4:

Evidence 15
Program code

Evidence 16
Program code

Evidence 17
Program code X 2

Evidence 18
Program code

Screenshot

Evidence 19
Program code

Screenshot

Stuff to note:

For binary number: add in the reverse order – binary= num+ binary

Hash table: 4 cases- 1. Access element= empty, exit 2. Access element= item, found 3. (Access
element is fill but not item)

def Search(item):

if hashTable[add]== '':

endSearch =True

elif hashTable[add]== item:

found=True

else: #hashTable[add] filled

if add=len(hashTable):

add=0

else:

add+=1

if add==initaladd:

endSearch= True

else:

continue seaching

Вам также может понравиться