Danulearn Open Danulearn
Unit 6

Fundamentals of Programming

πŸ“—Introduction
  • A computer program is a set of instructions that commands a computer what to do.
  • Computers do every task they do by following the instructions stated in programs, and the people who write programs are called programmers.
  • This unit introduces the types of programming languages, then teaches the basics of one of them, Python: the interactive interpreter and the text editor, variables and data types, statements and expressions, and simple programs with input and output.
  • Every Python listing in this unit has a Run button.
  • Boxes whose lines begin with >>> work like the interactive interpreter: each line is run in turn and its result is shown under it.
  • The other boxes are scripts, as written in the text editor, and they show only what print() displays.
  • Press Edit to change a box and run it again.
🎯 Learning Outcomes
  • Define computer programs.
  • State and describe the types of programming languages.
  • Explain the syntax and semantics of programming languages.
  • Explain variables and data types.
  • Differentiate statements and expressions in Python.
  • Analyze simple programs written in Python.
  • Write simple programs with input and output.
6.1  Computer Programs and Programming Languages
  • Programming languages are computer languages used to write computer programs.
  • They are generally grouped into machine language, assembly language and high-level language.
6.1.1Types of Programming Languages
Machine Language
  • Machine language is a low-level language in which everything, including instructions, numbers and memory locations, is represented in 1s and 0s, the binary system.
  • It is the language computers understand directly, with no translation, which is why it is very fast and uses memory efficiently.
  • Writing programs in machine language, however, is very difficult.
Assembly Language
  • Assembly language is also a low-level language, but instead of 1s and 0s it uses symbols called mnemonics.
  • It is easier than binary but still difficult.
  • Because computers understand only machine language, a program written in assembly language needs special software, the assembler, to translate its instructions into machine language.
High-Level Language
  • High-level languages are closer to human languages than assembly and machine languages are.
  • They let programmers concentrate on the problem they want to solve more than on the language.
  • Examples are C, C++, Java, C#, Python, Perl and Ruby.
  • A high-level program also cannot be executed directly: it is first translated into machine language by translator software, which is either a compiler or an interpreter.
TranslatorWhat it translatesHowUsed by
AssemblerAssembly languageTranslates the instructions into machine languageAssembly language
CompilerHigh-level languageTranslates the whole program at once; the machine language is then executedC, C++, Java, C#
InterpreterHigh-level languageTranslates and executes the program one statement at a timePython, Perl, Ruby
6.1.2Syntax and Semantics
πŸ”’
The rest of Unit 6 is in the Danulearn app

Read the full notes for all 5 sections, worked examples and figures, plus 11 exercises with step-by-step solutions, the Short Note and the unit review.

πŸ“‘ Contents

  1. 6.1Computer Programs and Programming LanguagesPreview
  2. 6.2Basics of PythonπŸ”’
  3. 6.3Variables and Data TypesπŸ”’
  4. 6.4Statements and ExpressionsπŸ”’
  5. 6.5Writing a Simple ProgramπŸ”’