๐Ÿ Introduction to Programming with Python

Department of Computing

College of Business & Technology

East Tennessee State University

Professor Ryan Haas

๐Ÿ“š Course Overview

This course introduces students to both programming fundamentals and computational thinkingโ€”the problem-solving skills that make programming powerful.

We'll learn Python while developing the mindset that helps us break down complex problems into manageable pieces.

๐ŸŽฏ What We'll Cover Today

๐Ÿ’ญ Computational thinking through real-world team formation
๐Ÿ”ข Python fundamentals: variables, data types, and operations
๐Ÿ“ Collections and indexing with lists
๐Ÿค” Boolean logic and decision making
๐Ÿ”„ Automation with loops
โœจ Professional output with f-strings

๐Ÿ What is Python?

๐Ÿ“–A popular programming language with easy-to-read syntax

This makes it accessible to beginners while remaining powerful for experts.

๐Ÿ”ฌ Scientists & Analysts

Use Python for data processing, visualization, machine learning, and AI in fields like bioinformatics and business analytics

๐ŸŒ Web Developers

Create modern, custom web applications with frameworks like Django and Flask

๐Ÿค– Hobbyists

Control robots, create chatbots, voice assistants, and home automation systems

๐Ÿ’กWith modern conversational AI, it's easier than ever to create your own apps! You should still know how to code because AI makes mistakes!

๐Ÿฅช The Recipe Challenge

Challenge Question:

"How would you teach a robot to make a peanut butter sandwich?"
Try it: Write step-by-step instructions that a robot could follow

๐Ÿค” What you'll quickly discover:

  • You need to be incredibly specific
  • "Pick up the knife" assumes the robot knows what a knife is!
  • Every step must be broken down further
  • You can't assume any prior knowledge

๐ŸŽฏThis is exactly how programming works - computers need explicit, detailed instructions for everything!

๐Ÿ‘ฅ Team Formation Challenge Activity

"Before we dive into programming concepts, let's experience computational thinking with a real problem you face in class: forming teams!"

๐Ÿ“ Phase 1: Manual Problem Solving

Setting: You have 100+ students who need project teams of equal size. How would you solve this manually?

1. Attendance: Who's actually here?
2. Calculate: How many teams? What size?
3. Assign: Put students into groups fairly
4. Communicate: Tell everyone their assignments

โš ๏ธ Manual Challenges:

  • Time-consuming roll call
  • Math errors in team sizing
  • Assignment bias (friends clustering)
  • Communication bottlenecks

๐Ÿ’ป Phase 2: Digital Solution Demo

๐Ÿ“‹ Digital Attendance

Microsoft Forms collect student information automatically

๐Ÿ“Š Data Processing

Excel responses cleaned and organized (abstraction!)

Name 1 2 3 4 5 6 Maxwell Chidi Monika Segun Sushmita Preet

๐ŸŽฒ Team Generation

Automated tool randomly assigns equal teams

Team Assignments Team Koalas Maxwell Chidi Monika 3 members Team Ducks Segun Sushmita Preet 3 members

๐Ÿ”— Demo Links (In-person classes):

๐Ÿ›๏ธ The Four Pillars of Computational Thinking

๐Ÿงฉ Decomposition

Breaking big problems into smaller, manageable pieces

Team formation: broke into attendance โ†’ calculation โ†’ assignment โ†’ communication

๐Ÿ” Pattern Recognition

Finding similarities and trends

Team formation: recognized repeated classroom need

๐ŸŽญ Abstraction

Focusing on what's important, ignoring unnecessary details

Team formation: only cared about names, not IDs or timestamps

๐Ÿ“‹ Algorithm Design

Creating step-by-step instructions that always work

Team formation: form โ†’ clean โ†’ generate โ†’ display

๐Ÿ Why Python?

Python reads almost like English! Let's see how our team formation logic would look in code:

# Our team formation algorithm in Python
with open('student_names.txt', 'r') as file:
    students = file.read().splitlines()  # Read names (like our Excel step)

team_size = 4
teams = []
for i in range(0, len(students), team_size):  # Pattern recognition!
    team = students[i:i + team_size]
    teams.append(team)

for i, team in enumerate(teams, 1):  # Communication step
    print(f"Team {i}: {', '.join(team)}")

๐Ÿ’กDon't worry about understanding every detail yet โ€” notice how it follows the same logical steps we identified!

Get Ready to Run Some Python

โš ๏ธ Online Student!

Before continuing, open an online Python interpreter such as this one so you can copy and paste the code examples. When you click "Run", You'll get to see the results! Try tweaking the code examples and watching the output change!

๐Ÿ“ฆ Variables: Digital Containers

Think of variables as labeled boxes that store informationโ€”just like how we stored student names in our digital form.

# Creating our first variables (like storing form responses)
name = "Chelsie"
age = 42
height = 5.7
likes_koalas = True

print("Hello! My name is", name)
print("I am", age, "years old")

๐Ÿ”‘ Key Concept: Think of each variable as a container that holds a value

name "Chelsie" age 42 height 5.7 likes_koalas True

๐Ÿท๏ธ Python's Data Types

Just like we organized different information in our team formation (names vs. numbers vs. true/false), Python has different data types:

๐Ÿ“ Strings (str)

Text in quotes

student_name = "Taylor Swift"
class_section = "CSCI-1100-001"

๐Ÿ”ข Integers (int)

Whole numbers

total_students = 127
team_size = 4

๐Ÿ”ข Floats (float)

Decimal numbers

average_team_size = 4.2
gpa = 3.85

โœ… Booleans (bool)

True or False

attendance_form_submitted = True
has_partner_preference = False

๐Ÿ–จ๏ธ Output: The Magic of the Print Function

print("This displays on screen!")
print("We have", 127, "students today!")

# Modern Python way with f-strings (like our team display)
student_name = "Taylor"
team_number = 3
print(f"{student_name} is assigned to Team {team_number}!")

# Advanced f-string formatting
average_score = 87.6789
print(f"Team average: {average_score:.1f}%")  # Shows: 87.7%

๐Ÿ‘‰ Your Turn: Personal Profile

Create variables about yourself and use print() to display a personal profile, similar to how our form collected and displayed information.

Try creating variables for: name, age, favorite subject, graduation year
Use f-strings to create a nicely formatted profile

โŒจ๏ธ Input: Getting Information from Users

name = input("What's your name?: ") # Won't continue until you press the enter key
print(f"Nice to meet you, {name}!")

# Getting numbers - int() converts it from string (str) to integer (int)
age = int(input("How old are you?: "))
print(f"You'll be {age+10} in 10 years!")

# Building an interactive profile collector
favorite_subject = input("What's your favorite subject?: ")
graduation_year = int(input("What year do you graduate?: "))
print(f"{name} loves {favorite_subject} and graduates in {graduation_year}!")

๐Ÿ‘‰ Your Turn: Interactive Profile Builder

Combine input() and print() to create an interactive program that asks users for their information and displays it back nicely formatted.

Ask for: name, favorite hobby, dream job, and hometown
Use input() to collect the data, then print() with f-strings to display a bio (e.g. "My name is ___. I'm from ___", etc.)

๐Ÿ“‹ Lists: Organizing Multiple Items

Remember our list of student names? Python lists work the same way:

todo_list = ["Clean room", "Do homework", "Work out"]
# Break a string up into a list with the *split* function!
shopping_list_string = "apples,bread,eggs"
shopping_list = shopping_list_string.split(",")
print(shopping_list) # prints ['apples', 'bread', 'eggs']

๐Ÿ”ข The Secret of Indexing: Computers Count from 0!

todo_list = ["Clean room", "Do homework", "Work out"]
# Indexing: "Clean room"
print("The first item in the to-do list is: " + todo_list[0])
# Indexing: "Do homework"
print(f"The second item in the to-do list is: {todo_list[1]}") # f-string
# Indexing: "Work out"
print(f"The third item in the to-do list is: {todo_list[2]}") # f-string 

Why start from 0? Think of it as "how many steps from the beginning"

๐Ÿ”ง List Methods: Updating Your Lists

Lists aren't just for storing - you can modify them as you complete tasks and get new ones!

todo_list = ["Clean room", "Do homework", "Work out"]
# How many items do we have?
print(f"I have {len(todo_list)} tasks to complete")

# Completed a task? Remove it!
todo_list.remove("Clean room")
print("โœ… Cleaned my room!")
print(f"Tasks remaining: {todo_list}")

# Got a new task? Add it to the end!
todo_list.append("Call grandma")
print(f"Updated list: {todo_list}")
print(f"Now I have {len(todo_list)} tasks")

๐Ÿ‘‰ Your Turn: Task Manager Simulation

Create your own dynamic to-do list that changes as you work through it!

Start with a list of 3-4 tasks
Remove a completed task and celebrate with print()
Add a new urgent task that just came up
Show your final list and count

โš–๏ธ Making Decisions with Boolean Logic

Remember when our team formation tool had to decide if we had enough students for even teams? That's Boolean logic!

# Scenario: Should you take an umbrella?
is_raining = True
has_hood = True
is_windy = True

# Don't need umbrella if it's NOT raining
# Or if you have a hood and it's NOT windy
need_umbrella = is_raining and not (has_hood and not is_windy)

if need_umbrella:
    print("Take your umbrella! โ˜”")
else:
    print("No umbrella needed today! ๐ŸŒž")
# Fun fact: I made a smart alarm clock with Python in college.
# It checked wind, humidity, rain to recommend my outfits using if/elif/else decisions! - Prof Haas

๐Ÿ” Comparison Operations

age = 65
is_student = False

if age >= 65 or is_student:
    print("โœ… Eligible for discount")
else:
    print("โŒ Not eligible for discount")

# Boolean variables in action
form_completed = True
valid_name_entered = True
can_assign_to_team = form_completed and valid_name_entered

print(can_assign_to_team)  # True

๐ŸŽฏ Like checking our form responses:

We can combine multiple conditions to make complex decisions, just like our team formation tool checks multiple criteria before assigning students.

๐Ÿ”„ For Loops: The Heart of Our Team Generator

Remember how our team generator automatically assigned all students without us doing it manually? That's the power of loops!

๐Ÿ˜ด Manual way (like calling attendance):

students = ["Maxwell", "Chidi", "Monika"]
print("Welcome", students[0])
print("Welcome", students[1])
print("Welcome", students[2])

๐Ÿš€ Automated way (like our digital solution):

students = ["Maxwell", "Chidi", "Monika"]
for student in students:
    print(f"Welcome {student}!")

๐Ÿ”ข The Range Function - Creating Team Numbers

# Creating team numbers (like our generator tool)
for number in range(1, 6):  # range starts from 1, goes up to (but doesn't include) 6
    print(f"Counting: {number}")# Prints 1 2 3 4 5 on separate lines

๐ŸŽฏ Building Our Own Simple Team Assigner

students = ["Maxwell", "Chidi", "Monika"]
students_count = len(students) # The *len* function stores 3 to students_count (students_count = 3)

# Using the range function to print a numbered list!!
print('Team Koalas:')
print("-"*20)
for index in range(students_count):  # Loops through indices of the list (0, 1, 2)
    count = index + 1 # Human-friendly numbering
    print(f"{count}. {students[index]}")

โณ While Loops: Loops with Conditions

# Like waiting for all students to submit the form
# Interactive form submission example
students_submitted = 0
total_students = 6 # Pretend class size is 6

print("Please enter your name to submit the form.\n")

while students_submitted < total_students: # Repeat the next 3 lines until students_submitted is 6
    name = input("Enter your name: ")
    students_submitted += 1 # Add one to the count
    print(f"Thanks, {name}! Submission received. ({students_submitted}/{total_students})\n")

# Only prints after the loop stops
print("All students have submitted! Time to generate teams!")

โš ๏ธBe careful with while loops! Make sure the condition will eventually become False, or your program will run forever.

๐Ÿงฎ The Order Matters - Operations and Precedence

When calculating team sizes, order of operations matters:

# Calculating teams with different approaches
total_students = 127
base_team_size = 4
extra_members = 3

# Wrong way (without parentheses)
result = total_students / base_team_size + extra_members
print(result)  # 34.75 (not what we want!)

# Right way (with parentheses)
result = total_students / (base_team_size + extra_members)
print(result)  # 18.14 (makes more sense!)

Variable Assignment and Updates:

# Like updating our attendance count
students_present = 120
print(f"Currently: {students_present} students")

# More students arrive
students_present = students_present + 7

# ๐Ÿ˜Ž Cool way
students_present += 3  # Same as: students_present = students_present + 3
print(f"Updated: {students_present} students")

๐ŸŽ‰ What We've Accomplished

๐Ÿ” Started with a Real Problem

How to efficiently form teams in a large class

๐Ÿง  Applied Computational Thinking

Decomposition, Pattern Recognition, Abstraction, Algorithm Design

๐Ÿ Learned Python by Solving

Variables, data types, lists, loops, boolean logic, and functions

๐Ÿ“š Python Concepts We Covered:

Variables stored our student information (like form responses)
Data types organized different kinds of information
Lists held collections of students (like our cleaned Excel data)
Indexing let us access specific students (starting from 0!)
Loops automated repetitive tasks (like the team generator)
Boolean logic helped make decisions
F-strings created professional output

๐Ÿค– Learning Python: Make your own chatbot

Now that you know input(), varables and decisions, you're ready to create a chatbot that responds differently based on what users say!

# Simple chatbot template
bot_name = "Ryan Bot"
print(f"๐Ÿค– Hi! I'm {bot_name}. What's your name?")
user_name = input("Your name: ")
print(f"Nice to meet you, {user_name}!")

print("How are you feeling today?")
mood = input("Your mood: ").lower()  # .lower() makes it not case-sensitive

if mood == "happy" or mood == "good" or mood == "great":
    print("๐ŸŽ‰ That's awesome! I'm happy you're doing well!")
elif mood == "sad" or mood == "bad" or mood == "tired":
    print("๐Ÿ˜Ÿ Sorry to hear that. I hope your day gets better!")
else:
    print(f"๐Ÿค” Hmm, {mood} is interesting! Thanks for sharing!")

print(f"It was nice chatting with you, {user_name}! ๐Ÿ‘‹")

๐Ÿ‘‰ Your Turn: Build Your Own Chatbot

Create a personalized chatbot that asks questions and responds based on the answers!

Start with a greeting and ask for their name
Ask a question (favorite color, hobby, food, etc.)
Use if/elif/else to give different responses
Add emojis and personality to make it fun!
End with a personalized goodbye using their name

๐ŸŒŸ The Big Picture

We've seen that programming isn't just about writing codeโ€”it's about developing a systematic way of thinking that helps you solve problems efficiently.

๐ŸŒ Real-world Applications:

  • Event planning: Break down into tasks, recognize patterns, focus on key details
  • Study optimization: Identify learning patterns, abstract key concepts
  • Group projects: Decompose work, create systematic processes
  • Problem-solving: Apply the same thinking process to any challenge
Whether you're organizing a classroom, planning an event, analyzing data, or building an app, computational thinking gives you a powerful approach.

๐Ÿš€ Next Steps

๐Ÿƒโ€โ™‚๏ธ Keep Practicing

Apply these concepts to personal projects and daily challenges

๐Ÿ‘€ Look for Opportunities

Find computational thinking opportunities in your daily life

๐Ÿ” Explore Python

If you want to continue learning Python, check out this resource

๐Ÿ’ช Remember

Every expert was once a beginner who kept practicing!

๐ŸŽฏ Practice Ideas:

  • Build a simple quiz game/chatbot
  • Create a grade calculator for your classes
  • Make a to-do list organizer
  • Design a budget tracker
  • Build a random password generator

๐Ÿ“‹ What We've Covered for Assessment

๐Ÿ Programming Concepts:

  • Variables and Data Types
  • Python Data Types (str, int, float, bool)
  • Print Function and F-strings
  • List Indexing (0-based)
  • Boolean Logic
  • For Loop Range
  • While Loops
  • Variable Assignment
  • Order of Operations

๐Ÿง  Computational Thinking:

  • Decomposition
  • Pattern Recognition
  • Abstraction
  • Algorithm Design
  • Real-world Applications

๐ŸŽฏ Key Achievement: You now understand both the how (Python syntax) and the why (computational thinking) of programming!

๐ŸŽ‰ Thank You!

Winking koala with leaf in mouth