1 Using Files in Python
1 Using Files in Python
Hit the play button on the video next to this Jupyter notebook to start the video and follow
along as Andrew explains how to work through this lesson.
You have worked with data that is created and assigned to variables within Jupyter notebooks.
You have created multi-line strings.
You have created lists and dictionaries.
You have automated tasks using for loops and if statements.
In this lesson, you will read files using Python!
Entrée [ ]:
Start by loading an email that Daniel sent recently. It is stored in a '.txt' file.
Entrée [ ]:
f = open("email.txt", "r")
email = f.read()
f.close()
Print what it is 'inside' the email ✉️.
Entrée [ ]:
print(email)
🤖 Use the Chatbot:
f = open("email.txt", "r")
email = f.read()
f.close()
Email:
{email}"""
print(prompt)
Run the get_llm_response function to get the response with bullet points.
Entrée [ ]:
bullet_points = get_llm_response(prompt)
print(bullet_points)
Print the LLM response in Markdown format.
Entrée [ ]:
Exercise 1
Complete the code below to identify all the countries mentioned in the email.
Entrée [ ]:
Email:
{email}
"""
countries = get_llm_response(prompt)
print(countries)
Exercise 2
Write code below to list all of the activities that Daniel did on his trip. You'll need to create a
prompt and use either get_llm_response or print_llm_response.
Entrée [ ]:
# Write code below to list all of the activities that Daniel did on
# his trip. You'll need to create a prompt and use either
# get_llm_response or print_llm_response
# START YOUR CODE HERE