Intro to Python

Classroom Habits and Learning Etiquette

  • Impact on Others: Students are encouraged to reflect on how their behaviors impact others' learning experiences.

  • Device Policy: Unless a student has a UCO-approved accommodation for taking notes or the class is performing an active coding exercise, phones and laptops should be stowed in bags. This is because the acoustics of the room cause conversations and distractions to carry, impacting others' ability to focus.

  • Do Not Disturb Mode: Students should set recurring "Do Not Disturb" modes on phones and laptops during class to prevent notifications from disrupting the environment.

  • Collaborative Context: Lectures frequently transition between instructional periods and group activities. Discussion during activities is highly encouraged, even if the room becomes loud, but "locking in" is required when new concepts are being taught.

Workspace Setup and Software Installation

  • Requirement: Students must install all required course software and set up their workspace to facilitate active coding in class and for assignments.

  • Software Frustration: Software installation is recognized as one of the most potentially frustrating experiences of the semester. However, it only needs to be completed once.

  • Open House Support: Located in Sitterson Hall, Room 8. No tickets or appointments are necessary. Staff are available to help with installation and workspace issues.

    • Thursday: 11:00 AM – 5:00 PM

    • Friday: 11:00 AM – 3:00 PM

Philosophical Engagement with AI

  • Curiosity vs. Laziness: Engaging with AI should be driven by curiosity rather than laziness. AI is a powerful tool for learning insight and broad knowledge but is also a powerful tool for avoiding the learning process.

  • Litmus Tests for AI Usage:

    • Is the message curious or lazy?

    • Does the message lead to "brain rot" or "brain gain"?

    • Would you reasonably ask this specific question to a TA or an Instructor? (e.g., You would not ask a TA to do your assignment for you).

  • Effective AI Interactions: Interactions should aim for insight and understanding rather than just obtaining an answer. For example, asking for a different explanation of a concept or how a concept relates to another field (like psychology) is productive.

Introduction to Algorithms and Data Types

  • The Programming Relationship: Programming is the practice of writing algorithms.

  • Algorithm Definition: A sequence of instructions.

  • Why Data Types Matter First:

    • Instructions must operate on "something."

    • Inputs serve as the raw material or building blocks for algorithms.

    • Different types of data represent different types of information (e.g., counting likes on a post vs. calculating statistical probabilities).

    • Understanding data types is necessary to understand the errors that may occur in a program.

  • Input and Output: The goal of programming is to take input data and transform it into resulting output data, which may take various shapes and sizes.

Literals in Python

  • Definition: A literal is the simplest possible way to express a piece of data in Python. It requires no further evaluation to be understood as a single value.

  • Evaluation Examples:

    • 11 is a literal.

    • 1+11 + 1 is NOT a literal because the computer must perform math to simplify it to a single value.

  • Primitive Atomic Types:

    • Integer (intint): A whole number without a decimal point. It can be positive (55), negative (−5-5), or zero (00).

    • Floating-point (floatfloat): A number that includes a decimal point followed by one or more digits (e.g., 5.05.0).

    • String (strstr): A sequence of characters wrapped in quotation marks (e.g., "true").

    • Boolean (boolbool): A logical value representing TrueTrue or FalseFalse.

Case Sensitivity and Booleans

  • Case Sensitivity: Python is a case-sensitive language, meaning capitalization is fundamental to how code is interpreted.

  • Boolean Specifics:

    • The value TrueTrue must have a capital "T" and lowercase "rue" to be recognized as a Boolean type.

    • Using TRUE (all caps) or true (all lowercase) without quotes will likely result in a NameError, as Python will not recognize them as Boolean literals or previously defined variables.

    • If a word like "true" is wrapped in quotes ("true"), it is interpreted as a string literal, not a Boolean.

Objects and Memory

  • Definition: An object is a typed unit of data stored in the computer's memory (RAMRAM).

  • Purpose: The data type of an object tells the computer how to store, represent, and interact with that piece of data.

  • Examples: The number 55 is an object; the text "Hello, World" is an object.

  • Technical Note: Objects represent areas in memory where data is stored and where certain operations can be performed. In the future, students can create "composite" objects by bundling atomic types together.

Data Types in Real-World Context (Instagram Scavenger Hunt)

  • Strings (strstr):

    • Usernames: (e.g., unc.csxl). Every username must be unique, which involves significant computer science logic when checking against billions of existing strings.

    • Bios: Descriptive text explaining an account.

    • Buttons: Labels like "Following" or "Message."

  • Floats (floatfloat):

    • Battery Percentage: On some devices, represented as 78.0%78.0\%.

  • Booleans (boolbool):

    • Following Status: Am I following this account? (True/FalseTrue/False).

    • Notifications: Are notifications toggled on or off?

    • Account Privacy: Is the account private? (True/FalseTrue/False).

    • Modal Visibility: Is a pop-up (modal) currently visible on the screen?

  • Advanced/Future Data Types:

    • Collections: Lists of followers, collections of images, or grids of posts.

    • Composite Objects: An Instagram profile itself is an object that bundles various strings, integers, and Booleans.

    • Time: Representations of specific moments (e.g., 11:4811:48) which Python handles differently than standard integers.

Questions & Discussion

  • Question: Why did we read about data types and objects before algorithms and instructions?

  • Response: Instructions need something to operate on. Inputs are the raw material for algorithms. You need to know what the data is before you can determine what you can do with it.

  • Question: What is the difference between an integer and a float?

  • Response: An integer is a whole number with no decimal. A float has a decimal and digits following it. Even 5.05.0 is a float, while 55 is an integer.

  • Question: What is an object in programming terms?

  • Response: It is a typed unit of data in the computer's memory. The type tells the computer how to classify the information and how the user wants to interact with it. It is essentially data that takes up space in memory.

  • Question: What happens if you type "TRUE" in all caps in Python?

  • Response: Python will likely raise an error because it expects the specific capitalization of TrueTrue for Booleans. If it isn't quoted, it isn't a string, and if it isn't defined as a variable, the computer won't know what it is.