IT1X54 Programming Essentials Week 1

IT1X54 Programming Essentials Week 1

Assessment

Quiz

Created by

Bobby Liu

Professional Development

12th Grade

2 plays

Medium

Student preview

quiz-placeholder

6 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the following are considered input devices?

Keyboard

Mouse

Monitor

Touchscreen

Answer explanation

Input Devices collects data for the processing by the computer. The input device can be a keyboard, a mouse, a microphone or a touchscreen.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What handles arithmetic and logical operations in the CPU?

Control Unit

Registers

Arithmetic Logic Unit

Main Memory

Answer explanation

Control Unit: extracts instructions from memory and decodes and executes them

Arithmetic Logic Unit (ALU): handles arithmetic and logical operations

Registers are internal memory units that are used in the ALU's information processing.

Main Memory stores data and instruction in the computer. The computer can only manipulate data that is in main memory.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Are data stored in secondary storage devices wiped out after power supply is cut off?

No

Yes

Answer explanation

Secondary Storage stores data for a long period of time even if there is no power supply. Examples are hard disks and thumb drives.

4.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Which of the following are features of Python?

Light-weight

Dynamically typed

Object-oriented

Easily integrated with C/C++

REPL (Read-eval-print-loop)

Answer explanation

Light-weight: Lightweight programming languages have simple syntax so they could be learnt easily and quickly. They required small memory and is easy to implement.

Dynamically typed: A language is dynamically-typed if the type of a variable is checked during run-time. We will learn more about this in the later chapters. Besides Python, common examples includes JavaScript, PHP, and Ruby.

Object-oriented: Object-oriented programming languages use the concept of objects in programming. This is very close to how we view the real-world. For example, to record book information (such as isbn, author, and title), object-oriented programming creates book objects and store the information in each object. The aim is to bind together the data and the codes that operate on them so that no other part of the program can change the data.

Easily integrated with C/C++: As there are many systems implemented using C/C++, this is a important feature in Python.

REPL (Read–eval–print-loop): Python is an interpreted language and we can run simple Python expressions and statements in an interactive programming environment. After you installed Python, you can open a Python Shell by typing "Python" in the Windows search box. 

5.

MULTIPLE CHOICE QUESTION

1 min • 5 pts

What is a compiler and and an interpreter?

A compiler compiles codes into machine language before running while an interpreter runs the source code directly

A compiler runs the source code directly while an interpreter compiles codes into machine language before running

Answer explanation

A compiler is used to translate the high-level language programs to a machine language programs.

The interpreter reads each instructions, converts it to machine language instruction and immediately executes it.

6.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Which are the 3 type of errors you would find in programming?

Interpreter error

Syntax error

Semantic (logic) error

Runtime error

Compiler error

Answer explanation

Syntax errors are mistakes in the way that the code is written. Common syntax errors include spelling mistakes, incorrect use of punctuation and wrong indentation.

Example:

prin("Good Morning")

Runtime errors cause the program or computer to crash even if it appears to be nothing wrong with the program code. Running out of memory or wrong type conversion will often cause a runtime error.

Example:

x = int(input("Enter a number: "))

Enter a number : a

Traceback (most recent call last):

ValueError: invalid literal for int() with base 10: 'a'

The runtime error occurs at the line when the character ‘a’ is being converted to an integer.  Program crashes and exit immediately.

Semantic errors, or logic errors, happen when the program produces different results from what we have expected. Program with semantic errors will execute without any errors being reported.

Example:

x = int(input("Enter the first number : ")) y = int(input("Enter the second number : "))

print("The sum is", x*y)

Enter the first number : 3 Enter the second number : 5 The sum is 15

Semantic or logic error occurred when the output of the program is incorrect.