0% found this document useful (0 votes)
7 views118 pages

Presentation Automate 1738593490906

This document outlines a two-day beginner-friendly course aimed at teaching participants how to automate tasks using Python and AI tools. Key goals include understanding Python scripting basics, leveraging large language models (LLMs), and automating tasks like file organization and data entry. The course emphasizes the practical benefits of scripting for non-developers to enhance productivity and streamline workflows.

Uploaded by

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

Presentation Automate 1738593490906

This document outlines a two-day beginner-friendly course aimed at teaching participants how to automate tasks using Python and AI tools. Key goals include understanding Python scripting basics, leveraging large language models (LLMs), and automating tasks like file organization and data entry. The course emphasizes the practical benefits of scripting for non-developers to enhance productivity and streamline workflows.

Uploaded by

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

Using AI Tools and Python to Automate

Tasks
A two-day, beginner-friendly journey to streamline workflows, boost
productivity, and integrate AI into everyday tasks.

1 / 118
Goals
1. Understand the basics of Python scripting without prior
programming experience

2 / 118
Goals
1. Understand the basics of Python scripting without prior
programming experience

2. Explore ways to leverage LLMs in combination with Python

3 / 118
Goals
1. Understand the basics of Python scripting without prior
programming experience

2. Explore ways to leverage LLMs in combination with Python

3. Learn how to automate tasks such as file organization and data entry

4 / 118
Goals
1. Understand the basics of Python scripting without prior
programming experience

2. Explore ways to leverage LLMs in combination with Python

3. Learn how to automate tasks such as file organization and data entry

4. Use Python scripts to integrate with external LLM APIs

5 / 118
Why Learn to Automate?

6 / 118
Automation as a General Skill
Automate Repetitive Tasks

7 / 118
Automation as a General Skill
Automate Repetitive Tasks

Increase Productivity

8 / 118
Automation as a General Skill
Automate Repetitive Tasks

Increase Productivity

Save Money:

Replace expensive subscription tools with your own scripts

9 / 118
Automation as a General Skill
Automate Repetitive Tasks

Increase Productivity

Save Money:

Replace expensive subscription tools with your own scripts

Analyse Massive Amounts of Data

10 / 118
The Real Reason....

11 / 118
Writing code = the most general skill you
can have!
It is a superpower! :)

12 / 118
Scripting vs. Programming
An important distinction!

13 / 118
Both are About Following Recipes

14 / 118
Scripting
Writing code to full fill a set of pre-defined steps that accomplish a task

15 / 118
Scripting
Writing code to full fill a set of pre-defined steps that accomplish a task

Quick, targeted, and task-oriented

16 / 118
Scripting
Writing code to full fill a set of pre-defined steps that accomplish a task

Quick, targeted, and task-oriented

Typically used for automations, data manipulation, or utility tasks

17 / 118
Scripting
Writing code to full fill a set of pre-defined steps that accomplish a task

Quick, targeted, and task-oriented

Typically used for automations, data manipulation, or utility tasks

Toy example -> Renaming multiple files

# Rename all .txt files in a directory to include today's date


import os
from datetime import date

today = date.today().strftime("%Y-%m-%d")
for filename in os.listdir("."):
if filename.endswith(".txt"):
new_name = f"{today}_{filename}"
os.rename(filename, new_name)

18 / 118
Programming
At it's core is also about writing code to perform steps but...

19 / 118
Programming
At it's core is also about writing code to perform steps but...

It's about developing software systems (implementing engineering


practices, etc..)

20 / 118
Programming
At it's core is also about writing code to perform steps but...

It's about developing software systems (implementing engineering


practices, etc..)

Involves structure, design patterns, and often collaborative development

21 / 118
Programming
At it's core is also about writing code to perform steps but...

It's about developing software systems (implementing engineering


practices, etc..)

Involves structure, design patterns, and often collaborative development

Programming is considerably more effortful than scripting.

22 / 118
This course focuses on Scripting!

23 / 118
Why focus on scripting here?

24 / 118
Why focus on scripting here?
Much faster learning curve - if it works don't change it

25 / 118
Why focus on scripting here?
Much faster learning curve - if it works don't change it

Immediate practical benefits - makes your life better

26 / 118
Why focus on scripting here?
Much faster learning curve - if it works don't change it

Immediate practical benefits - makes your life better

Ideal for nondevelopers who just want to get things done

27 / 118
Why focus on scripting here?
Much faster learning curve - if it works don't change it

Immediate practical benefits - makes your life better

Ideal for nondevelopers who just want to get things done

Home-Cooked Software and Barefoot Developers


28 / 118
The Ostrich Approach to Learning Python

29 / 118
30 / 118
It's about Learning What We Need for Our
Tasks!

31 / 118
It's about Learning What We Need for Our
Tasks!
And purposefuly ignoring that which does not seem to have any effect on its
success.

32 / 118
Why Python?

33 / 118
Python is Easy and Everywhere

34 / 118
Python is Easy and Everywhere
Python is a general purpose language (can be used for everything)

35 / 118
Python is Easy and Everywhere
Python is a general purpose language (can be used for everything)

Python is used across the board in AI from developing AI models to


powering self-driving cars

36 / 118
Python is Easy and Everywhere
Python is a general purpose language (can be used for everything)

Python is used across the board in AI from developing AI models to


powering self-driving cars

Python is super easy to learn due to its proximity with natural language

37 / 118
The Busy Person Guide to Python Basics

38 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

39 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

Common Data Types: Strings, integers, floats, booleans

40 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

Common Data Types: Strings, integers, floats, booleans

Control Structures: if statements, loops (for, while)

41 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

Common Data Types: Strings, integers, floats, booleans

Control Structures: if statements, loops (for, while)

Useful Libraries: os for file operations, csv for handling CSVs, requests
for making web requests

42 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

Common Data Types: Strings, integers, floats, booleans

Control Structures: if statements, loops (for, while)

Useful Libraries: os for file operations, csv for handling CSVs, requests
for making web requests

That is a lot! How can we manage?

43 / 118
Python Things We Will Learn
Basic Syntax: Indentation, variable assignments, printing

Common Data Types: Strings, integers, floats, booleans

Control Structures: if statements, loops (for, while)

Useful Libraries: os for file operations, csv for handling CSVs, requests
for making web requests

That is a lot! How can we manage?

Use AI conversationally! Asking questions and clarifying what you don't


know!

44 / 118
How to Use AI to Learn/Use Python
A quick detour to set up an AI toolkit to speed up our Automation skills

45 / 118
The "Just Ask AI" Naive Approach

46 / 118
The "Just Ask AI" Naive Approach

47 / 118
The "Just Ask AI" Naive Approach

48 / 118
Demo - Meta-Strategy for Scripting with AI

49 / 118
Data Types, Operations, Variables
Writing code is about writing text that changes or manipulates data in
some way

50 / 118
Data Types, Operations, Variables
Writing code is about writing text that changes or manipulates data in
some way

For that we need? ..... (drumbroll)

Data! Specifically a way to describe it, reference it, talk about it etc...

51 / 118
Data Types, Operations, Variables
Writing code is about writing text that changes or manipulates data in
some way

For that we need? ..... (drumbroll)

Data! Specifically a way to describe it, reference it, talk about it etc...

In Python data can be of different types (like numbers, text, image etc...)

52 / 118
Data Types, Operations, Variables
Writing code is about writing text that changes or manipulates data in
some way

For that we need? ..... (drumbroll)

Data! Specifically a way to describe it, reference it, talk about it etc...

In Python data can be of different types (like numbers, text, image etc...)

The things we can do to it are called operations (like 5+5)

53 / 118
Data Types, Operations, Variables
Writing code is about writing text that changes or manipulates data in
some way

For that we need? ..... (drumbroll)

Data! Specifically a way to describe it, reference it, talk about it etc...

In Python data can be of different types (like numbers, text, image etc...)

The things we can do to it are called operations (like 5+5)

To organize things, we use variables to define what each thing is

54 / 118
Data Types, Operations, Variables - Example
Here is a piece of code that defines a variable of some type and performs
a simple operation on the data stored in the variable

# This is data of type string!


name = "Lucas"
# This is data of type integer!
actual_age = 33

# This is data of type integer!


mental_age = 12

# our operation
average_age_between_actual_and_mental = (actual_age + mental_age) / 2
# special function that displays what goes inside of it
print(average_age_between_actual_and_mental)

# this would be a float!


# Output: 22.5

55 / 118
Data Types; Operations; Variables - Demo

56 / 118
Data Types, Operations, Variables
Core Data Types:
int: whole nubmers like 1, 2, 3 ...
float: decimal numbers like 1.1, 1.0, etc...
string: text like 'Hello'
bool: logical booleans like True or False

57 / 118
Data Types, Operations, Variables
Core Data Types:
int: whole nubmers like 1, 2, 3 ...
float: decimal numbers like 1.1, 1.0, etc...
string: text like 'Hello'
bool: logical booleans like True or False

Operations:
Arithmetic (+,-,,/,*,//,%)
String concatenation ('Lucas' + ' is' + ' wonderful' = 'Lucas is
wonderful')
Logical operations (and, or, not)
Comparison operations (>, <, >=, <=, ==, !=)

58 / 118
Data Types, Operations, Variables
Core Data Types:
int: whole nubmers like 1, 2, 3 ...
float: decimal numbers like 1.1, 1.0, etc...
string: text like 'Hello'
bool: logical booleans like True or False

Operations:
Arithmetic (+,-,,/,*,//,%)
String concatenation ('Lucas' + ' is' + ' wonderful' = 'Lucas is
wonderful')
Logical operations (and, or, not)
Comparison operations (>, <, >=, <=, ==, !=)

Variables: Storing data for reuse, assigning and reassigning values:

a = 10
b = 20

59 / 118
Functions

60 / 118
Functions
Functions are a way to group code that performs a specific task

61 / 118
Functions
Functions are a way to group code that performs a specific task

Functions can take parameters and return values

62 / 118
Functions
Functions are a way to group code that performs a specific task

Functions can take parameters and return values

For example, a function that calculates the total cost of an item including
tax

63 / 118
Functions
Functions are a way to group code that performs a specific task

Functions can take parameters and return values

For example, a function that calculates the total cost of an item including
tax

We could do this by simply writing a script:

64 / 118
Functions
Functions are a way to group code that performs a specific task

Functions can take parameters and return values

For example, a function that calculates the total cost of an item including
tax

We could do this by simply writing a script:

# Arithmetic operation: multiplication of parameters


tax = price * tax_rate
# Arithmetic operation: addition of variables
total = price + tax

But what if I want to re-use this code for different prices and tax rates?

65 / 118
Functions
Here is what it would look like if we define a function to do this:

def calculate_total(price, tax_rate):


tax = price * tax_rate
total = price + tax
return total

66 / 118
Functions
Here is what it would look like if we define a function to do this:

def calculate_total(price, tax_rate):


tax = price * tax_rate
total = price + tax
return total

Now we can re-use the function for different prices and tax rates:

shirt_price = 10
shirt_tax_rate = 0.05
pants_price = 20
pants_tax_rate = 0.1

print(calculate_total(shirt_price, shirt_tax_rate))
# Output: 10.5
print(calculate_total(pants_price, pants_tax_rate))
# Output: 22.0

67 / 118
Functions
Why Functions?: Reuse code and break tasks into smaller chunks

68 / 118
Functions
Why Functions?: Reuse code and break tasks into smaller chunks

Defining a Function: def function_name(parameters):

69 / 118
Functions
Why Functions?: Reuse code and break tasks into smaller chunks

Defining a Function: def function_name(parameters):

Return Values: Make your functions flexible and reusable

70 / 118
Functions
Why Functions?: Reuse code and break tasks into smaller chunks

Defining a Function: def function_name(parameters):

Return Values: Make your functions flexible and reusable

Best Practices: Keep them short, descriptive, and single-purpose

71 / 118
Demo Functions

72 / 118
Lists & Loops
Lists: Python’s go-to data structure for ordered collections

73 / 118
Lists & Loops
Lists: Python’s go-to data structure for ordered collections

# Define a list of tasks


tasks = ["Buy groceries", "Finish project", "Call the bank"]

Access Elements: Indexing and slicing

74 / 118
Lists & Loops
Lists: Python’s go-to data structure for ordered collections

# Define a list of tasks


tasks = ["Buy groceries", "Finish project", "Call the bank"]

Access Elements: Indexing and slicing

print(tasks[0])
# Output: Buy groceries

print(tasks[1])
# Output: Finish project

75 / 118
Lists & Loops
Lists: Python’s go-to data structure for ordered collections

# Define a list of tasks


tasks = ["Buy groceries", "Finish project", "Call the bank"]

Access Elements: Indexing and slicing

print(tasks[0])
# Output: Buy groceries

print(tasks[1])
# Output: Finish project

Slice: Get a range of elements

76 / 118
Lists & Loops
Lists: Python’s go-to data structure for ordered collections

# Define a list of tasks


tasks = ["Buy groceries", "Finish project", "Call the bank"]

Access Elements: Indexing and slicing

print(tasks[0])
# Output: Buy groceries

print(tasks[1])
# Output: Finish project

Slice: Get a range of elements

print(tasks[0:2])
# Output: ['Buy groceries', 'Finish project']

77 / 118
Lists & Loops
Loops: for loops to iterate over items

78 / 118
Lists & Loops
Loops: for loops to iterate over items

tasks = ["Buy groceries", "Finish project", "Call the bank"]


for task in tasks:
print(task)

79 / 118
Lists & Loops
Loops: for loops to iterate over items

tasks = ["Buy groceries", "Finish project", "Call the bank"]


for task in tasks:
print(task)

Processing List Elements: With for loops we can perform the same
operation on each element of the list

80 / 118
Lists & Loops
Loops: for loops to iterate over items

tasks = ["Buy groceries", "Finish project", "Call the bank"]


for task in tasks:
print(task)

Processing List Elements: With for loops we can perform the same
operation on each element of the list

# Below we use an imaginary function that asks a robot to do a task


for task in tasks:
ask_robot_to_do(task)

81 / 118
Lists & Loops
Loops: for loops to iterate over items

tasks = ["Buy groceries", "Finish project", "Call the bank"]


for task in tasks:
print(task)

Processing List Elements: With for loops we can perform the same
operation on each element of the list

# Below we use an imaginary function that asks a robot to do a task


for task in tasks:
ask_robot_to_do(task)

Common Uses: Batch renaming files in a directory, processing data from


tables, etc...

82 / 118
Demo - Lists & Loops

83 / 118
Dictionaries & Tabular Data
Dictionaries: Key-value pairs for storing related data

84 / 118
Dictionaries & Tabular Data
Dictionaries: Key-value pairs for storing related data

# Dictionary of product prices


prices = {
"apple": 0.50,
"banana": 0.75,
"orange": 0.60
}

85 / 118
Dictionaries & Tabular Data
Dictionaries: Key-value pairs for storing related data

# Dictionary of product prices


prices = {
"apple": 0.50,
"banana": 0.75,
"orange": 0.60
}

Accessing Values: Use keys to lookup values quickly

86 / 118
Dictionaries & Tabular Data
Dictionaries: Key-value pairs for storing related data

# Dictionary of product prices


prices = {
"apple": 0.50,
"banana": 0.75,
"orange": 0.60
}

Accessing Values: Use keys to lookup values quickly

print(prices["apple"])
# Output: 0.50

print(prices["banana"])
# Output: 0.75

87 / 118
Dictionaries & Tabular Data
Dictionaries: Key-value pairs for storing related data

# Dictionary of product prices


prices = {
"apple": 0.50,
"banana": 0.75,
"orange": 0.60
}

Accessing Values: Use keys to lookup values quickly

print(prices["apple"])
# Output: 0.50

print(prices["banana"])
# Output: 0.75

Common Uses: Storing configurations, mapping relationships, caching


data

88 / 118
Reading/Writing
Tabular Data: Data that is organized in a table format

89 / 118
Reading/Writing
Tabular Data: Data that is organized in a table format

Common Formats: .csv, .json, .xlsx, .xls

90 / 118
Reading/Writing
Tabular Data: Data that is organized in a table format

Common Formats: .csv, .json, .xlsx, .xls

CSV Files store data in rows and columns via comma-separated values:
Name,Age,City
John Smith,32,New York
Jane Doe,28,San Francisco

Name Age City

John Smith 32 New York

Jane Doe 28 San Francisco

91 / 118
Demo - Dictionaries & Tabular Data

92 / 118
Comparators & Conditionals
Boolean Comparisons: ==, !=, >, <, >=, <=

93 / 118
Comparators & Conditionals
Boolean Comparisons: ==, !=, >, <, >=, <=

# Example of a boolean comparison


a = 10
b = 20
print(a == b) # Output: False
print(a != b) # Output: True
print(a > b) # Output: False
print(a < b) # Output: True
print(a >= b) # Output: False
print(a <= b) # Output: True

94 / 118
Comparators & Conditionals
Boolean Comparisons: ==, !=, >, <, >=, <=

# Example of a boolean comparison


a = 10
b = 20
print(a == b) # Output: False
print(a != b) # Output: True
print(a > b) # Output: False
print(a < b) # Output: True
print(a >= b) # Output: False
print(a <= b) # Output: True

Logical Operators: and, or, not

95 / 118
Comparators & Conditionals
Boolean Comparisons: ==, !=, >, <, >=, <=

# Example of a boolean comparison


a = 10
b = 20
print(a == b) # Output: False
print(a != b) # Output: True
print(a > b) # Output: False
print(a < b) # Output: True
print(a >= b) # Output: False
print(a <= b) # Output: True

Logical Operators: and, or, not

# Example of a logical operator


print(True and False) # Output: False
print(True or False) # Output: True
print(not True) # Output: False

96 / 118
Comparators & Conditionals
Conditionals: Using conditionals if/elif/else to perform different
actions based on data

97 / 118
Comparators & Conditionals
Conditionals: Using conditionals if/elif/else to perform different
actions based on data

# Example of an if statement
if a > b:
print("a is greater than b")

98 / 118
Comparators & Conditionals
Conditionals: Using conditionals if/elif/else to perform different
actions based on data

# Example of an if statement
if a > b:
print("a is greater than b")

# Example of an if/else statement


if a > b:
print("a is greater than b")
else:
print("a is less than or equal to b")

99 / 118
Comparators & Conditionals
Conditionals: Using conditionals if/elif/else to perform different
actions based on data

# Example of an if statement
if a > b:
print("a is greater than b")

# Example of an if/else statement


if a > b:
print("a is greater than b")
else:
print("a is less than or equal to b")

# Example of an if/elif/else statement


if a > b:
print("a is greater than b")
elif a == b:
print("a is equal to b")
else:
print("a is less than b")

100 / 118
Demo - Working with Data

101 / 118
APIs, Packages, and AI as an API
APIs 101: Application Programming Interface—send a request, get a
response
Python Packages: Example: requests library to make HTTP calls
AI as an API: Connect to services like OpenAI or Claude for text
generation, content analysis, and more

102 / 118
The Ostrich Approach to AI Assistants

103 / 118
Automating Data Extraction
Target Websites or Documents: Identify patterns or structures (tables,
IDs, HTML tags)
Techniques: Using Beautiful Soup, Pandas, or request-response cycles
Practical Examples: Extracting data from a CSV, scraping a simple
webpage for product listings

104 / 118
Automating Basic Data Analysis
Data Loading: Reading CSV files, Excel sheets, or database tables with
Pandas
Basic Analysis: Calculating averages, sums, or finding patterns in data
Visualization: Creating simple charts or graphs to represent findings

105 / 118
Automating Slides
Effective data wrangling for high quality slides
A Hybrid Approach: AI + Python Scripts
Bulk Processing to save time

106 / 118
Automating the Browser
Tools: selenium, playwright
Common Tasks: Logging in to websites, navigating pages, clicking
buttons, scraping dynamic elements
Why Automate Browser Tasks?: Speed up online research, data entry, or
repetitive website interactions

107 / 118
Automating Filling Out Forms
Form Fields: Identifying input boxes, radio buttons, checkboxes in HTML
Scripts: Using selenium to locate elements by ID/class/xpath and input
data
Real-World Use: Automating repetitive website sign-up processes, survey
completion, or internal data-entry forms

108 / 118
AI Hacks
1. Prompt Templates: Keep a library of common prompt structures for
repetitive tasks

109 / 118
AI Hacks
1. Prompt Templates: Keep a library of common prompt structures for
repetitive tasks

2. Chaining Tools: Use AI outputs as inputs to other scripts or services for


multi-step automations

110 / 118
AI Hacks
1. Prompt Templates: Keep a library of common prompt structures for
repetitive tasks

2. Chaining Tools: Use AI outputs as inputs to other scripts or services for


multi-step automations

3. Hybrid Approach: Combine AI text generation with Python logic to


automate tasks like content creation or bulk editing

111 / 118
A System for Writing Your Scripts
Plan: Define the scope and goal of your automation
Prototype: Write a small test script or snippet to handle one core task
Expand: Add new features or handle edge cases incrementally
Refine: Use AI assistance to improve structure, fix bugs, and add clarity

112 / 118
Using AI != Slop

113 / 118
Using AI != Slop
Slop is using unreviewed code from AI models

114 / 118
Using AI != Slop
Slop is using unreviewed code from AI models

115 / 118
Using AI != Slop
Slop is using unreviewed code from AI models

116 / 118
Using AI != Slop
Slop is using unreviewed code from AI models

117 / 118
118 / 118

You might also like