1 Introduction
it is believed that with the help of AI chatbot we can learn python more easily and it will be amazing to automate tasks using Python
2 Completing a task list with AI
2.1 List
①list is a single variable of type that holds multiple values
②len() will show how many values are stored in the list
③you can access any element by choose the right index number
④ you can add/remove another element into it by using append()/remove()
3 Repeating tasks with for loops
①
Let's break this down.
The
for task in list
pattern works as follows:
task
is assigned the first item in the list. In this case, it's the string"Compose a brief email to my boss explaining that I will be late for tomorrow's meeting."
- The next indented line is called a block and contains an action to carry out on
task
. In this example, the string gets passed to the LLM, and the result appears on the screen.- Then the loop starts again. Now,
task
is assigned the string "Write a birthday poem for Otto, celebrating his 28th birthday." It's the same variable, but with a different value.get_llm_response
runs again, and so on.Be sure to call out the
:
at the end of the line. Indentation is crucial; if it’s not correct, you'll get an error.②
③there will be different if the codes do not be indented one level
P.S.if there is a list with 5 values and I want to print the first three values and there is no interspace between the result printed ,can I use for loops?
4 Prioritizing tasks with dictionaries and AI
4.1 Dictionaries
①to access the values in the dictionary you need to use its keys or you can use values() to see all of it.
② to add a new item for the "Rocky Road"
flavor, you will need to assign its definition to ice_cream_flavors["Rocky Road"]
as follows:(You can update existing dictionary items in a similar way)
③it is okey that you store different types of elements or lists in dictionary
④ a example with the use of list and dictionary
5 Customizing recipes with lists,dictionaries and AI
it is more about using the previous knowledge to get a recipe for yourself
6 Comparing data in Python
6.1 boolean
①it is okey to use boolean valuse in dictionary
6.2 Comparison Operators
# Assume ages are given
isabel_age = 25
tommy_age = 22
daniel_age = 27
### EDITED CODE ###
is_isabel_older_than_tommy = isabel_age > tommy_age
is_isabel_older_than_daniel = isabel_age > daniel_age
### --------------- ###
### EDITED CODE ###
# Using the logical operator "or" to check if Isabel is older than at least one friend
print("Check if Isabel is older than at least one of my friends:", is_isabel_older_than_tommy or is_isabel_older_than_daniel)
### --------------- ###
7 Helping AI make decisions
from helper_functions import print_llm_response
task_list = [
{
"description": "Compose a brief email to my boss explaining that I will be late for next week's meeting.",
"time_to_complete": 3
},
{
"description": "Create an outline for a presentation on the benefits of remote work.",
"time_to_complete": 60
},
{
"description": "Write a 300-word review of the movie 'The Arrival'.",
"time_to_complete": 30
},
{
"description": "Create a shopping list for tofu and olive stir fry.",
"time_to_complete": 5
}
]
task = task_list[0]
print(task)
task["time_to_complete"] <= 5
if task["time_to_complete"] <= 5:
task_to_do = task["description"]
print_llm_response(task_to_do)
8 Next course preview:working with files
try to use AI in python to highlight the data in files
from helper_functions import *
journal = read_journal("journal_entries/cape_town.txt")
print(journal)
prompt = f"""
Given the following journal entry from a food critic, identify the restaurants and their specialties.
For each restaurant, highlight its name and specialties in bold and use different colors for each.
Provide the output as HTML suitable for display in a Jupyter notebook.
Journal entry:
{journal}
"""
html_response = get_llm_response(prompt)
display_html(html_response)
学习网站:
https://learn.deeplearning.ai/courses/ai-python-for-beginners-c2/lesson/1/introduction
标签:吴恩达,task,AI,study,list,use,isabel,### From: https://blog.csdn.net/2302_77608969/article/details/141110964