0% found this document useful (0 votes)
133 views3 pages

Worksheet 4

Uploaded by

arushi.agupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views3 pages

Worksheet 4

Uploaded by

arushi.agupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Worksheet 4

Translators and facilities of languages


Unit 8 Logic and languages

Name:...................................................................................................... Class: ......................

Task 1
1. Insert the following languages into the correct column in the table:
Java, VB, Assembly code, Python, C++, machine code, C#, PHP

High-level language Low-level language

Java Assembly code

VB machine code

Python

C++,

C#

PHP

2. Write True or False beside each of these statements:

True or False?
A programming language which has
1. statements resembling English or Maths is T
classified as a high-level language
A high-level language is closer than a low-
2. level language to the machine code that the F
computer can execute
Assembly code does not have to be
3. translated into machine code before it can be T
executed
An interpreter is a program that translates a
4. F
high level language into machine code
A compiler is a program that translates a high
5. T
level language into machine code
There are different assembly languages for
6. T
different processor types
There are different high-level languages for
7. T
different processor types

1
Worksheet 4
Translators and facilities of languages
Unit 8 Logic and languages

3. Write True or False beside each of these statements:

Disadvantages of low-level code True or False?


An assembly program written for one type of
1. processor will not work on a different type of T
processor
Programs written in assembly will usually
2. execute faster than those written in a high- T
level language
Low level languages cannot control individual
components in embedded systems such as
3. F
those found in washing machines or mobile
phones
Machine code produced from assembly
4. language will occupy more memory than the F
machine code from a high level language
Assembly language is harder to learn than a
5. T
high level language

Task 2
The Python code below contains a syntax error and a logic error.

1 # Program to perform a bubble sort


2
3 userName = ["Carl","Tamsin","Eric","Zoe","Alan","Mark"]
4 print("list of unsorted names: ", userName)
5 #numItems is the length of the list
6
7 while numItems > 1:
8 for count in range(5):
9 if userName[count][1] > userName[count + 1][1]:
10 temp = userName[count]
11 userName[count] = userName[count + 1]
12 userName[count + 1] = temp
13 prnt("count = ",count, "userName[count] = ",
userName[count], "userName[count+1] ="
,userName[count+1])
14 numItems = numItems – 1
15 print(userName)

(a) There is a syntax error in line 15. What is the error?


Print(userName)

2
Worksheet 4
Translators and facilities of languages
Unit 8 Logic and languages

(b) Python programs are interpreted.


What, if anything will be printed when the program is run?
An error or whatever commands state to print things

(c) If you have Python installed on your computer, try out the code and see if you are right.

(d) If numItems = 6 is now inserted at line 6, what will happen when the program is run?
nothing
(e) When this error is fixed, does the program give the correct result? If not, correct it.

You might also like