3.2: Variables, Literals, and Primitive Data Types
3.2.1: Variables vs. Literals
Please read this article, as well as the article on Variables, for an understanding of the differences between literals and variables.
Please watch the lecture for an introduction to programming basic data types. This is one of a group of Khan Lectures that are used in this course. All of these lectures demonstrate programming concepts using Python.
You have been introduced to Python in sub-subunit 2.1.3.2 on OO-Programming. Python is an interpreted programming language that can be used to write procedural or object-oriented programs. It is easy to understand and write Python programs. One of its distinctive features is that it is dynamically typed. This means that a declaration is not needed to declare the type of a name. The Python interpreter determines the type of a name at execution time. Programming languages have syntax and semantics. Syntax is the set of grammar rules for writing statements in the language. Semantics are the meanings attached to the statements. For the lecture series, concentrate on the semantics or meanings. It is not our intent to teach Python here, but to use Python to teach programming concepts.
The value of these lectures lies primarily in the programming concepts that they demonstrate. From sub-subunit 1.2.3, The Programming Lifecycle, you saw that programs are used to solve problems (called requirements) using a programming language. First, one must devise a plan for solving the problem (called the design of the program). Then, a solution must be built based on the design, using a programming language (called the implementation or program implementation)--in this lecture, Python programs. Finally, you should test the program to check that it solves the problem (i.e. satisfies the requirements).
In watching the lecture, focus on understanding the process of specifying the problem or requirements, the design, the program semantics, and test as well as understanding the transformation that relates these to each other. Do not worry about the syntax of Python for now; the basics will be repeated throughout the Khan lectures.
3.2.2: Legality of Variable Names
Review the section on variables, which you read in unit 2.
3.2.3: Primitive Data Types
Please read the chapter. This chapter discusses eight primitive data types in Java programming language. Please note that this resource applies to the topics outlined in sub-subunits 3.2.3.1 - 3.2.3.3.
Please note that this assessment covers the topics outlined in subunits 3.2.3.1 - 3.2.3.3.
Please watch the two lectures. Lists and strings are similar, in that a string can be viewed as a list of characters. However, while similar, they are different objects with their own methods or functions used to manipulate them. A program consists of control phrases, or statements, and data structures. Lists and strings are two important data structures for problem solving.