Introduction to Programming (6100L) - Lecture 1

Jul 23, 2024

Lecture Notes: Introduction to Programming (6100L)

Instructor Information

  • Lecturer: Anna Bell
  • Experience: Nearly 10 years in the ECS department
  • Course Title: Introduction to Programming, 6100L

Lecture Overview

  1. Course Administrative Information
  2. High-Level Overview of Computers
  3. Introduction to Python Basics

Course Structure & Expectations

  • Lectures: Teaching, interactive coding sessions, opportunities for questions
  • Materials: Download lecture slides beforehand, highly recommend following along with coding exercises
  • UTRI Breaks: Breaks during lectures for hands-on coding practice
  • Participation & Practice: Emphasizes the importance of actively coding and participating to learn programming skills

Learning Outcomes

  1. Conceptual Knowledge: Understanding computer science concepts
  2. Programming Skills: Gaining hands-on experience in coding
  3. Problem-Solving Skills: Translating problems from English descriptions to coded solutions

Course Topics

  1. Computational Thinking: Approach problems with computational solutions
  2. Python Programming Language: Basics and structuring code
  3. Algorithms: Intro to base algorithms
  4. Algorithmic Complexity: Assessing program efficiency and memory usage

Types of Knowledge

  • Declarative Knowledge: Statements of fact (e.g., math definitions)
  • Imperative Knowledge: Instructions or recipes (e.g., steps to compute square roots)

Example Algorithm: Computing Square Roots

  1. Initial Guess: Start with an arbitrary guess
  2. Iteration: Iterate to refine the guess
  3. Stopping Condition: Stop when an adequately precise value is reached

Programming Basics

  • Programs as Recipes: Sequences of steps or instructions for computers
  • Computers’ Role: Execute algorithms, store data, perform operations quickly

Historical Context

  1. Fixed-Program Computers: e.g., Pocket calculators
  2. Stored-Program Computers: Could store and execute instructions as data

Python Programming Language

  • Primitives: Numbers, sequences of characters, operations, true/false values
  • Syntax: Rules for forming valid sentences or expressions in Python
  • Semantics: No ambiguity in meaning; programs have a single interpretation
  • Expression Evaluation: Python evaluates expressions and stores their values, not the expressions themselves

Variables & Assignments

  • Variable Creation: Binding names to values
  • Variable Rules: Understanding valid assignment (e.g., x = 5)
  • Rebinding: Changing the value associated with a variable’s name (e.g., radius = radius + 1)

Programming Constructs

  1. Expressions: Example 3 + 2 evaluates to 5
  2. Types of Objects: Integers, floats, booleans, etc.
  3. Operations: Addition, multiplication, division, exponentiation, etc.

Coding Practicals

  • Swapping Variable Values: Using a temporary variable
  • Python Tutor: Tool to step through code execution line-by-line for debugging

Key Takeaways

  • Evaluate Line by Line: Python reads and executes code from top to bottom
  • Computers Follow Instructions: Execute instructions exactly as given
  • Imperative vs Declarative Knowledge: Focus on instructions (imperative) in computer science

Next Steps

  • Upcoming Lectures: Introduction to control flow and decision-making in programs
  • Practice: Continue using the shell for quick tests and debugging

Summary

  • Programming Basics: Manipulating objects and understanding types
  • Expressions & Evaluations: Combining objects into meaningful expressions
  • Assignments: Using variables to write clear, reusable code
  • Importance of Practice: Engage in hands-on coding to solidify learning

End of Lecture

  • Reminder: Next session on Monday