Digital Information and Data Types
Digital Information (bits, bytes, and abstraction)
Other number System (Video on binary, octal, decimal, and hexadecimal numbers)
Complete: PL Computer Science Data Module 1: Lesson 1
Data Types
Numeric Data Types
Type What it stores Storage Requirements Range
int whole numbers 4 byte -2,147,483,648 to +2,147,483,647
double decimal numbers 8 byte -1.7977+E308 to +1.7977+E308
float decimal numbers 4 byte -1.175494351 E 38 to 3.40282346E38
Non-Numeric Data Types
Type What it stores Examples
char single characters ‘s’, ‘$’,’A’
boolean logical values true, false
Assignment:
Note that the form of the assignment statement requires that the variable to be assigned is on the left of the equal sign and that the assigning expression is always on the right. See below.
Correct: age = currentYear - yearBorn;
Incorrect: currentYear - yearBorn = age;
Assign Values before using:
We can also use declared variables in equations and output, but only after first giving the variable a value.
Correct
double price = 18.95, tax;
tax = .0725 * price;
Incorrect
double price, tax;
tax = .0725 * price;
The problem in the second version is that we are trying to use the variable price in an equation, but price does not have a value yet. This will produce a compile-time error. The same error will occur if we try to output the price before it has a value.
Basic String Operations:
A String is a “string” of characters which can be a word or several words (including numbers and symbols). The indices of the characters are numbered from 0 to str.length – 1.
Concatenation: The process of combining two or more strings with the + operator is called concatenation.
String combination = “Let’s” + “Go”;
println(combination); //prints Let’sGo (no space)
Note: On the GACE it will be notated as print(combination)
Problem Set 1:
1) Determine an appropriate data type for the following values
Amount of money in checking account
Whether or not a person voted or not
Your Full Name
The first letter in your name
Number of siblings
2) Conversions:
Convert 39 (base 10) to binary
Convert 10101 (base 2) to decimal
Convert 74 (base 8) to decimal
Convert 62 (base 8) to binary
Convert 2A (base 16) to decimal
Convert 39 (base 16) to binary
3) Go over basic methods in Processing.
a) setup, draw, print, operations, order of operations, methods, errors (syntax, run-time, logical)
More Practice with Unit 1 and related concepts: Complete Data Course from GADOE
Before Unit 2: Read over the notes for conditionals, iteration, and recursion in Unit 2.