Saturday , October 5 2024

Python Essentials 1 – Module 1 Test Answers

Python Essentials 1 – Module 1 Test Answers

Python Essentials 1 Module 1 Completion – Module Test Quiz Answers

1. What is machine code?

  • A low-level programming language consisting of binary digits/bits that the computer reads and understands
  • A high-level programming language consisting of instruction lists that humans can read and understand
  • A medium-level programming language consisting of the assembly code designed for the computer processor
  • A low-level programming language consisting of hexadecimal digits that make up high-level language instructions
Explanation: Machine code is a program written in machine language, which consists of sequences of digital binary numbers: 0s and 1s.

2. What are the four fundamental elements that make a language?

  • An alphabet, a lexis, a syntax, and semantics
  • An alphabet, phonetics, phonology, and semantics
  • An alphabet, a lexis, phonetics, and semantics
  • An alphabet, morphology, phonetics, and semantics
Explanation: Each language, be it machine language or natural language, consists of an alphabet, a lexis, a syntax, and semantics.

3. What do you call a file containing a program written in a high-level programming language?

  • A source file
  • A machine file
  • A target file
  • A code file
Explanation: A source file is a file that contains source code, that is, a program’s instructions.

4. What is true about compilation? (Select two answers)

  • It tends to be faster than interpretation
  • It tends to be slower than interpretation
  • Both you and the end user must have the compiler to run your code
  • The code is converted directly into machine code executable by the processor
Explanation: The compiler translates (compiles) the source program (a set of high-level language instructions) into machine code (a lower-level representation of the source program). The sequence of 0s and 1s can be then executed by the processor. The execution of the compiled code is usually faster than interpretation.

5. What is the best definition of a script?

  • It’s a text file that contains sequences of zeroes and ones
  • It’s a text file that contains instructions which make up a Python program
  • It’s an error message generated by the compiler
  • It’s an error message generated by the interpreter
Explanation: A script is a set of high-level language commands in a file, structured to be executed like a program. A Python script is therefore a file containing code written in Python.

6. Select the true statements. (Select two answers)

  • Python is free, open-source, and multiplatform
  • Python 3 is backwards compatible with Python 2
  • Python is a good choice for low-level programming, e.g., when you want to implement an effective driver
  • Python is a good choice for creating and executing tests for applications
Explanation: Python is a free and open-source programming language available to everyone. It is a multi- and cross-platform language, which means a Python program written on a Linux system will run on a Mac, and vice versa.

Because Python is relatively easy to learn and contains simple syntax, it is a good choice for testers.

7. What is CPython?

  • It’s a programming language that is a superset of the C language, designed to produce Python-like performance with code written in C
  • It’s the default, reference implementation of Python, written in the C language
  • It’s a programming language that is a superset of Python, designed to produce C-like performance with code written in Python
  • It’s the default, reference implementation of the C language, written in Python
Explanation: CPython is the original (traditional) Python language implementation written in the C language, as opposed to other, non-default implementations, such as Jython, implemented in the Java language, which came later. CPython is the Python language implementation available for download from www.python.org, and the first to adopt new features that come with all the subsequent Python versions.

8. What do you call a command-line interpreter which lets you interact with your OS and execute Python commands and scripts?

  • Jython
  • A console
  • A compiler
  • An editor
Explanation: A Python console is a command-line interpreter that allows you to execute Python commands, instructions, and scripts line by line. Just like the one here: www.python.org/shell.

9. What is the expected behavior of the following program?

print("Hello!")
  • The program will output ("Hello!") to the screen
  • The program will generate an error message on the screen
  • The program will output Hello! to the screen
  • The program will output "Hello!" to the screen
Explanation: The program will print the string ‘Hello!’ to the console. The print function simply prints the specified message, in our case 'Hello!', to the screen.

10. What is the expected behavior of the following program?

prin("Goodbye!")
  • The program will output ("Goodbye!") to the screen
  • The program will output "Goodbye!" to the screen
  • The program will output Goodbye! to the screen
  • The program will generate an error message on the screen
Explanation: The program will raise a NameError exception, because Python cannot recognize the name prin. Python doesn’t know that you’re most probably trying to use the word print, not prin.

Leave a Reply

Your email address will not be published. Required fields are marked *