Skip to content

Commit 48d672d

Browse files
authored
Improve wording (#746)
1 parent 88dfd66 commit 48d672d

File tree

2 files changed

+79
-15
lines changed

2 files changed

+79
-15
lines changed

quickstarts/Authentication.ipynb

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@
6868
"\n",
6969
"You can [create](https://aistudio.google.com/app/apikey) your API key using Google AI Studio with a single click. \n",
7070
"\n",
71-
"Remember to treat your API key like a password. Do not accidentally save it in a notebook or source file you later commit to GitHub. This notebook shows you two ways you can securely store your API key.\n",
71+
"Remember to treat your API key like a password. Don't accidentally save it in a notebook or source file you later commit to GitHub. This notebook shows you two ways you can securely store your API key.\n",
7272
"\n",
73-
"* If you are using Google Colab, it is recommended to store your key in Colab Secrets.\n",
73+
"* If you're using Google Colab, it's recommended to store your key in Colab Secrets.\n",
7474
"\n",
75-
"* If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), it is recommended to store your key in an [environment variable](https://en.wikipedia.org/wiki/Environment_variable).\n",
75+
"* If you're using a different development environment (or calling the Gemini API through `cURL` in your terminal), it's recommended to store your key in an [environment variable](https://en.wikipedia.org/wiki/Environment_variable).\n",
7676
"\n",
7777
"Let's start with Colab Secrets."
7878
]
@@ -124,7 +124,7 @@
124124
"source": [
125125
"## Configure the SDK with your API key\n",
126126
"\n",
127-
"You create a client using your API key, but instead of pasting your key into the notebook, you will read it from Colab Secrets thanks to `userdata`."
127+
"You create a client using your API key, but instead of pasting your key into the notebook, you'll read it from Colab Secrets thanks to `userdata`."
128128
]
129129
},
130130
{
@@ -168,7 +168,7 @@
168168
"id": "tr7oAO6-nMsE"
169169
},
170170
"source": [
171-
"And that's it! Now you are ready to call the Gemini API."
171+
"And that's it! Now you're ready to call the Gemini API."
172172
]
173173
},
174174
{
@@ -180,7 +180,71 @@
180180
"outputs": [
181181
{
182182
"data": {
183-
"text/markdown": "Okay, Python provides two main ways to sort a list:\n\n1. **`list.sort()`:** This method sorts the list *in-place*. It modifies the original list and returns `None`.\n2. **`sorted(list)`:** This is a built-in function that returns a *new* sorted list, leaving the original list unchanged.\n\nHere are examples of both:\n\n**1. Using `list.sort()` (Sorts In-Place)**\n\n```python\n# Original list\nmy_list = [3, 1, 4, 1, 5, 9, 2, 6]\n\nprint(f\"Original list: {my_list}\")\n\n# Sort the list in-place (ascending order by default)\nmy_list.sort()\n\nprint(f\"List after my_list.sort(): {my_list}\")\n\n# You can also sort in descending order\nmy_list.sort(reverse=True)\n\nprint(f\"List after my_list.sort(reverse=True): {my_list}\")\n\n# Important: my_list.sort() returns None\nresult = my_list.sort()\nprint(f\"Result of my_list.sort(): {result}\") # This will print None\nprint(f\"List after calling sort() again: {my_list}\") # List is sorted again (ascending this time)\n```\n\n**2. Using `sorted(list)` (Returns a New Sorted List)**\n\n```python\n# Original list\nanother_list = [9, 5, 2, 7, 1, 8, 3, 6]\n\nprint(f\"\\nOriginal list for sorted(): {another_list}\")\n\n# Get a new sorted list (ascending order)\nnew_sorted_list_asc = sorted(another_list)\n\nprint(f\"Original list after sorted(): {another_list}\") # Original list is unchanged\nprint(f\"New sorted list (ascending): {new_sorted_list_asc}\")\n\n# Get a new sorted list (descending order)\nnew_sorted_list_desc = sorted(another_list, reverse=True)\n\nprint(f\"New sorted list (descending): {new_sorted_list_desc}\")\n\n# sorted() also works on other iterables, not just lists\nmy_tuple = (5, 2, 8, 1)\nsorted_tuple_as_list = sorted(my_tuple)\nprint(f\"\\nOriginal tuple: {my_tuple}\")\nprint(f\"Sorted tuple (as list): {sorted_tuple_as_list}\")\n```\n\n**Which one to use?**\n\n* Use `list.sort()` if you don't need the original order of the list and want to modify it directly (often slightly more efficient for lists as it doesn't create a new list).\n* Use `sorted(list)` if you need to keep the original list unchanged or if you are sorting an iterable that is not a list (like a tuple, string, or set).\n\nBoth methods support the `key` argument for custom sorting criteria (e.g., sorting a list of strings by their length, or a list of objects by one of their attributes).",
183+
"text/markdown": [
184+
"Okay, Python provides two main ways to sort a list:\n",
185+
"\n",
186+
"1. **`list.sort()`:** This method sorts the list *in-place*. It modifies the original list and returns `None`.\n",
187+
"2. **`sorted(list)`:** This is a built-in function that returns a *new* sorted list, leaving the original list unchanged.\n",
188+
"\n",
189+
"Here are examples of both:\n",
190+
"\n",
191+
"**1. Using `list.sort()` (Sorts In-Place)**\n",
192+
"\n",
193+
"```python\n",
194+
"# Original list\n",
195+
"my_list = [3, 1, 4, 1, 5, 9, 2, 6]\n",
196+
"\n",
197+
"print(f\"Original list: {my_list}\")\n",
198+
"\n",
199+
"# Sort the list in-place (ascending order by default)\n",
200+
"my_list.sort()\n",
201+
"\n",
202+
"print(f\"List after my_list.sort(): {my_list}\")\n",
203+
"\n",
204+
"# You can also sort in descending order\n",
205+
"my_list.sort(reverse=True)\n",
206+
"\n",
207+
"print(f\"List after my_list.sort(reverse=True): {my_list}\")\n",
208+
"\n",
209+
"# Important: my_list.sort() returns None\n",
210+
"result = my_list.sort()\n",
211+
"print(f\"Result of my_list.sort(): {result}\") # This will print None\n",
212+
"print(f\"List after calling sort() again: {my_list}\") # List is sorted again (ascending this time)\n",
213+
"```\n",
214+
"\n",
215+
"**2. Using `sorted(list)` (Returns a New Sorted List)**\n",
216+
"\n",
217+
"```python\n",
218+
"# Original list\n",
219+
"another_list = [9, 5, 2, 7, 1, 8, 3, 6]\n",
220+
"\n",
221+
"print(f\"\\nOriginal list for sorted(): {another_list}\")\n",
222+
"\n",
223+
"# Get a new sorted list (ascending order)\n",
224+
"new_sorted_list_asc = sorted(another_list)\n",
225+
"\n",
226+
"print(f\"Original list after sorted(): {another_list}\") # Original list is unchanged\n",
227+
"print(f\"New sorted list (ascending): {new_sorted_list_asc}\")\n",
228+
"\n",
229+
"# Get a new sorted list (descending order)\n",
230+
"new_sorted_list_desc = sorted(another_list, reverse=True)\n",
231+
"\n",
232+
"print(f\"New sorted list (descending): {new_sorted_list_desc}\")\n",
233+
"\n",
234+
"# sorted() also works on other iterables, not just lists\n",
235+
"my_tuple = (5, 2, 8, 1)\n",
236+
"sorted_tuple_as_list = sorted(my_tuple)\n",
237+
"print(f\"\\nOriginal tuple: {my_tuple}\")\n",
238+
"print(f\"Sorted tuple (as list): {sorted_tuple_as_list}\")\n",
239+
"```\n",
240+
"\n",
241+
"**Which one to use?**\n",
242+
"\n",
243+
"* Use `list.sort()` if you don't need the original order of the list and want to modify it directly (often slightly more efficient for lists as it doesn't create a new list).\n",
244+
"* Use `sorted(list)` if you need to keep the original list unchanged or if you are sorting an iterable that is not a list (like a tuple, string, or set).\n",
245+
"\n",
246+
"Both methods support the `key` argument for custom sorting criteria (e.g., sorting a list of strings by their length, or a list of objects by one of their attributes)."
247+
],
184248
"text/plain": [
185249
"<IPython.core.display.Markdown object>"
186250
]
@@ -215,26 +279,26 @@
215279
"id": "gZDX51Y27pN4"
216280
},
217281
"source": [
218-
"If you are using a different development environment (or calling the Gemini API through `cURL` in your terminal), it is recommended to store your key in an environment variable.\n",
282+
"If you're using a different development environment (or calling the Gemini API through `cURL` in your terminal), it's recommended to store your key in an environment variable.\n",
219283
"\n",
220284
"To store your key in an environment variable, open your terminal and run:\n",
221285
"\n",
222286
"```export GOOGLE_API_KEY=\"YOUR_API_KEY\"```\n",
223287
"\n",
224-
"If you are using Python, you can add these two lines to your notebook to read the key:\n",
288+
"If you're using Python, you can add these two lines to your notebook to read the key:\n",
225289
"\n",
226290
"```\n",
227291
"import os\n",
228292
"client = genai.Client(api_key=os.environ['GOOGLE_API_KEY'])\n",
229293
"```\n",
230294
"\n",
231-
"Alternatively, if it is not provided explicitly, the client will look for the API key.\n",
295+
"Alternatively, if it isn't provided explicitly, the client will look for the API key.\n",
232296
"\n",
233297
"```\n",
234298
"client = genai.Client()\n",
235299
"```\n",
236300
"\n",
237-
"Or, if you are calling the API through your terminal using `cURL`, you can copy and paste this code to read your key from the environment variable.\n",
301+
"Or, if you're calling the API through your terminal using `cURL`, you can copy and paste this code to read your key from the environment variable.\n",
238302
"\n",
239303
"```\n",
240304
"curl \"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GOOGLE_API_KEY\" \\\n",
@@ -258,7 +322,7 @@
258322
"source": [
259323
"## Learning more\n",
260324
"\n",
261-
"Now that you know how to manage your API key, you have everything to [get started](./Get_started.ipynb) with Gemini. Check all the [quickstart guides](https://github.com/google-gemini/cookbook/tree/main/quickstarts) from the Cookbook, and in particular the [Get started](./Get_started.ipynb) one."
325+
"Now that you know how to manage your API key, you've everything to [get started](./Get_started.ipynb) with Gemini. Check all the [quickstart guides](https://github.com/google-gemini/cookbook/tree/main/quickstarts) from the Cookbook, and in particular the [Get started](./Get_started.ipynb) one."
262326
]
263327
}
264328
],

quickstarts/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
This folder contains guides to help you explore all Gemini API features using complete end-to-end code examples.
44

5-
When you are confident in your Gemini capabilities, the [examples](https://github.com/google-gemini/cookbook/tree/main/examples/) folder will be an endless source of inspiration on how to mix those capabilities together.
5+
When you're confident in your Gemini capabilities, the [examples](https://github.com/google-gemini/cookbook/tree/main/examples/) folder will be an endless source of inspiration on how to mix those capabilities together.
66
<br><br>
77

88
## Table of contents
99

10-
If you are new to Gemini API, you should start with these two guides:
10+
If you're new to Gemini API, you should start with these two guides:
1111
1. [Authentication](./Authentication.ipynb): Start here to learn how you can set up your API key so you can get access to the Gemini API.
1212
2. [Get Started](./Get_started.ipynb): Learn how to make your first calls to the Gemini API and get a quick overview of everything it can do.
1313
<br><br>
@@ -21,7 +21,7 @@ Then learn about how to **Get Started** with the other models that you can use w
2121
<br><br>
2222

2323

24-
There are multiple ways to call the models using the Gemini API, these other **Get Started** guides will then show you the other ways to call the model:
24+
There're multiple ways to call the models using the Gemini API, these other **Get Started** guides will then show you the other ways to call the model:
2525
* [Get started with Live API](./Get_started_LiveAPI.ipynb): Get started with the live API with this comprehensive overview of its capabilities
2626
* More to come...
2727
<br><br>
@@ -38,7 +38,7 @@ Finally, these guides will deep-dive into specific capabilities of the Gemini mo
3838

3939
These guides will walk you through the various use cases of the Gemini API:
4040
* [Asynchronous requests](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Asynchronous_requests.ipynb): Learn how to use Python's async/await API with the Gemini SDK to parallelize calls.
41-
* [Counting Tokens](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Counting_Tokens.ipynb) Tokens are the basic inputs to the Gemini models. Through this notebook, you will gain a better understanding of tokens through an interactive experience.
41+
* [Counting Tokens](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Counting_Tokens.ipynb) Tokens are the basic inputs to the Gemini models. Through this notebook, you'll gain a better understanding of tokens through an interactive experience.
4242
* [Gemini Flash Introduction](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Gemini_Flash_Introduction.ipynb): Get started with Gemini Flash 2.0.
4343
* [Models](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Models.ipynb): Learn about the different models and parameters available in the Gemini API.
4444
* [Working with files](https://github.com/google-gemini/cookbook/blob/main/quickstarts/File_API.ipynb): Use the Gemini API to upload files (audio, video, images, code, text) and perform actions with them through the Gemini models.

0 commit comments

Comments
 (0)