0% found this document useful (0 votes)
15 views13 pages

Intro To CS Class Notes

The document provides study notes on data and computers, covering key concepts such as the difference between data and information, types of data handled by computers, and the importance of binary representation. It also discusses data compression, analog vs. digital data, and various methods for representing numeric data, including positive and negative integers, real numbers, and floating-point representation. Additionally, it outlines the basics of declaring and using variables and constants in programming, as well as an overview of object-oriented design and high-level programming languages.

Uploaded by

Allen Volpe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views13 pages

Intro To CS Class Notes

The document provides study notes on data and computers, covering key concepts such as the difference between data and information, types of data handled by computers, and the importance of binary representation. It also discusses data compression, analog vs. digital data, and various methods for representing numeric data, including positive and negative integers, real numbers, and floating-point representation. Additionally, it outlines the basics of declaring and using variables and constants in programming, as well as an overview of object-oriented design and high-level programming languages.

Uploaded by

Allen Volpe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

📘 3.

1 Data and Computers – Study Notes


📌 Key Concepts

● Data vs. Information:

○ Data: Raw facts or values, unprocessed and potentially unstructured.

○ Information: Processed and organized data that is useful for solving problems.

● Types of Data Computers Handle:

○ Numbers

○ Text

○ Audio

○ Images and Graphics

○ Video

● All data on a computer is stored as binary digits (1s and 0s).

🔄 Data Compression

● Purpose:

○ Originally: Save storage space.

○ Now: Improve data transmission (especially for streaming).

● Compression Ratio:

○ Formula: Compressed Size / Original Size

○ Value range: 0 to 1 — lower is better (more compression).

● Types:

○ Lossless: No data lost (e.g., ZIP files).

○ Lossy: Some data lost, acceptable for media (e.g., MP3, JPEG).

○ Trade-off: Size vs. Accuracy.


🌍 Analog vs. Digital

● Analog Data:

○ Continuous, infinite (e.g., real-world sound, light, motion).

○ Example: Mercury thermometer.

● Digital Data:

○ Discrete, finite.

○ Must digitize analog input for use in computers.

○ Represented using binary.

🔌 Why Binary?

● Hardware:

○ Simpler, cheaper, and more reliable to detect two states (high/low voltage).

● Signal Reliability:

○ Analog: Degrades → data loss.

○ Digital: Can be reclocked (restored) to preserve information.

○ Pulse-Code Modulation (PCM): Sharp switching between two voltages.

🧮 Binary Representations

● Bit Basics:

○ 1 bit = 2 values

○ n bits = 2ⁿ unique combinations

● Examples:

○ 1 bit → 2 values (sweet/sour)


○ 2 bits → 4 values (gear states: P, D, R, N)

○ 3 bits → 8 values

○ 5 bits → 32 values (sufficient for 25 items)

● Computer Architecture:

○ Data stored in bit groups: typically 8, 16, 32, etc.

○ Extra bits may be allocated even if not strictly needed.

Here are your clean, structured study notes for Section 3.2: Representing Numeric Data from
your computer science course:

📘 3.2 Representing Numeric Data – Study Notes


🔢 Positive Integers

● Binary is naturally suited to representing positive integers (covered in Chapter 2).

● No special mapping needed—binary is a number system.

➖ Representing Negative Numbers

🔹 1. Signed-Magnitude

● Sign (+/-) + magnitude

● Used in human math, e.g., –23.

● Problem: Two zeros (e.g., +0 and –0) → not ideal for computers.

🔹 2. Fixed-Sized Number Mapping

● Split numeric space into positive and negative halves.

● Example (two-digit decimal):

○ 00–49 = 0 to 49

○ 50–99 = –50 to –1
● Subtraction = A – B = A + (–B)

● Use ten’s complement:

○ Formula: Negative(I) = 10^k – I

■ E.g., –3 with 2-digit space: 100 – 3 = 97

🔹 3. Two’s Complement (Binary Version)

● Formula: Negative(I) = 2^k – I

● Or use shortcut: invert bits and add 1

● Example: –2 in 8-bit →

○ 2 = 00000010

○ Invert: 11111101

○ Add 1: 11111110

● Leftmost bit (MSB):

○ 0 → Positive

○ 1 → Negative

⚠️Overflow

● Happens when the result exceeds allocated bits.

● Example (8-bit): 127 + 3 = 130, which wraps to negative due to sign bit.

● Handled differently by each system/language.

📈 Representing Real (Non-Integer) Numbers

🧮 What is a real number?

● Value with a fractional part (e.g., 3.14, 0.999)

● In base 10:

○ Left of decimal: 10⁰, 10¹, etc.


○ Right of decimal: 10⁻¹, 10⁻², etc.

● In binary:

○ Right of radix point: 2⁻¹ (½), 2⁻² (¼), 2⁻³, etc.

🔹 Floating-Point Representation

● Formula:
sign × mantissa × base^exponent

● Mantissa: significant digits

● Exponent: how much to shift radix point

● Base:

○ Decimal: 10

○ Binary: 2

🔸 Example (Base 10):

● 148.69 → 14869 × 10⁻²

● Stored as:

○ Sign

○ Mantissa = 14869

○ Exponent = –2

🔸 Binary Floating Point (IEEE 754 standard)

● 64-bit layout:

○ 1 bit: sign

○ 11 bits: exponent

○ 52 bits: mantissa

🔹 Converting Fractional Part to Binary

● Multiply decimal part by 2.


● Integer part of result = next binary digit.

● Repeat with new fractional part.

● Example:
0.75 × 2 = 1.5 → 1
0.5 × 2 = 1.0 → 1
→ 0.75 = .11

● Example:
0.435 × 2 = 0.870 → 0
0.870 × 2 = 1.740 → 1
0.740 × 2 = 1.480 → 1
0.480 × 2 = 0.960 → 0
→ continues indefinitely → approximation

🔸 Full Conversion Example:

● 20.25 (decimal) → Binary

○ 20 = 10100

○ 0.25 = .01
→ Final: 10100.01

🧪 Scientific Notation

● Keeps radix to the right of the first non-zero digit.

● Used in many programming languages.

● Format:
1.20013E+4 = 12001.3
(E stands for “× 10^”)

Here are your concise, structured study notes for Section 2.1: Declaring and Using Variables
and Constants, formatted for clarity and easy reference:

📘 2.1 Declaring and Using Variables and Constants – Study Notes


🔹 Data in Programs

● Data: Includes all text, numbers, and other values processed by a program.

● Data types:

○ Numeric: Numbers (e.g., 42, 3.14)

○ String: Text (e.g., "hello")

● Data Forms:

○ Literals (unnamed constants)

○ Variables (named, changeable memory)

○ Named constants (named, unchangeable)

🧾 Data Types

● Data Type defines:

○ What values can be held

○ How values are stored

○ What operations are valid

● Numeric:

○ Includes integers and floating-point (real) numbers

○ Used in arithmetic

● String:

○ Includes letters, digits, symbols (e.g., "Hello", "42", "$5.00")

○ Not used in arithmetic

● This course uses only:

○ num for numeric

○ string for text


📍 Constants (Literals)

● Unnamed (literal) constant: Hardcoded value, no identifier

○ Numeric: 43

○ String: "Amanda"

● Note: "43" is a string; 43 is a numeric constant

🔁 Variables

● Variable: Named memory location that can change value

● Example: myNumber, myAnswer

● Must be declared before use

➕ Declaration includes:

● Data type (num or string)

● Identifier (name)

● Optional initial value

💡 Type-Safety:

● Some languages are strongly typed: you must assign correct data types

● Invalid assignments (e.g., assigning text to a num) cause errors

✍️Identifiers (Variable Names)

● Identifier: Programmer-chosen name for a variable

● Naming Rules (This Course):

1. One word, no spaces or punctuation

2. Must start with a letter


3. Should be meaningful/descriptive

🧱 Naming Conventions:
Convention Example Used In

Camel Case hourlyWage Java, C#

Pascal Case HourlyWage Visual Basic

Hungarian Notation numHourlyW C (Windows API)


age

Snake Case hourly_wag C, Python


e

Mixed Case w/ Hourly_Wag Ada


Underscores e

Kebab Case hourly- Lisp, COBOL


wage

➡️Assignment Statements

● Syntax: variable = value

○ Example: myAnswer = myNumber * 2

● Assignment Operator (=):

○ Operates right to left

○ Right = value or expression

○ Left = variable (called an lvalue)

Valid:

someNumber = 10
someOtherNumber = someNumber + 5

Invalid:

10 = someNumber ← Left side must be a variable


"Hello" = name ← Cannot assign to a literal

🧮 Initializing Variables

● Initialization = Assigning a starting value at the time of declaration

● Example:

num rate = 0.05 ← Initialized


string name ← Not initialized

● Garbage Values:

○ Uninitialized variables may contain undefined ("garbage") values

○ Using them without assignment = logical error

Where to Declare Variables

● Must be declared before first use

● This course’s convention: declare all variables together, at the top

Here are your study notes based on the provided text from Chapter 9: Object-Oriented Design
and High-Level Programming Languages. I’ve organized them into bullet points for clarity and
memorization:

📘 Chapter Overview
● This chapter builds on earlier lessons:

○ Chapter 1 introduced layered language systems built around hardware.

○ Chapter 6 covered machine code and assembly language, which use


mnemonics instead of raw numbers.

● Assembly languages simplify things but still require thinking in machine-level terms.
● Pseudocode was introduced as a human-readable way to describe algorithms.

● High-level programming languages formalize this, but still need to be translated into
machine code using compilers or interpreters.

🎯 Goals / Learning Objectives


By the end of this chapter, you should be able to:

● Distinguish between functional design and object-oriented design.

● Describe and apply the object-oriented design process.

● Identify the three core components of object-oriented languages:

1. Encapsulation

2. Inheritance

3. Polymorphism

● Describe how code translation works:

1. Assembly

2. Compilation

3. Interpretation

4. Execution

● Name four programming paradigms and give examples:

1. Imperative (e.g., C)

2. Functional (e.g., Lisp)

3. Object-Oriented (e.g., Java)

4. Logic-Based (e.g., Prolog)

● Define data type and strong typing.

● Understand how top-down design and object-oriented design are supported in


programming languages.
🧠 Key Concepts
🔹 Object-Oriented Design (OOD)

● Focuses on data rather than tasks.

● Views a program as a collection of interacting objects, each with its own data and
behavior.

● OOD is a foundational concept behind many modern high-level programming languages


(like Java, C++, Python).

🔹 High-Level Programming Languages

● Use human-readable syntax.

● Allow programmers to focus on logic rather than hardware.

● Require translation into machine code through:

○ Compilers (translate entire code before execution)

○ Interpreters (translate and run code line by line)

🎾 Real-World Application Example: Tennis Ball Tracking


● Tennis line calls are verified using computer vision and trajectory mapping.

● A system of 4 high-speed digital cameras + wireless network + software:

○ Tracks the ball's flight.

○ Calculates point of impact.

○ Maps whether it was “in” or “out”.

● Demonstrates real-world use of object-oriented systems, data processing, and high-


level logic in sports technology.

Let me know if you’d like this turned into a printable study guide or flashcards!

You might also like