{"appState":{"pageLoadApiCallsStatus":true},"categoryState":{"relatedCategories":{"headers":{"timestamp":"2024-11-01T08:01:06+00:00"},"categoryId":33512,"data":{"title":"Technology","slug":"technology","image":{"src":"https://www.dummies.com/wp-content/uploads/technology-category.jpg","width":643,"height":1286},"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512}],"parentCategory":{"categoryId":0,"title":null,"slug":null,"_links":null},"childCategories":[{"categoryId":35241,"title":"Virtual Reality","slug":"virtual-reality","_links":{"self":"https://dummies-api.dummies.com/v2/categories/35241"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":5,"bookCount":2},{"categoryId":33513,"title":"Computers","slug":"computers","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33513"},"image":{"src":"/img/background-image-1.daf74cf0.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":1392,"bookCount":56},{"categoryId":33537,"title":"Cybersecurity","slug":"cybersecurity","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33537"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":59,"bookCount":14},{"categoryId":33538,"title":"Digital Audio & Radio","slug":"digital-audio-radio","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33538"},"image":{"src":"/img/background-image-1.daf74cf0.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":131,"bookCount":5},{"categoryId":33543,"title":"Electronics","slug":"electronics","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33543"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":1756,"bookCount":46},{"categoryId":33572,"title":"Information Technology","slug":"information-technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33572"},"image":{"src":"/img/background-image-1.daf74cf0.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":812,"bookCount":68},{"categoryId":33587,"title":"Internet Basics","slug":"internet-basics","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33587"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":86,"bookCount":3},{"categoryId":33588,"title":"Notable Websites","slug":"notable-websites","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33588"},"image":{"src":"/img/background-image-1.daf74cf0.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":188,"bookCount":4},{"categoryId":33592,"title":"Programming & Web Design","slug":"programming-web-design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":1395,"bookCount":99},{"categoryId":33611,"title":"Social Media","slug":"social-media","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33611"},"image":{"src":"/img/background-image-1.daf74cf0.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":385,"bookCount":20},{"categoryId":33618,"title":"Software","slug":"software","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33618"},"image":{"src":"/img/background-image-2.fabfbd5c.png","width":0,"height":0},"hasArticle":true,"hasBook":true,"articleCount":3194,"bookCount":187}],"description":"Technology. It makes the world go 'round. And whether you're a self-confessed techie or a total newbie, you'll find something to love among our hundreds of technology articles and books.","relatedArticles":{"self":"https://dummies-api.dummies.com/v2/articles?category=33512&offset=0&size=5"},"hasArticle":true,"hasBook":true,"articleCount":9404,"bookCount":504},"_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"}},"relatedCategoriesLoadedStatus":"success"},"listState":{"list":{"count":10,"total":9423,"items":[{"headers":{"creationTime":"2019-10-09T22:32:15+00:00","modifiedTime":"2024-10-28T20:21:54+00:00","timestamp":"2024-10-28T21:01:27+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"Python","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33606"},"slug":"python","categoryId":33606}],"title":"How to Define and Use Python Lists","strippedTitle":"how to define and use python lists","slug":"how-to-define-and-use-python-lists","canonicalUrl":"","seo":{"metaDescription":"Use this guide from Dummies.com to learn how to define and use Python lists. This Python tutorial helps you make the most of your Python lists.","noIndex":0,"noFollow":0},"content":"The simplest data collection in <a href=\"https://www.dummies.com/programming/python/python-all-in-one-for-dummies-cheat-sheet/\">Python</a> is a list. A <em>list</em> is any list of data items, separated by commas, inside square brackets. Typically, you assign a name to the Python list using an = sign, just as you would with variables. If the list contains numbers, then don't use quotation marks around them. For example, here is a list of test scores:\r\n<pre class=\"code\">scores = [88, 92, 78, 90, 98, 84]</pre>\r\nIf the list contains strings then, as always, those strings should be enclosed in single or double quotation marks, as in this example:\r\n\r\nTo display the contents of a list on the screen, you can print it just as you would print any regular variable. For example, executing <code>print(students)</code> in your code after defining that list shows this on the screen.\r\n<pre class=\"code\">['Mark', 'Amber', 'Todd', 'Anita', 'Sandy']</pre>\r\nThis may not be exactly what you had in mind. But don’t worry, Python offers lots of great ways to access data in lists and display it however you like.\r\n<h2 id=\"tab1\" >Referencing Python list items by position</h2>\r\nEach item in a list has a position number, starting with zero, even though you don’t see any numbers. You can refer to any item in the list by its number using the name for the list followed by a number in square brackets. In other words, use this syntax:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;[&lt;em&gt;x&lt;/em&gt;]\r\n\r\nReplace &lt;em&gt;&lt;code&gt;listname&lt;/code&gt;&lt;/em&gt; with the name of the list you're accessing and replace &lt;em&gt;&lt;code&gt;x&lt;/code&gt;&lt;/em&gt; with the position number of item you want. Remember, the first item is always number zero, not one. For example, in the first line below, I define a list named &lt;code&gt;students&lt;/code&gt;, and then print item number zero from that list. The result, when executing the code, is that the name &lt;code&gt;Mark&lt;/code&gt; is displayed.</pre>\r\n<pre class=\"code\">students = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nprint(students[0])\r\nMark</pre>\r\n<technicalstuff>\r\n\r\nWhen reading access list items, professionals use the word <em>sub</em> before the number. For example, <em>students[0]</em> would be spoken as <em>students sub zero</em>.\r\n\r\nThis next example shows a list named <code>scores</code>. The <code>print()</code> function prints the position number of the last score in the list, which is 4 (because the first one is always zero).\r\n<pre class=\"code\">scores = [88, 92, 78, 90, 84]\r\nprint(scores[4])\r\n84</pre>\r\nIf you try to access a list item that doesn't exist, you get an “index out of range” error. The <em>index</em> part is a reference to the number inside the square brackets. For example, the image below shows a little experiment in a <a href=\"https://www.dummies.com/programming/python/tips-for-using-jupyter-notebook-for-python-programming/\">Jupyter notebook</a> where a list of scores was created and then the printing of <code>score[5]</code> was attempted.\r\n\r\nIt failed and generated an error because there is no <code>scores[5]</code>. There's only <code>scores[0]</code>, <code>scores[1]</code>, <code>scores[2]</code>, <code>scores[3]</code>, and <code>scores[4]</code> because the counting always starts at zero with the first one on the list.\r\n\r\n[caption id=\"attachment_264920\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264920 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-index-range.jpg\" alt=\"Python index range\" width=\"535\" height=\"212\" /> Index out of range error because there is no scores[5].[/caption] \r\n<h2 id=\"tab2\" >Looping through a Python list</h2>\r\nTo access each item in a list, just use a for loop with this syntax:\r\n<pre class=\"code\">for &lt;em&gt;x&lt;/em&gt; in &lt;em&gt;list&lt;/em&gt;:</pre>\r\nReplace <em<code>&gt;x</code> with a variable name of your choosing. Replace <em><code>list</code></em> with the name of the list. An easy way to make the code readable is to always use a plural for the list name (such as <code>students</code>, <code>scores</code>). Then you can use the singular name (<code>student</code>, <code>score</code>) for the variable name. You don't need to use subscript numbers (numbers in square brackets) with this approach either. For example, the following code prints each score in the scores list:\r\n<pre class=\"code\">for score in scores:\r\nprint(score)</pre>\r\nRemember to always indent the code that’s to be executed within the loop. This image shows a more complete example where you can see the result of running the code in a Jupyter notebook.\r\n\r\n[caption id=\"attachment_264921\" align=\"aligncenter\" width=\"262\"]<img class=\"wp-image-264921 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-loop-list.jpg\" alt=\"Looping through a Python list\" width=\"262\" height=\"219\" /> Looping through a list.[/caption]\r\n\r\n \r\n<h2 id=\"tab3\" >Seeing whether a Python list contains an item</h2>\r\nIf you want your code to check the contents of a list to see whether it already contains some item, use <code>in &lt;em&gt;listname&lt;/em&gt;</code> in an <code>if</code> statement or a variable assignment.\r\n\r\nFor example, the code in the image below creates a list of names. Then, two variables store the results of searching the list for the names <em>Anita</em> and <em>Bob</em>. Printing the contents of each variable shows True for the one where the name (Anita) is in the list. The test to see whether Bob is in the list proves False.\r\n\r\n[caption id=\"attachment_264922\" align=\"aligncenter\" width=\"460\"]<img class=\"wp-image-264922 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-list-contain.jpg\" alt=\"Seeing whether an item is in a Python list\" width=\"460\" height=\"244\" /> Seeing whether an item is in a list.[/caption]\r\n\r\n \r\n<h2 id=\"tab4\" >Getting the length of a Python list</h2>\r\nTo determine how many items are in a list, use the <code>len()</code> function (short for <em>length</em>). Put the name of the list inside the parentheses. For example, type the following code into a Jupyter notebook or Python prompt or whatever:\r\n<pre class=\"code\">students = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nprint(len(students))</pre>\r\nRunning that code produces this output:\r\n<pre class=\"code\">5</pre>\r\nThere are indeed five items in the list, though the last one is always one less than the number because Python starts counting at zero. So the last one, Sandy, actually refers to students[4] and not students[5].\r\n<h2 id=\"tab5\" >Appending an item to the end of a Python list</h2>\r\nWhen you want your Python code to add a new item to the end of a list, use the <code>.append()</code> method with the value you want to add inside the parentheses. You can use either a variable name or a literal value inside the quotation marks.\r\n\r\nFor instance, in the following image the line that reads <code>students.append(\"Goober\")</code> adds the name Goober to the list. The line that reads <code>students.append(new_student)</code> adds whatever name is stored in the variable named <code>new_student</code> to the list. The <code>.append()</code> method always adds to the end of the list. So when you print the list you see those two new names at the end.\r\n\r\n[caption id=\"attachment_264923\" align=\"aligncenter\" width=\"533\"]<img class=\"wp-image-264923 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-append-list.jpg\" alt=\"Python append list\" width=\"533\" height=\"272\" /> Appending two new names to the end of the list.[/caption]\r\n\r\n \r\n\r\nYou can use a test to see whether an item is in a list and then append it only when the item isn't already there. For example, the code below won’t add the name Amber to the list because that name is already in the list:\r\n<pre class=\"code\">student_name = \"Amanda\"\r\n\r\n#Add student_name but only if not already in the list.\r\nif student_name in students:\r\n print (student_name + \" already in the list\")\r\nelse: \r\n students.append(student_name)\r\n print (student_name + \" added to the list\")</pre>\r\n<h2 id=\"tab6\" >Inserting an item into a Python list</h2>\r\nAlthough the <code>append()</code> method allows you to add an item to the end of a list, the <code>insert()</code> method allows you to add an item to the list in any position. The syntax for <code>insert()</code> is\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.insert(&lt;em&gt;position&lt;/em&gt;, &lt;em&gt;item&lt;/em&gt;)</pre>\r\nReplace <em>listname</em> with the name of the list, <em>position</em> with the position at which you want to insert the item (for example, 0 to make it the first item, 1 to make it the second item, and so forth). Replace <em>item</em> with the value, or the name of a variable that contains the value, that you want to put into the list.\r\n\r\nFor example, the following code makes Lupe the first item in the list:\r\n<pre class=\"code\">#Create a list of strings (names).\r\nstudents = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\n\r\nstudent_name = \"Lupe\"\r\n# Add student name to front of the list.\r\nstudents.insert(0,student_name)\r\n\r\n#Show me the new list.\r\nprint(students)</pre>\r\nIf you run the code, <code>print(students)</code> will show the list after the new name has been inserted, as follows:\r\n<pre class=\"code\">['Lupe', 'Mark', 'Amber', 'Todd', 'Anita', 'Sandy']</pre>\r\n<h2 id=\"tab7\" >Changing an item in a Python list</h2>\r\nYou can change an item in a list using the = assignment operator (check out these <a href=\"https://www.dummies.com/programming/python/common-python-operators/\">common Python operators</a>) just like you do with variables. Just make sure you include the index number in square brackets of the item you want to change. The syntax is:\r\n\r\n<em>listname</em>[<em>index</em>]=<em>newvalue</em>\r\n\r\nReplace <em><code>listname</code></em> with the name of the list; replace <em><code>index</code></em> with the subscript (index number) of the item you want to change; and replace <em><code>newvalue</code></em> with whatever you want to put in the list item. For example, take a look at this code:\r\n<pre class=\"code\">#Create a list of strings (names).\r\nstudents = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nstudents[3] = \"Hobart\"\r\nprint(students)</pre>\r\nWhen you run this code, the output is as follows, because Anita's name has been changed to Hobart.\r\n<pre class=\"code\">['Mark', 'Amber', 'Todd', 'Hobart', 'Sandy']</pre>\r\n<h2 id=\"tab8\" >Combining Python lists</h2>\r\nIf you have two lists that you want to combine into a single list, use the <code>extend()</code> function with the syntax:\r\n<pre class=\"code\">&lt;em&gt;original_list&lt;/em&gt;.extend(&lt;em&gt;additional_items_list&lt;/em&gt;)</pre>\r\nIn your code, replace <em>original_list</em> with the name of the list to which you’ll be adding new list items. Replace <em>additional_items_list</em> with the name of the list that contains the items you want to add to the first list. Here is a simple example using lists named <code>list1</code> and <code>list2</code>. After executing <code>list1.extend(list2)</code>, the first list contains the items from both lists, as you can see in the output of the <code>print()</code> statement at the end.\r\n<pre class=\"code\"># Create two lists of Names.\r\nlist1 = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\nlist2 = [\"Huey\", \"Dewey\", \"Louie\", \"Nader\", \"Bubba\"]\r\n\r\n# Add list2 names to list1.\r\nlist1.extend(list2)\r\n\r\n# Print list 1.\r\nprint(list1)\r\n\r\n['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake', 'Huey', 'Dewey', 'Louie', 'Nader', 'Bubba']</pre>\r\nEasy Parcheesi, no?\r\n<h2 id=\"tab9\" >Removing Python list items</h2>\r\nPython offers a <code>remove()</code> method so you can remove any value from the list. If the item is in the list multiple times, only the first occurrence is removed. For example, the following code shows a list of letters with the letter <em>C</em> repeated a few times. Then the code uses <code>letters.remove(\"C\")</code> to remove the letter <em>C</em> from the list:\r\n<pre class=\"code\"># Remove \"C\" from the list.\r\nletters.remove(\"C\")\r\n\r\n#Show me the new list.\r\nprint(letters)</pre>\r\nWhen you actually execute this code and then print the list, you'll see that only the first letter <em>C</em> has been removed:\r\n<pre class=\"code\">['A', 'B', 'D', 'C', 'E', 'C']</pre>\r\nIf you need to remove all of an item, you can use a <code>while</code> loop to repeat the <code>.remove</code> as long as the item still remains in the list. For example, this code repeats the .remove as long as the “C” is still in the list.\r\n<pre class=\"code\">#Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"C\", \"E\", \"C\"]</pre>\r\nIf you want to remove an item based on its position in the list, use <code>pop()</code> with an index number rather than <code>remove()</code> with a value. If you want to remove the last item from the list, use <code>pop()</code> without an index number.\r\n\r\nFor example, the following code creates a list, one line removes the first item (0), and another removes the last item <code>(pop()</code> with nothing in the parentheses). Printing the list shows those two items have been removed:\r\n<pre class=\"code\">#Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n#Remove the first item.\r\nletters.pop(0)\r\n#Remove the last item.\r\nletters.pop()\r\n \r\n#Show me the new list.\r\nprint(letters)</pre>\r\nRunning the code shows that the popping the first and last items did, indeed, work:\r\n<pre class=\"code\">['B', 'C', 'D', 'E', 'F']</pre>\r\nWhen you <code>pop()</code> an item off the list, you can store a copy of that value in some variable. For example this image shows the same code as above. However, it stores copies of what's been removed in variables named <code>first_removed</code> and <code>last_removed</code>. At the end it <a href=\"https://www.dummies.com/programming/python/printing-lists-using-python/\">prints the Python list</a>, and also shows which letters were removed.\r\n\r\n[caption id=\"attachment_264924\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264924 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-remove-list-item.jpg\" alt=\"remove items from Python list\" width=\"535\" height=\"231\" /> Removing list items with pop().[/caption]\r\n\r\nPython also offers a <code>del</code> (short for <em>delete</em>) command that deletes any item from a list based on its index number (position). But again, you have to remember that the first item is zero. So, let's say you run the following code to delete item number 2 from the list:\r\n<pre class=\"code\"># Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n# Remove item sub 2.\r\ndel letters[2]\r\n \r\nprint(letters)</pre>\r\nRunning that code shows the list again, as follows. The letter <em>C</em> has been deleted, which is the correct item to delete because letters are numbered 0, 1, 2, 3, and so forth.\r\n<pre class=\"code\">['A', 'B', 'D', 'E', 'F', 'G']</pre>\r\nYou can also use del to delete an entire list. Just don’t use the square brackets and the index number. For example, the code you see below creates a list then deletes it. Trying to print the list after the deletion causes an error, because the list no longer exists when the <code>print()</code> statement is executed.\r\n\r\n[caption id=\"attachment_264925\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264925 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-delete-list.jpg\" alt=\"delete Python list\" width=\"535\" height=\"273\" /> Deleting a list and then trying to print it causes an error.[/caption]\r\n\r\n \r\n<h2 id=\"tab10\" >Clearing out a Python list</h2>\r\nIf you want to delete the contents of a list but not the list itself, use <code>.clear()</code>. The list still exists; however, it contains no items. In other words, it's an empty list. The following code shows how you could test this. Running the code displays [] at the end, which lets you know the list is empty:\r\n<pre class=\"code\"># Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n# Clear the list of all entries.\r\nletters.clear()\r\n \r\n# Show me the new list.\r\nprint(letters)\r\n</pre>\r\n\r\n<h2 id=\"tab11\" >Counting how many times an item appears in a Python list</h2>\r\nYou can use the Python <code>count()</code> method to count how many times an item appears in a list. As with other list methods, the syntax is simple:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.count(&lt;em&gt;x&lt;/em&gt;)</pre>\r\nReplace <em>listname</em> with the name of your list, and <em>x</em> with the value you're looking for (or the name of a variable that contains that value).\r\n\r\nThe code in the image below counts how many times the letter <em>B</em> appears in the list, using a literal B inside the parentheses of <code>.count()</code>. This same code also counts the number of <em>C</em> grades, but that value was stored in a variable just to show the difference in syntax. Both counts worked, as you can see in the output of the program at the bottom. One was added to count the <em>F</em>'s, not using any variables. The <em>F</em>’s were counted right in the code that displays the message. There are no <em>F</em> grades, so this returns zero, as you can see in the output.\r\n\r\n[caption id=\"attachment_264926\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264926 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-count-list-item.jpg\" alt=\"count Python list items\" width=\"535\" height=\"296\" /> Counting items in a list.[/caption]\r\n\r\nWhen trying to combine numbers and strings to form a message, remember you have to convert the numbers to strings using the <code>str()</code> function. Otherwise, you get an error that reads something like can only <code>concatenate str (not \"int\") to str</code>. In that message, <code>int</code> is short for <em>integer</em>, and <code>str</code> is short for <em>string</em>.\r\n<h2 id=\"tab12\" >Finding a Python list item's index</h2>\r\nPython offers an .index() method that returns a number indicating the position, based on index number, of an item in a list. The syntax is:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.index(&lt;em&gt;x&lt;/em&gt;)</pre>\r\nAs always, replace <em><code>listname</code></em> with name of the list you want to search. Replace <em>x</em> what whatever you're looking for (either as a literal or as a variable name, as always). Of course, there’s no guarantee that the item is in the list, and even if it is, there’s no guarantee that the item is in the list only once. If the item isn’t in the list, then an error occurs. If the item is in the list multiple times, then the index of the first matching item is returned.\r\n\r\nThe following image shows an example where the program crashes at the line <code>f_index = grades.index(look_for)</code> because there is no <em>F</em> in the list.\r\n\r\n[caption id=\"attachment_264927\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264927 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-list-iem-index.jpg\" alt=\"Python list item index\" width=\"535\" height=\"374\" /> Program fails when trying to find index of a nonexistent list item.[/caption]\r\n\r\n \r\n\r\nAn easy way to get around that problem is to use an <code>if</code> statement to see whether an item is in the list before you try to get its index number. If the item isn't in the list, display a message saying so. Otherwise, get the index number and show it in a message. That code is as follows:\r\n<pre class=\"code\"># Create a list of strings.\r\ngrades = [\"C\", \"B\", \"A\", \"D\", \"C\", \"B\", \"C\"]\r\n# Decide what to look for\r\nlook_for = \"F\"\r\n# See if the item is in the list.\r\nif look_for in grades:\r\n # If it's in the list, get and show the index.\r\n print(str(look_for) + \" is at index \" + str(grades.index(look_for)))\r\nelse:\r\n # If not in the list, don't even try for index number.\r\n print(str(look_for) + \" isn't in the list.\")</pre>\r\n<h2 id=\"tab13\" >Alphabetizing and sorting Python lists</h2>\r\nPython offers a <code>sort()</code> method for sorting lists. In its simplest form, it alphabetizes the items in the list (if they’re strings). If the list contains numbers, they’re sorted smallest to largest. For a simple sort like that, just use <code>sort()</code> with empty parentheses:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.sort()</pre>\r\nReplace <em><code>listname</code></em> with the name of your list. The following image shows an example using a list of strings and a list of numbers. In the example, a new list was created for each of them simply by assigning each sorted list to a new list name. Then the code prints the contents of each sorted list.\r\n\r\n[caption id=\"attachment_264928\" align=\"aligncenter\" width=\"496\"]<img class=\"wp-image-264928 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-sort-list.jpg\" alt=\"sort Python list\" width=\"496\" height=\"296\" /> Sorting strings and numbers.[/caption]\r\n\r\n \r\n\r\nIf your list contains strings with a mixture of uppercase and lowercase letters, and if the results of the sort don't look right, try replacing <code>.sort()</code> with <code>.sort(key=lambda s:s.lower())</code> and then running the code again.\r\n\r\nDates are a little trickier because you can’t just type them in as strings, like <code>\"12/31/2020\"</code>. They have to be the <code>date</code> data type to sort correctly. This means using the <code>datetime</code> module and the <code>date()</code> method to define each date. You can add the dates to the list as you would any other list. For example, in the following line, the code creates a list of four dates, and the code is perfectly fine.\r\n<pre class=\"code\">dates = [dt.date(2020,12,31), dt.date(2019,1,31), dt.date(2018,2,28), dt.date(2020,1,1)]</pre>\r\nThe computer certainly won't mind if you create the list this way. But if you want to make the code more readable to yourself or other developers, you may want to create and append each date, one at a time, so just so it’s a little easier to see what’s going on and so you don’t have to deal with so many commas in one line of code. The image below shows an example where an empty list named <code>datelist</code> was created:\r\n<pre class=\"code\">datelist = []</pre>\r\n[caption id=\"attachment_264929\" align=\"aligncenter\" width=\"481\"]<img class=\"wp-image-264929 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-display-dates.jpg\" alt=\"display dates in Python\" width=\"481\" height=\"353\" /> Sorting and displaying dates in a nice format.[/caption]\r\n\r\n \r\n\r\nThen one date at a time was appended to the list using the <code>dt.date(&lt;em&gt;year&lt;/em&gt;,&lt;em&gt;month&lt;/em&gt;,&lt;em&gt;day&lt;/em&gt;)</code> syntax.\r\n\r\nAfter the list is created, the code uses <code>datelist.sort()</code> to sort them into chronological order (earliest to latest). You don’t need to use <code>print(datelist)</code> in that code because that method displays the dates with the data type information included, like this:\r\n<pre class=\"code\">[datetime.date(2018, 2, 28), datetime.date(2019, 1, 31), datetime.date (2020, 1, 1), datetime.date(2020, 12, 31)]</pre>\r\nNot the easiest list to read. So, rather than print the whole list with one <code>print()</code> statement, you can loop through each date in the list, and printed each one formatted with the f-string <code>%m/%d/%Y</code>. This displays each date on its own line in <em>mm/dd/yyyy</</em> format, as you can see at the bottom of the image above.\r\n\r\nIf you want to sort items in reverse order, put <code>reverse=True</code> inside the sort() parentheses (and don't forget to make the first letter uppercase). The image below shows examples of sorting all three lists in descending (reverse) order using <code>reverse=True</code>.\r\n\r\n[caption id=\"attachment_264930\" align=\"aligncenter\" width=\"403\"]<img class=\"wp-image-264930 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-sort-info-reverse.jpg\" alt=\"sort info in Python list in reverse\" width=\"403\" height=\"450\" /> Sorting strings, numbers, and dates in reverse order.[/caption]\r\n\r\n \r\n<h2 id=\"tab14\" >Reversing a Python list</h2>\r\nYou can also reverse the order of items in a list using the <code>.reverse</code> method. This is not the same as sorting in reverse, because when you sort in reverse, you still actually sort: Z–A for strings, largest to smallest for numbers, latest to earliest for dates. When you reverse a list, you simply reverse the items in the list, no matter their order, without trying to sort them in any way.\r\n\r\nThe following code shows an example in which you reverse the order of the names in the list and then print the list. The output shows the list items reversed from their original order:\r\n<pre class=\"code\"># Create a list of strings.\r\nnames = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\n# Reverse the list\r\nnames.reverse()\r\n# Print the list\r\nprint(names)\r\n \r\n['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara']</pre>\r\n<h2 id=\"tab15\" >Copying a Python list</h2>\r\nIf you ever need to work with a copy of a list, use the <code>.copy()</code> method so as not to alter the original list,. For example, the following code is similar to the preceding code, except that instead of reversing the order of the original list, you make a copy of the list and reverse that one. Printing the contents of each list shows how the first list is still in the original order whereas the second one is reversed:\r\n<pre class=\"code\"># Create a list of strings.\r\nnames = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\n \r\n# Make a copy of the list\r\nbackward_names = names.copy()\r\n# Reverse the copy\r\nbackward_names.reverse()\r\n \r\n# Print the list\r\nprint(names)\r\nprint(backward_names)\r\n \r\n['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake']\r\n['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara']</pre>\r\nFor future references, the following table summarizes the methods you've learned about.\r\n<table><caption>Methods for Working with Lists</caption>\r\n<thead>\r\n<tr>\r\n<td>Method</td>\r\n<td>What it Does</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td><code>append()</code></td>\r\n<td>Adds an item to the end of the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>clear()</code></td>\r\n<td>Removes all items from the list, leaving it empty.</td>\r\n</tr>\r\n<tr>\r\n<td><code>copy()</code></td>\r\n<td>Makes a copy of a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>count()</code></td>\r\n<td>Counts how many times an element appears in a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>extend()</code></td>\r\n<td>Appends the items from one list to the end of another list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>index()</code></td>\r\n<td>Returns the index number (position) of an element within a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>insert()</code></td>\r\n<td>Inserts an item into the list at a specific position.</td>\r\n</tr>\r\n<tr>\r\n<td><code>pop()</code></td>\r\n<td>Removes an element from the list, and provides a copy of that item that you can store in a variable.</td>\r\n</tr>\r\n<tr>\r\n<td><code>remove()</code></td>\r\n<td>Removes one item from the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>reverse()</code></td>\r\n<td>Reverses the order of items in the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>sort()</code></td>\r\n<td>Sorts the list in ascending order. Put <code>reverse=True</code> inside the parentheses to sort in descending order.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h1></h1>","description":"The simplest data collection in <a href=\"https://www.dummies.com/programming/python/python-all-in-one-for-dummies-cheat-sheet/\">Python</a> is a list. A <em>list</em> is any list of data items, separated by commas, inside square brackets. Typically, you assign a name to the Python list using an = sign, just as you would with variables. If the list contains numbers, then don't use quotation marks around them. For example, here is a list of test scores:\r\n<pre class=\"code\">scores = [88, 92, 78, 90, 98, 84]</pre>\r\nIf the list contains strings then, as always, those strings should be enclosed in single or double quotation marks, as in this example:\r\n\r\nTo display the contents of a list on the screen, you can print it just as you would print any regular variable. For example, executing <code>print(students)</code> in your code after defining that list shows this on the screen.\r\n<pre class=\"code\">['Mark', 'Amber', 'Todd', 'Anita', 'Sandy']</pre>\r\nThis may not be exactly what you had in mind. But don’t worry, Python offers lots of great ways to access data in lists and display it however you like.\r\n<h2 id=\"tab1\" >Referencing Python list items by position</h2>\r\nEach item in a list has a position number, starting with zero, even though you don’t see any numbers. You can refer to any item in the list by its number using the name for the list followed by a number in square brackets. In other words, use this syntax:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;[&lt;em&gt;x&lt;/em&gt;]\r\n\r\nReplace &lt;em&gt;&lt;code&gt;listname&lt;/code&gt;&lt;/em&gt; with the name of the list you're accessing and replace &lt;em&gt;&lt;code&gt;x&lt;/code&gt;&lt;/em&gt; with the position number of item you want. Remember, the first item is always number zero, not one. For example, in the first line below, I define a list named &lt;code&gt;students&lt;/code&gt;, and then print item number zero from that list. The result, when executing the code, is that the name &lt;code&gt;Mark&lt;/code&gt; is displayed.</pre>\r\n<pre class=\"code\">students = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nprint(students[0])\r\nMark</pre>\r\n<technicalstuff>\r\n\r\nWhen reading access list items, professionals use the word <em>sub</em> before the number. For example, <em>students[0]</em> would be spoken as <em>students sub zero</em>.\r\n\r\nThis next example shows a list named <code>scores</code>. The <code>print()</code> function prints the position number of the last score in the list, which is 4 (because the first one is always zero).\r\n<pre class=\"code\">scores = [88, 92, 78, 90, 84]\r\nprint(scores[4])\r\n84</pre>\r\nIf you try to access a list item that doesn't exist, you get an “index out of range” error. The <em>index</em> part is a reference to the number inside the square brackets. For example, the image below shows a little experiment in a <a href=\"https://www.dummies.com/programming/python/tips-for-using-jupyter-notebook-for-python-programming/\">Jupyter notebook</a> where a list of scores was created and then the printing of <code>score[5]</code> was attempted.\r\n\r\nIt failed and generated an error because there is no <code>scores[5]</code>. There's only <code>scores[0]</code>, <code>scores[1]</code>, <code>scores[2]</code>, <code>scores[3]</code>, and <code>scores[4]</code> because the counting always starts at zero with the first one on the list.\r\n\r\n[caption id=\"attachment_264920\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264920 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-index-range.jpg\" alt=\"Python index range\" width=\"535\" height=\"212\" /> Index out of range error because there is no scores[5].[/caption] \r\n<h2 id=\"tab2\" >Looping through a Python list</h2>\r\nTo access each item in a list, just use a for loop with this syntax:\r\n<pre class=\"code\">for &lt;em&gt;x&lt;/em&gt; in &lt;em&gt;list&lt;/em&gt;:</pre>\r\nReplace <em<code>&gt;x</code> with a variable name of your choosing. Replace <em><code>list</code></em> with the name of the list. An easy way to make the code readable is to always use a plural for the list name (such as <code>students</code>, <code>scores</code>). Then you can use the singular name (<code>student</code>, <code>score</code>) for the variable name. You don't need to use subscript numbers (numbers in square brackets) with this approach either. For example, the following code prints each score in the scores list:\r\n<pre class=\"code\">for score in scores:\r\nprint(score)</pre>\r\nRemember to always indent the code that’s to be executed within the loop. This image shows a more complete example where you can see the result of running the code in a Jupyter notebook.\r\n\r\n[caption id=\"attachment_264921\" align=\"aligncenter\" width=\"262\"]<img class=\"wp-image-264921 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-loop-list.jpg\" alt=\"Looping through a Python list\" width=\"262\" height=\"219\" /> Looping through a list.[/caption]\r\n\r\n \r\n<h2 id=\"tab3\" >Seeing whether a Python list contains an item</h2>\r\nIf you want your code to check the contents of a list to see whether it already contains some item, use <code>in &lt;em&gt;listname&lt;/em&gt;</code> in an <code>if</code> statement or a variable assignment.\r\n\r\nFor example, the code in the image below creates a list of names. Then, two variables store the results of searching the list for the names <em>Anita</em> and <em>Bob</em>. Printing the contents of each variable shows True for the one where the name (Anita) is in the list. The test to see whether Bob is in the list proves False.\r\n\r\n[caption id=\"attachment_264922\" align=\"aligncenter\" width=\"460\"]<img class=\"wp-image-264922 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-list-contain.jpg\" alt=\"Seeing whether an item is in a Python list\" width=\"460\" height=\"244\" /> Seeing whether an item is in a list.[/caption]\r\n\r\n \r\n<h2 id=\"tab4\" >Getting the length of a Python list</h2>\r\nTo determine how many items are in a list, use the <code>len()</code> function (short for <em>length</em>). Put the name of the list inside the parentheses. For example, type the following code into a Jupyter notebook or Python prompt or whatever:\r\n<pre class=\"code\">students = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nprint(len(students))</pre>\r\nRunning that code produces this output:\r\n<pre class=\"code\">5</pre>\r\nThere are indeed five items in the list, though the last one is always one less than the number because Python starts counting at zero. So the last one, Sandy, actually refers to students[4] and not students[5].\r\n<h2 id=\"tab5\" >Appending an item to the end of a Python list</h2>\r\nWhen you want your Python code to add a new item to the end of a list, use the <code>.append()</code> method with the value you want to add inside the parentheses. You can use either a variable name or a literal value inside the quotation marks.\r\n\r\nFor instance, in the following image the line that reads <code>students.append(\"Goober\")</code> adds the name Goober to the list. The line that reads <code>students.append(new_student)</code> adds whatever name is stored in the variable named <code>new_student</code> to the list. The <code>.append()</code> method always adds to the end of the list. So when you print the list you see those two new names at the end.\r\n\r\n[caption id=\"attachment_264923\" align=\"aligncenter\" width=\"533\"]<img class=\"wp-image-264923 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-append-list.jpg\" alt=\"Python append list\" width=\"533\" height=\"272\" /> Appending two new names to the end of the list.[/caption]\r\n\r\n \r\n\r\nYou can use a test to see whether an item is in a list and then append it only when the item isn't already there. For example, the code below won’t add the name Amber to the list because that name is already in the list:\r\n<pre class=\"code\">student_name = \"Amanda\"\r\n\r\n#Add student_name but only if not already in the list.\r\nif student_name in students:\r\n print (student_name + \" already in the list\")\r\nelse: \r\n students.append(student_name)\r\n print (student_name + \" added to the list\")</pre>\r\n<h2 id=\"tab6\" >Inserting an item into a Python list</h2>\r\nAlthough the <code>append()</code> method allows you to add an item to the end of a list, the <code>insert()</code> method allows you to add an item to the list in any position. The syntax for <code>insert()</code> is\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.insert(&lt;em&gt;position&lt;/em&gt;, &lt;em&gt;item&lt;/em&gt;)</pre>\r\nReplace <em>listname</em> with the name of the list, <em>position</em> with the position at which you want to insert the item (for example, 0 to make it the first item, 1 to make it the second item, and so forth). Replace <em>item</em> with the value, or the name of a variable that contains the value, that you want to put into the list.\r\n\r\nFor example, the following code makes Lupe the first item in the list:\r\n<pre class=\"code\">#Create a list of strings (names).\r\nstudents = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\n\r\nstudent_name = \"Lupe\"\r\n# Add student name to front of the list.\r\nstudents.insert(0,student_name)\r\n\r\n#Show me the new list.\r\nprint(students)</pre>\r\nIf you run the code, <code>print(students)</code> will show the list after the new name has been inserted, as follows:\r\n<pre class=\"code\">['Lupe', 'Mark', 'Amber', 'Todd', 'Anita', 'Sandy']</pre>\r\n<h2 id=\"tab7\" >Changing an item in a Python list</h2>\r\nYou can change an item in a list using the = assignment operator (check out these <a href=\"https://www.dummies.com/programming/python/common-python-operators/\">common Python operators</a>) just like you do with variables. Just make sure you include the index number in square brackets of the item you want to change. The syntax is:\r\n\r\n<em>listname</em>[<em>index</em>]=<em>newvalue</em>\r\n\r\nReplace <em><code>listname</code></em> with the name of the list; replace <em><code>index</code></em> with the subscript (index number) of the item you want to change; and replace <em><code>newvalue</code></em> with whatever you want to put in the list item. For example, take a look at this code:\r\n<pre class=\"code\">#Create a list of strings (names).\r\nstudents = [\"Mark\", \"Amber\", \"Todd\", \"Anita\", \"Sandy\"]\r\nstudents[3] = \"Hobart\"\r\nprint(students)</pre>\r\nWhen you run this code, the output is as follows, because Anita's name has been changed to Hobart.\r\n<pre class=\"code\">['Mark', 'Amber', 'Todd', 'Hobart', 'Sandy']</pre>\r\n<h2 id=\"tab8\" >Combining Python lists</h2>\r\nIf you have two lists that you want to combine into a single list, use the <code>extend()</code> function with the syntax:\r\n<pre class=\"code\">&lt;em&gt;original_list&lt;/em&gt;.extend(&lt;em&gt;additional_items_list&lt;/em&gt;)</pre>\r\nIn your code, replace <em>original_list</em> with the name of the list to which you’ll be adding new list items. Replace <em>additional_items_list</em> with the name of the list that contains the items you want to add to the first list. Here is a simple example using lists named <code>list1</code> and <code>list2</code>. After executing <code>list1.extend(list2)</code>, the first list contains the items from both lists, as you can see in the output of the <code>print()</code> statement at the end.\r\n<pre class=\"code\"># Create two lists of Names.\r\nlist1 = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\nlist2 = [\"Huey\", \"Dewey\", \"Louie\", \"Nader\", \"Bubba\"]\r\n\r\n# Add list2 names to list1.\r\nlist1.extend(list2)\r\n\r\n# Print list 1.\r\nprint(list1)\r\n\r\n['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake', 'Huey', 'Dewey', 'Louie', 'Nader', 'Bubba']</pre>\r\nEasy Parcheesi, no?\r\n<h2 id=\"tab9\" >Removing Python list items</h2>\r\nPython offers a <code>remove()</code> method so you can remove any value from the list. If the item is in the list multiple times, only the first occurrence is removed. For example, the following code shows a list of letters with the letter <em>C</em> repeated a few times. Then the code uses <code>letters.remove(\"C\")</code> to remove the letter <em>C</em> from the list:\r\n<pre class=\"code\"># Remove \"C\" from the list.\r\nletters.remove(\"C\")\r\n\r\n#Show me the new list.\r\nprint(letters)</pre>\r\nWhen you actually execute this code and then print the list, you'll see that only the first letter <em>C</em> has been removed:\r\n<pre class=\"code\">['A', 'B', 'D', 'C', 'E', 'C']</pre>\r\nIf you need to remove all of an item, you can use a <code>while</code> loop to repeat the <code>.remove</code> as long as the item still remains in the list. For example, this code repeats the .remove as long as the “C” is still in the list.\r\n<pre class=\"code\">#Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"C\", \"E\", \"C\"]</pre>\r\nIf you want to remove an item based on its position in the list, use <code>pop()</code> with an index number rather than <code>remove()</code> with a value. If you want to remove the last item from the list, use <code>pop()</code> without an index number.\r\n\r\nFor example, the following code creates a list, one line removes the first item (0), and another removes the last item <code>(pop()</code> with nothing in the parentheses). Printing the list shows those two items have been removed:\r\n<pre class=\"code\">#Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n#Remove the first item.\r\nletters.pop(0)\r\n#Remove the last item.\r\nletters.pop()\r\n \r\n#Show me the new list.\r\nprint(letters)</pre>\r\nRunning the code shows that the popping the first and last items did, indeed, work:\r\n<pre class=\"code\">['B', 'C', 'D', 'E', 'F']</pre>\r\nWhen you <code>pop()</code> an item off the list, you can store a copy of that value in some variable. For example this image shows the same code as above. However, it stores copies of what's been removed in variables named <code>first_removed</code> and <code>last_removed</code>. At the end it <a href=\"https://www.dummies.com/programming/python/printing-lists-using-python/\">prints the Python list</a>, and also shows which letters were removed.\r\n\r\n[caption id=\"attachment_264924\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264924 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-remove-list-item.jpg\" alt=\"remove items from Python list\" width=\"535\" height=\"231\" /> Removing list items with pop().[/caption]\r\n\r\nPython also offers a <code>del</code> (short for <em>delete</em>) command that deletes any item from a list based on its index number (position). But again, you have to remember that the first item is zero. So, let's say you run the following code to delete item number 2 from the list:\r\n<pre class=\"code\"># Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n# Remove item sub 2.\r\ndel letters[2]\r\n \r\nprint(letters)</pre>\r\nRunning that code shows the list again, as follows. The letter <em>C</em> has been deleted, which is the correct item to delete because letters are numbered 0, 1, 2, 3, and so forth.\r\n<pre class=\"code\">['A', 'B', 'D', 'E', 'F', 'G']</pre>\r\nYou can also use del to delete an entire list. Just don’t use the square brackets and the index number. For example, the code you see below creates a list then deletes it. Trying to print the list after the deletion causes an error, because the list no longer exists when the <code>print()</code> statement is executed.\r\n\r\n[caption id=\"attachment_264925\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264925 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-delete-list.jpg\" alt=\"delete Python list\" width=\"535\" height=\"273\" /> Deleting a list and then trying to print it causes an error.[/caption]\r\n\r\n \r\n<h2 id=\"tab10\" >Clearing out a Python list</h2>\r\nIf you want to delete the contents of a list but not the list itself, use <code>.clear()</code>. The list still exists; however, it contains no items. In other words, it's an empty list. The following code shows how you could test this. Running the code displays [] at the end, which lets you know the list is empty:\r\n<pre class=\"code\"># Create a list of strings.\r\nletters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\"]\r\n \r\n# Clear the list of all entries.\r\nletters.clear()\r\n \r\n# Show me the new list.\r\nprint(letters)\r\n</pre>\r\n\r\n<h2 id=\"tab11\" >Counting how many times an item appears in a Python list</h2>\r\nYou can use the Python <code>count()</code> method to count how many times an item appears in a list. As with other list methods, the syntax is simple:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.count(&lt;em&gt;x&lt;/em&gt;)</pre>\r\nReplace <em>listname</em> with the name of your list, and <em>x</em> with the value you're looking for (or the name of a variable that contains that value).\r\n\r\nThe code in the image below counts how many times the letter <em>B</em> appears in the list, using a literal B inside the parentheses of <code>.count()</code>. This same code also counts the number of <em>C</em> grades, but that value was stored in a variable just to show the difference in syntax. Both counts worked, as you can see in the output of the program at the bottom. One was added to count the <em>F</em>'s, not using any variables. The <em>F</em>’s were counted right in the code that displays the message. There are no <em>F</em> grades, so this returns zero, as you can see in the output.\r\n\r\n[caption id=\"attachment_264926\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264926 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-count-list-item.jpg\" alt=\"count Python list items\" width=\"535\" height=\"296\" /> Counting items in a list.[/caption]\r\n\r\nWhen trying to combine numbers and strings to form a message, remember you have to convert the numbers to strings using the <code>str()</code> function. Otherwise, you get an error that reads something like can only <code>concatenate str (not \"int\") to str</code>. In that message, <code>int</code> is short for <em>integer</em>, and <code>str</code> is short for <em>string</em>.\r\n<h2 id=\"tab12\" >Finding a Python list item's index</h2>\r\nPython offers an .index() method that returns a number indicating the position, based on index number, of an item in a list. The syntax is:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.index(&lt;em&gt;x&lt;/em&gt;)</pre>\r\nAs always, replace <em><code>listname</code></em> with name of the list you want to search. Replace <em>x</em> what whatever you're looking for (either as a literal or as a variable name, as always). Of course, there’s no guarantee that the item is in the list, and even if it is, there’s no guarantee that the item is in the list only once. If the item isn’t in the list, then an error occurs. If the item is in the list multiple times, then the index of the first matching item is returned.\r\n\r\nThe following image shows an example where the program crashes at the line <code>f_index = grades.index(look_for)</code> because there is no <em>F</em> in the list.\r\n\r\n[caption id=\"attachment_264927\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-264927 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-list-iem-index.jpg\" alt=\"Python list item index\" width=\"535\" height=\"374\" /> Program fails when trying to find index of a nonexistent list item.[/caption]\r\n\r\n \r\n\r\nAn easy way to get around that problem is to use an <code>if</code> statement to see whether an item is in the list before you try to get its index number. If the item isn't in the list, display a message saying so. Otherwise, get the index number and show it in a message. That code is as follows:\r\n<pre class=\"code\"># Create a list of strings.\r\ngrades = [\"C\", \"B\", \"A\", \"D\", \"C\", \"B\", \"C\"]\r\n# Decide what to look for\r\nlook_for = \"F\"\r\n# See if the item is in the list.\r\nif look_for in grades:\r\n # If it's in the list, get and show the index.\r\n print(str(look_for) + \" is at index \" + str(grades.index(look_for)))\r\nelse:\r\n # If not in the list, don't even try for index number.\r\n print(str(look_for) + \" isn't in the list.\")</pre>\r\n<h2 id=\"tab13\" >Alphabetizing and sorting Python lists</h2>\r\nPython offers a <code>sort()</code> method for sorting lists. In its simplest form, it alphabetizes the items in the list (if they’re strings). If the list contains numbers, they’re sorted smallest to largest. For a simple sort like that, just use <code>sort()</code> with empty parentheses:\r\n<pre class=\"code\">&lt;em&gt;listname&lt;/em&gt;.sort()</pre>\r\nReplace <em><code>listname</code></em> with the name of your list. The following image shows an example using a list of strings and a list of numbers. In the example, a new list was created for each of them simply by assigning each sorted list to a new list name. Then the code prints the contents of each sorted list.\r\n\r\n[caption id=\"attachment_264928\" align=\"aligncenter\" width=\"496\"]<img class=\"wp-image-264928 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-sort-list.jpg\" alt=\"sort Python list\" width=\"496\" height=\"296\" /> Sorting strings and numbers.[/caption]\r\n\r\n \r\n\r\nIf your list contains strings with a mixture of uppercase and lowercase letters, and if the results of the sort don't look right, try replacing <code>.sort()</code> with <code>.sort(key=lambda s:s.lower())</code> and then running the code again.\r\n\r\nDates are a little trickier because you can’t just type them in as strings, like <code>\"12/31/2020\"</code>. They have to be the <code>date</code> data type to sort correctly. This means using the <code>datetime</code> module and the <code>date()</code> method to define each date. You can add the dates to the list as you would any other list. For example, in the following line, the code creates a list of four dates, and the code is perfectly fine.\r\n<pre class=\"code\">dates = [dt.date(2020,12,31), dt.date(2019,1,31), dt.date(2018,2,28), dt.date(2020,1,1)]</pre>\r\nThe computer certainly won't mind if you create the list this way. But if you want to make the code more readable to yourself or other developers, you may want to create and append each date, one at a time, so just so it’s a little easier to see what’s going on and so you don’t have to deal with so many commas in one line of code. The image below shows an example where an empty list named <code>datelist</code> was created:\r\n<pre class=\"code\">datelist = []</pre>\r\n[caption id=\"attachment_264929\" align=\"aligncenter\" width=\"481\"]<img class=\"wp-image-264929 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-display-dates.jpg\" alt=\"display dates in Python\" width=\"481\" height=\"353\" /> Sorting and displaying dates in a nice format.[/caption]\r\n\r\n \r\n\r\nThen one date at a time was appended to the list using the <code>dt.date(&lt;em&gt;year&lt;/em&gt;,&lt;em&gt;month&lt;/em&gt;,&lt;em&gt;day&lt;/em&gt;)</code> syntax.\r\n\r\nAfter the list is created, the code uses <code>datelist.sort()</code> to sort them into chronological order (earliest to latest). You don’t need to use <code>print(datelist)</code> in that code because that method displays the dates with the data type information included, like this:\r\n<pre class=\"code\">[datetime.date(2018, 2, 28), datetime.date(2019, 1, 31), datetime.date (2020, 1, 1), datetime.date(2020, 12, 31)]</pre>\r\nNot the easiest list to read. So, rather than print the whole list with one <code>print()</code> statement, you can loop through each date in the list, and printed each one formatted with the f-string <code>%m/%d/%Y</code>. This displays each date on its own line in <em>mm/dd/yyyy</</em> format, as you can see at the bottom of the image above.\r\n\r\nIf you want to sort items in reverse order, put <code>reverse=True</code> inside the sort() parentheses (and don't forget to make the first letter uppercase). The image below shows examples of sorting all three lists in descending (reverse) order using <code>reverse=True</code>.\r\n\r\n[caption id=\"attachment_264930\" align=\"aligncenter\" width=\"403\"]<img class=\"wp-image-264930 size-full\" src=\"https://www.dummies.com/wp-content/uploads/python-sort-info-reverse.jpg\" alt=\"sort info in Python list in reverse\" width=\"403\" height=\"450\" /> Sorting strings, numbers, and dates in reverse order.[/caption]\r\n\r\n \r\n<h2 id=\"tab14\" >Reversing a Python list</h2>\r\nYou can also reverse the order of items in a list using the <code>.reverse</code> method. This is not the same as sorting in reverse, because when you sort in reverse, you still actually sort: Z–A for strings, largest to smallest for numbers, latest to earliest for dates. When you reverse a list, you simply reverse the items in the list, no matter their order, without trying to sort them in any way.\r\n\r\nThe following code shows an example in which you reverse the order of the names in the list and then print the list. The output shows the list items reversed from their original order:\r\n<pre class=\"code\"># Create a list of strings.\r\nnames = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\n# Reverse the list\r\nnames.reverse()\r\n# Print the list\r\nprint(names)\r\n \r\n['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara']</pre>\r\n<h2 id=\"tab15\" >Copying a Python list</h2>\r\nIf you ever need to work with a copy of a list, use the <code>.copy()</code> method so as not to alter the original list,. For example, the following code is similar to the preceding code, except that instead of reversing the order of the original list, you make a copy of the list and reverse that one. Printing the contents of each list shows how the first list is still in the original order whereas the second one is reversed:\r\n<pre class=\"code\"># Create a list of strings.\r\nnames = [\"Zara\", \"Lupe\", \"Hong\", \"Alberto\", \"Jake\"]\r\n \r\n# Make a copy of the list\r\nbackward_names = names.copy()\r\n# Reverse the copy\r\nbackward_names.reverse()\r\n \r\n# Print the list\r\nprint(names)\r\nprint(backward_names)\r\n \r\n['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake']\r\n['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara']</pre>\r\nFor future references, the following table summarizes the methods you've learned about.\r\n<table><caption>Methods for Working with Lists</caption>\r\n<thead>\r\n<tr>\r\n<td>Method</td>\r\n<td>What it Does</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td><code>append()</code></td>\r\n<td>Adds an item to the end of the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>clear()</code></td>\r\n<td>Removes all items from the list, leaving it empty.</td>\r\n</tr>\r\n<tr>\r\n<td><code>copy()</code></td>\r\n<td>Makes a copy of a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>count()</code></td>\r\n<td>Counts how many times an element appears in a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>extend()</code></td>\r\n<td>Appends the items from one list to the end of another list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>index()</code></td>\r\n<td>Returns the index number (position) of an element within a list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>insert()</code></td>\r\n<td>Inserts an item into the list at a specific position.</td>\r\n</tr>\r\n<tr>\r\n<td><code>pop()</code></td>\r\n<td>Removes an element from the list, and provides a copy of that item that you can store in a variable.</td>\r\n</tr>\r\n<tr>\r\n<td><code>remove()</code></td>\r\n<td>Removes one item from the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>reverse()</code></td>\r\n<td>Reverses the order of items in the list.</td>\r\n</tr>\r\n<tr>\r\n<td><code>sort()</code></td>\r\n<td>Sorts the list in ascending order. Put <code>reverse=True</code> inside the parentheses to sort in descending order.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h1></h1>","blurb":"","authors":[{"authorId":26709,"name":"Alan Shovic","slug":"alan-shovic","description":"","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/26709"}},{"authorId":26710,"name":"John C. Shovic","slug":"john-shovic","description":"John Shovic, PhD, is a computer science faculty member at the University of Idaho specializing in robotics and artificial intelligence.","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/26710"}}],"primaryCategoryTaxonomy":{"categoryId":33606,"title":"Python","slug":"python","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33606"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[{"label":"Referencing Python list items by position","target":"#tab1"},{"label":"Looping through a Python list","target":"#tab2"},{"label":"Seeing whether a Python list contains an item","target":"#tab3"},{"label":"Getting the length of a Python list","target":"#tab4"},{"label":"Appending an item to the end of a Python list","target":"#tab5"},{"label":"Inserting an item into a Python list","target":"#tab6"},{"label":"Changing an item in a Python list","target":"#tab7"},{"label":"Combining Python lists","target":"#tab8"},{"label":"Removing Python list items","target":"#tab9"},{"label":"Clearing out a Python list","target":"#tab10"},{"label":"Counting how many times an item appears in a Python list","target":"#tab11"},{"label":"Finding a Python list item's index","target":"#tab12"},{"label":"Alphabetizing and sorting Python lists","target":"#tab13"},{"label":"Reversing a Python list","target":"#tab14"},{"label":"Copying a Python list","target":"#tab15"}],"relatedArticles":{"fromBook":[{"articleId":264911,"title":"How to Use Lambda Functions in Python","slug":"how-to-use-lambda-functions-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264911"}},{"articleId":264906,"title":"Your Guide to the Python Standard Library","slug":"your-guide-to-the-python-standard-library","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264906"}},{"articleId":264894,"title":"A Beginner’s Guide to Python Versions","slug":"a-beginners-guide-to-python-versions","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264894"}},{"articleId":264888,"title":"How to Build a Simple Neural Network in Python","slug":"how-to-build-a-simple-neural-network-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264888"}},{"articleId":264872,"title":"The Raspberry Pi: The Perfect PC Platform for Python","slug":"the-raspberry-pi-the-perfect-platform-for-physical-computing-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264872"}}],"fromCategory":[{"articleId":264911,"title":"How to Use Lambda Functions in Python","slug":"how-to-use-lambda-functions-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264911"}},{"articleId":264906,"title":"Your Guide to the Python Standard Library","slug":"your-guide-to-the-python-standard-library","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264906"}},{"articleId":264894,"title":"A Beginner’s Guide to Python Versions","slug":"a-beginners-guide-to-python-versions","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264894"}},{"articleId":264888,"title":"How to Build a Simple Neural Network in Python","slug":"how-to-build-a-simple-neural-network-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264888"}},{"articleId":264872,"title":"The Raspberry Pi: The Perfect PC Platform for Python","slug":"the-raspberry-pi-the-perfect-platform-for-physical-computing-in-python","categoryList":["technology","programming-web-design","python"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/264872"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281833,"slug":"python-all-in-one-for-dummies","isbn":"9781394236152","categoryList":["technology","programming-web-design","python"],"amazon":{"default":"https://www.amazon.com/gp/product/1394236158/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1394236158/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1394236158-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1394236158/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1394236158/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/python-all-in-one-for-dummies-cover-9781394236152-203x255.jpg","width":203,"height":255},"title":"Python All-in-One For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"","authors":[{"authorId":35406,"name":"John C. Shovic","slug":"john-c-shovic","description":" <p> <b>John C. Shovic, PhD,</b> is a computer science faculty member specializing in robotics and artificial intelligence at the University of Idaho. <p><b>Alan Simpson</b> is a web development professional and prolific tech author with more than 100 publications to his credit. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/35406"}},{"authorId":10199,"name":"Alan Simpson","slug":"alan-simpson","description":" <p> <b>John C. Shovic, PhD,</b> is a computer science faculty member specializing in robotics and artificial intelligence at the University of Idaho. <p><b>Alan Simpson</b> is a web development professional and prolific tech author with more than 100 publications to his credit. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/10199"}},{"authorId":35433,"name":"","slug":"","description":" <p><b>Dr. Jill Schiefelbein</b> taught business communication at Arizona State University for 11 years before venturing into entrepreneurship. Jill’s business, The Dynamic Communicator<sup>®</sup>, helps organizations attract customers, increase sales, and retain clients. She is the author of <i>Dynamic Communication: 27 Strategies to Grow, Lead, and Manage Your Business.</i> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/35433"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;python&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781394236152&quot;]}]\" id=\"du-slot-671ffba74cdb6\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;python&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781394236152&quot;]}]\" id=\"du-slot-671ffba74d873\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"Two years","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":264919},{"headers":{"creationTime":"2018-07-11T02:40:50+00:00","modifiedTime":"2024-10-28T18:50:46+00:00","timestamp":"2024-10-28T21:01:26+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Information Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33572"},"slug":"information-technology","categoryId":33572},{"name":"AI","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33574"},"slug":"ai","categoryId":33574},{"name":"Generative AI","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33576"},"slug":"general-ai","categoryId":33576}],"title":"Envision the World as a Graph with Bayes' Theorem","strippedTitle":"envision the world as a graph with bayes' theorem","slug":"envision-world-graph-bayes-theorem","canonicalUrl":"","seo":{"metaDescription":"Bayes’ theorem can help you deduce how likely something is to happen in a certain context, based on the general probabilities of the fact itself and the evidenc","noIndex":0,"noFollow":0},"content":"Bayes’ theorem can help you deduce how likely something is to happen in a certain context, based on the general probabilities of the fact itself and the evidence you examine, and combined with the probability of the evidence given the fact. Seldom will a single piece of evidence diminish doubts and provide enough certainty in a prediction to ensure that it will happen. As a true detective, to reach certainty, you have to collect more evidence and make the individual pieces work together in your investigation. Noticing that a person has long hair isn’t enough to determine whether person is female or a male. Adding data about height and weight could help increase confidence.\r\n\r\nThe Naïve Bayes algorithm helps you arrange all the evidence you gather and reach a more solid prediction with a higher likelihood of being correct. Gathered evidence considered singularly couldn’t save you from the risk of predicting incorrectly, but all evidence summed together can reach a more definitive resolution. The following example shows how things work in a Naïve Bayes classification. This is an old, renowned problem, but it represents the kind of capability that you can expect from an AI. The dataset is from the paper “<a href=\"https://dl.acm.org/doi/10.1023/A%3A1022643204877\" target=\"_blank\" rel=\"noopener\">Induction of Decision Trees</a>,” by John Ross Quinlan. Quinlan is a computer scientist who contributed to the development of another machine learning algorithm, decision trees, in a fundamental way, but his example works well with any kind of learning algorithm. The problem requires that the AI guess the best conditions to play tennis given the weather conditions. The set of features described by Quinlan is as follows:\r\n<ul>\r\n \t<li><strong>Outlook:</strong> Sunny, overcast, or rainy</li>\r\n \t<li><strong>Temperature:</strong> Cool, mild, or hot</li>\r\n \t<li><strong>Humidity:</strong> High or normal</li>\r\n \t<li><strong>Windy:</strong> True or false</li>\r\n</ul>\r\nThe following table contains the database entries used for the example:\r\n<table>\r\n<thead>\r\n<tr>\r\n<td><strong>Outlook</strong></td>\r\n<td width=\"95\"><strong>Temperature</strong></td>\r\n<td width=\"95\"><strong>Humidity</strong></td>\r\n<td width=\"57\"><strong>Windy</strong></td>\r\n<td width=\"113\"><strong>PlayTennis</strong></td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\nThe option of playing tennis depends on the four arguments shown here.\r\n\r\n[caption id=\"attachment_254186\" align=\"alignnone\" width=\"535\"]<img class=\"size-full wp-image-254186\" src=\"https://www.dummies.com/wp-content/uploads/ai-naïve-bayes.jpg\" alt=\"ai-naïve-bayes\" width=\"535\" height=\"129\" /> A Naïve Bayes model can retrace evidence to the right outcome.[/caption]\r\n\r\nThe result of this AI learning example is a decision as to whether to play tennis, given the weather conditions (the evidence). Using just the outlook (sunny, overcast, or rainy) won’t be enough, because the temperature and humidity could be too high or the wind might be strong. These arguments represent real conditions that have multiple causes, or causes that are interconnected. The Naïve Bayes algorithm is skilled at guessing correctly when multiple causes exist.\r\n\r\nThe algorithm computes a score, based on the probability of making a particular decision and multiplied by the probabilities of the evidence connected to that decision. For instance, to determine whether to play tennis when the outlook is sunny but the wind is strong, the algorithm computes the score for a positive answer by multiplying the general probability of playing (9 played games out of 14 occurrences) by the probability of the day’s being sunny (2 out of 9 played games) and of having windy conditions when playing tennis (3 out of 9 played games). The same rules apply for the negative case (which has different probabilities for not playing given certain conditions):\r\n\r\n<code>likelihood of playing: 9/14 * 2/9 * 3/9 = 0.05</code>\r\n\r\n<code>likelihood of not playing: 5/14 * 3/5 * 3/5 = 0.13</code>\r\n\r\nBecause the score for the likelihood is higher, the algorithm decides that it’s safer not to play under such conditions. It computes such likelihood by summing the two scores and dividing both scores by their sum:\r\n\r\n<code>probability of playing : 0.05 / (0.05 + 0.13) = 0.278</code>\r\n\r\n<code>probability of not playing : 0.13 / (0.05 + 0.13) = 0.722</code>\r\n\r\nYou can further extend Naïve Bayes to represent relationships that are more complex than a series of factors that hint at the likelihood of an outcome using a <em>Bayesian network,</em> which consists of graphs showing how events affect each other. Bayesian graphs have nodes that represent the events and arcs showing which events affect others, accompanied by a table of conditional probabilities that show how the relationship works in terms of probability. The figure shows a famous example of a Bayesian network taken from a 1988 academic paper, “<a href=\"https://www.jstor.org/stable/2345762\" target=\"_blank\" rel=\"noopener\">Local computations with probabilities on graphical structures and their application to expert systems</a>,” by Lauritzen, Steffen L. and David J. Spiegelhalter, published by the <em>Journal of the Royal Statistical Society.</em>\r\n\r\n[caption id=\"attachment_254183\" align=\"alignnone\" width=\"449\"]<img class=\"size-full wp-image-254183\" src=\"https://www.dummies.com/wp-content/uploads/ai-bayesian-network.jpg\" alt=\"ai-bayesian-network\" width=\"449\" height=\"400\" /> A Bayesian network can support a medical decision.[/caption]\r\n\r\nThe depicted network is called <em>Asia.</em> It shows possible patient conditions and what causes what. For instance, if a patient has dyspnea, it could be an effect of tuberculosis, lung cancer, or bronchitis. Knowing whether the patient smokes, has been to Asia, or has anomalous x-ray results (thus giving certainty to certain pieces of evidence, a priori in Bayesian language) helps infer the real (posterior) probabilities of having any of the pathologies in the graph.\r\n\r\nBayesian networks, though intuitive, have complex math behind them, and they’re more powerful than a simple Naïve Bayes algorithm because they mimic the world as a sequence of causes and effects based on probability. Bayesian networks are so effective that you can use them to represent any situation. They have varied applications, such as medical diagnoses, the fusing of uncertain data arriving from multiple sensors, economic modeling, and the monitoring of complex systems such as a car. For instance, because driving in highway traffic may involve complex situations with many vehicles, the Analysis of MassIve Data STreams (AMIDST) consortium, in collaboration with the automaker Daimler, devised a Bayesian network that can recognize maneuvers by other vehicles and increase driving safety.","description":"Bayes’ theorem can help you deduce how likely something is to happen in a certain context, based on the general probabilities of the fact itself and the evidence you examine, and combined with the probability of the evidence given the fact. Seldom will a single piece of evidence diminish doubts and provide enough certainty in a prediction to ensure that it will happen. As a true detective, to reach certainty, you have to collect more evidence and make the individual pieces work together in your investigation. Noticing that a person has long hair isn’t enough to determine whether person is female or a male. Adding data about height and weight could help increase confidence.\r\n\r\nThe Naïve Bayes algorithm helps you arrange all the evidence you gather and reach a more solid prediction with a higher likelihood of being correct. Gathered evidence considered singularly couldn’t save you from the risk of predicting incorrectly, but all evidence summed together can reach a more definitive resolution. The following example shows how things work in a Naïve Bayes classification. This is an old, renowned problem, but it represents the kind of capability that you can expect from an AI. The dataset is from the paper “<a href=\"https://dl.acm.org/doi/10.1023/A%3A1022643204877\" target=\"_blank\" rel=\"noopener\">Induction of Decision Trees</a>,” by John Ross Quinlan. Quinlan is a computer scientist who contributed to the development of another machine learning algorithm, decision trees, in a fundamental way, but his example works well with any kind of learning algorithm. The problem requires that the AI guess the best conditions to play tennis given the weather conditions. The set of features described by Quinlan is as follows:\r\n<ul>\r\n \t<li><strong>Outlook:</strong> Sunny, overcast, or rainy</li>\r\n \t<li><strong>Temperature:</strong> Cool, mild, or hot</li>\r\n \t<li><strong>Humidity:</strong> High or normal</li>\r\n \t<li><strong>Windy:</strong> True or false</li>\r\n</ul>\r\nThe following table contains the database entries used for the example:\r\n<table>\r\n<thead>\r\n<tr>\r\n<td><strong>Outlook</strong></td>\r\n<td width=\"95\"><strong>Temperature</strong></td>\r\n<td width=\"95\"><strong>Humidity</strong></td>\r\n<td width=\"57\"><strong>Windy</strong></td>\r\n<td width=\"113\"><strong>PlayTennis</strong></td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Cool</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Sunny</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Overcast</td>\r\n<td width=\"95\">Hot</td>\r\n<td width=\"95\">Normal</td>\r\n<td width=\"57\">False</td>\r\n<td width=\"113\">Yes</td>\r\n</tr>\r\n<tr>\r\n<td>Rainy</td>\r\n<td width=\"95\">Mild</td>\r\n<td width=\"95\">High</td>\r\n<td width=\"57\">True</td>\r\n<td width=\"113\">No</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\nThe option of playing tennis depends on the four arguments shown here.\r\n\r\n[caption id=\"attachment_254186\" align=\"alignnone\" width=\"535\"]<img class=\"size-full wp-image-254186\" src=\"https://www.dummies.com/wp-content/uploads/ai-naïve-bayes.jpg\" alt=\"ai-naïve-bayes\" width=\"535\" height=\"129\" /> A Naïve Bayes model can retrace evidence to the right outcome.[/caption]\r\n\r\nThe result of this AI learning example is a decision as to whether to play tennis, given the weather conditions (the evidence). Using just the outlook (sunny, overcast, or rainy) won’t be enough, because the temperature and humidity could be too high or the wind might be strong. These arguments represent real conditions that have multiple causes, or causes that are interconnected. The Naïve Bayes algorithm is skilled at guessing correctly when multiple causes exist.\r\n\r\nThe algorithm computes a score, based on the probability of making a particular decision and multiplied by the probabilities of the evidence connected to that decision. For instance, to determine whether to play tennis when the outlook is sunny but the wind is strong, the algorithm computes the score for a positive answer by multiplying the general probability of playing (9 played games out of 14 occurrences) by the probability of the day’s being sunny (2 out of 9 played games) and of having windy conditions when playing tennis (3 out of 9 played games). The same rules apply for the negative case (which has different probabilities for not playing given certain conditions):\r\n\r\n<code>likelihood of playing: 9/14 * 2/9 * 3/9 = 0.05</code>\r\n\r\n<code>likelihood of not playing: 5/14 * 3/5 * 3/5 = 0.13</code>\r\n\r\nBecause the score for the likelihood is higher, the algorithm decides that it’s safer not to play under such conditions. It computes such likelihood by summing the two scores and dividing both scores by their sum:\r\n\r\n<code>probability of playing : 0.05 / (0.05 + 0.13) = 0.278</code>\r\n\r\n<code>probability of not playing : 0.13 / (0.05 + 0.13) = 0.722</code>\r\n\r\nYou can further extend Naïve Bayes to represent relationships that are more complex than a series of factors that hint at the likelihood of an outcome using a <em>Bayesian network,</em> which consists of graphs showing how events affect each other. Bayesian graphs have nodes that represent the events and arcs showing which events affect others, accompanied by a table of conditional probabilities that show how the relationship works in terms of probability. The figure shows a famous example of a Bayesian network taken from a 1988 academic paper, “<a href=\"https://www.jstor.org/stable/2345762\" target=\"_blank\" rel=\"noopener\">Local computations with probabilities on graphical structures and their application to expert systems</a>,” by Lauritzen, Steffen L. and David J. Spiegelhalter, published by the <em>Journal of the Royal Statistical Society.</em>\r\n\r\n[caption id=\"attachment_254183\" align=\"alignnone\" width=\"449\"]<img class=\"size-full wp-image-254183\" src=\"https://www.dummies.com/wp-content/uploads/ai-bayesian-network.jpg\" alt=\"ai-bayesian-network\" width=\"449\" height=\"400\" /> A Bayesian network can support a medical decision.[/caption]\r\n\r\nThe depicted network is called <em>Asia.</em> It shows possible patient conditions and what causes what. For instance, if a patient has dyspnea, it could be an effect of tuberculosis, lung cancer, or bronchitis. Knowing whether the patient smokes, has been to Asia, or has anomalous x-ray results (thus giving certainty to certain pieces of evidence, a priori in Bayesian language) helps infer the real (posterior) probabilities of having any of the pathologies in the graph.\r\n\r\nBayesian networks, though intuitive, have complex math behind them, and they’re more powerful than a simple Naïve Bayes algorithm because they mimic the world as a sequence of causes and effects based on probability. Bayesian networks are so effective that you can use them to represent any situation. They have varied applications, such as medical diagnoses, the fusing of uncertain data arriving from multiple sensors, economic modeling, and the monitoring of complex systems such as a car. For instance, because driving in highway traffic may involve complex situations with many vehicles, the Analysis of MassIve Data STreams (AMIDST) consortium, in collaboration with the automaker Daimler, devised a Bayesian network that can recognize maneuvers by other vehicles and increase driving safety.","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <b>John Paul Mueller</b> has written more than 300 articles and 80 books, most recently <i>Mastering Windows Vista Business</i> with Mark Minasi. The author of <i>Ribbon X For Dummies</i>, he has covered everything from programming to operating systems to home security and accessibility.","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}},{"authorId":9110,"name":"Luca Massaron","slug":"luca-massaron","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9110"}}],"primaryCategoryTaxonomy":{"categoryId":33576,"title":"Generative AI","slug":"general-ai","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33576"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[{"articleId":254261,"title":"Performing Health Care Tasks Using Automation","slug":"performing-tasks-using-automation","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/254261"}},{"articleId":254258,"title":"New Surgical Techniques and Artificial Intelligence","slug":"new-surgical-techniques-artificial-intelligence","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/254258"}},{"articleId":254255,"title":"Artificial Intelligence and Special Needs","slug":"artificial-intelligence-special-needs","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/254255"}},{"articleId":254252,"title":"How AI Can Enhance Physical Ability","slug":"artificial-intelligence-making-humans-capable","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/254252"}},{"articleId":254249,"title":"Portable Patient Monitoring","slug":"portable-patient-monitoring","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/254249"}}],"fromCategory":[{"articleId":302379,"title":"Generative AI For Dummies Cheat Sheet","slug":"generative-ai-for-dummies-cheat-sheet","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/302379"}},{"articleId":302176,"title":"Improving CLM with Generative AI: Key Use Cases","slug":"improving-clm-with-generative-ai-key-use-cases","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/302176"}},{"articleId":301980,"title":"Enterprise Generative AI: Transforming Your Business","slug":"enterprise-generative-ai-transforming-your-business","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/301980"}},{"articleId":301240,"title":"Five Ways Machine Health Delivers Real Business Value","slug":"five-ways-machine-health-delivers-real-business-value","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/301240"}},{"articleId":299369,"title":"How ChatGPT Could Change Our Lives","slug":"how-chatgpt-could-change-our-lives","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/299369"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281623,"slug":"artificial-intelligence-for-dummies","isbn":"9781119796763","categoryList":["technology","information-technology","ai","general-ai"],"amazon":{"default":"https://www.amazon.com/gp/product/1119796768/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1119796768/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119796768-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1119796768/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1119796768/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/artificial-intelligence-for-dummies-2nd-edition-cover-9781119796763-203x255.jpg","width":203,"height":255},"title":"Artificial Intelligence For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"<p><b><b data-author-id=\"9109\">John Paul Mueller</b></b> has written more than 300 articles and 80 books, most recently <i>Mastering Windows Vista Business</i> with Mark Minasi. The author of <i>Ribbon X For Dummies</i>, he has covered everything from programming to operating systems to home security and accessibility. <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, <b data-author-id=\"9110\">Luca Massaron</b>, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b></p>","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <b>John Paul Mueller</b> has written more than 300 articles and 80 books, most recently <i>Mastering Windows Vista Business</i> with Mark Minasi. The author of <i>Ribbon X For Dummies</i>, he has covered everything from programming to operating systems to home security and accessibility.","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}},{"authorId":9110,"name":"Luca Massaron","slug":"luca-massaron","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9110"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;ai&quot;,&quot;general-ai&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119796763&quot;]}]\" id=\"du-slot-671ffba706e99\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;ai&quot;,&quot;general-ai&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119796763&quot;]}]\" id=\"du-slot-671ffba707797\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"Six months","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":254213},{"headers":{"creationTime":"2017-05-15T13:05:30+00:00","modifiedTime":"2024-10-28T18:28:36+00:00","timestamp":"2024-10-28T21:01:26+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Social Media","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33611"},"slug":"social-media","categoryId":33611},{"name":"YouTube","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33616"},"slug":"youtube","categoryId":33616}],"title":"How to Download YouTube Videos","strippedTitle":"how to download youtube videos","slug":"download-youtube-videos","canonicalUrl":"","seo":{"metaDescription":"Need to download a YouTube video for later viewing? Find out how with these easy instructions.","noIndex":0,"noFollow":0},"content":"<a href=\"https://www.youtube.com/\" target=\"_blank\" rel=\"noopener\">YouTube</a> is a video-sharing website where users post all kinds of media. YouTube is so popular that it has one billion unique visits every single month. From how-tos to educational cartoons, YouTube has a large selection of videos from every genre.\r\n\r\nYou’ve likely watched videos on YouTube and seen something that you might want to watch when you don’t have access to the internet. Need a <a href=\"https://www.dummies.com/article/technology/social-media/youtube/what-is-the-youtube-kids-app-138083/\">cartoon for your child </a>who watch while on an airplane? Or, maybe an instructional video to review while actually doing the task later? Downloading YouTube videos is quite simple.\r\n<h2 id=\"tab1\" >How to download YouTube videos with Keepvid</h2>\r\nYou can use keepvid.com to download YouTube videos. Follow these steps to use Keepvid:\r\n<ol>\r\n \t<li>Go to <a href=\"https://www.youtube.com\" target=\"_blank\" rel=\"noopener\">YouTube</a> and find the video you’d like to download.</li>\r\n \t<li>Click the <em>Share</em> button underneath the video on YouTube to copy the link.</li>\r\n \t<li>Open a new window and navigate to <a href=\"https://www.keepvid.site/\" target=\"_blank\" rel=\"noopener\">keepvid.com</a>.</li>\r\n \t<li>Paste the link into the download text box.</li>\r\n \t<li>Click download and save the video.All done!</li>\r\n</ol>\r\n<p class=\"article-tips tip\">Keepvid can also download videos from other websites, including videos posted to social media.</p>\r\n<p class=\"article-tips warning\">Before you begin downloading videos from YouTube, you need to understand the legal issues that accompany your use of those videos. YouTube content is copyrighted. That means that you absolutely cannot download it for anything other than personal use.</p>\r\nAlso, Google (the owner of YouTube) includes <a href=\"https://www.youtube.com/static?template=terms\" target=\"_blank\" rel=\"noopener\">terms of service</a> for users. These terms specifically state: “You shall not download any Content unless you see a 'download' or similar link displayed by YouTube on the Service for that Content” (Section 5 – B). The following is provided for informational purposes only.\r\n<p class=\"article-tips remember\">There are several methods for downloading YouTube videos. The instructions above discuss one popular way to complete the task, but other options exist. There are numerous software suites available to download these videos. If you prefer this method, you can easily find choices by searching the internet for “YouTube downloading software.” The directions you find here discuss the use of websites that are specifically created to download YouTube videos.</p>","description":"<a href=\"https://www.youtube.com/\" target=\"_blank\" rel=\"noopener\">YouTube</a> is a video-sharing website where users post all kinds of media. YouTube is so popular that it has one billion unique visits every single month. From how-tos to educational cartoons, YouTube has a large selection of videos from every genre.\r\n\r\nYou’ve likely watched videos on YouTube and seen something that you might want to watch when you don’t have access to the internet. Need a <a href=\"https://www.dummies.com/article/technology/social-media/youtube/what-is-the-youtube-kids-app-138083/\">cartoon for your child </a>who watch while on an airplane? Or, maybe an instructional video to review while actually doing the task later? Downloading YouTube videos is quite simple.\r\n<h2 id=\"tab1\" >How to download YouTube videos with Keepvid</h2>\r\nYou can use keepvid.com to download YouTube videos. Follow these steps to use Keepvid:\r\n<ol>\r\n \t<li>Go to <a href=\"https://www.youtube.com\" target=\"_blank\" rel=\"noopener\">YouTube</a> and find the video you’d like to download.</li>\r\n \t<li>Click the <em>Share</em> button underneath the video on YouTube to copy the link.</li>\r\n \t<li>Open a new window and navigate to <a href=\"https://www.keepvid.site/\" target=\"_blank\" rel=\"noopener\">keepvid.com</a>.</li>\r\n \t<li>Paste the link into the download text box.</li>\r\n \t<li>Click download and save the video.All done!</li>\r\n</ol>\r\n<p class=\"article-tips tip\">Keepvid can also download videos from other websites, including videos posted to social media.</p>\r\n<p class=\"article-tips warning\">Before you begin downloading videos from YouTube, you need to understand the legal issues that accompany your use of those videos. YouTube content is copyrighted. That means that you absolutely cannot download it for anything other than personal use.</p>\r\nAlso, Google (the owner of YouTube) includes <a href=\"https://www.youtube.com/static?template=terms\" target=\"_blank\" rel=\"noopener\">terms of service</a> for users. These terms specifically state: “You shall not download any Content unless you see a 'download' or similar link displayed by YouTube on the Service for that Content” (Section 5 – B). The following is provided for informational purposes only.\r\n<p class=\"article-tips remember\">There are several methods for downloading YouTube videos. The instructions above discuss one popular way to complete the task, but other options exist. There are numerous software suites available to download these videos. If you prefer this method, you can easily find choices by searching the internet for “YouTube downloading software.” The directions you find here discuss the use of websites that are specifically created to download YouTube videos.</p>","blurb":"","authors":[{"authorId":8941,"name":"Ashley Watters, Abshier House","slug":"ashley-watters-abshier-house","description":"","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/8941"}}],"primaryCategoryTaxonomy":{"categoryId":33616,"title":"YouTube","slug":"youtube","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33616"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[{"label":"How to download YouTube videos with Keepvid","target":"#tab1"}],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":273536,"title":"Understanding Your YouTube Channel Audience","slug":"understanding-your-youtube-channel-audience","categoryList":["technology","social-media","youtube"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/273536"}},{"articleId":273522,"title":"Getting Started with YouTube Analytics","slug":"getting-started-with-youtube-analytics","categoryList":["technology","social-media","youtube"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/273522"}},{"articleId":273516,"title":"How to Add Music to Your YouTube Video","slug":"how-to-add-music-to-your-youtube-video","categoryList":["technology","social-media","youtube"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/273516"}},{"articleId":273510,"title":"Making a Content Strategy for Your YouTube Channel","slug":"making-a-content-strategy-for-your-youtube-channel","categoryList":["technology","social-media","youtube"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/273510"}},{"articleId":258541,"title":"How to Use YouTube as a Marketing Channel","slug":"how-to-use-youtube-as-a-marketing-channel","categoryList":["technology","social-media","youtube"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258541"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;social-media&quot;,&quot;youtube&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671ffba6b2dad\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;social-media&quot;,&quot;youtube&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671ffba6b422a\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Solve","lifeExpectancy":"One year","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":239597},{"headers":{"creationTime":"2017-05-03T13:14:52+00:00","modifiedTime":"2024-10-28T17:51:19+00:00","timestamp":"2024-10-28T18:01:09+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"Java","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33602"},"slug":"java","categoryId":33602}],"title":"The Atoms: Java’s Primitive Types","strippedTitle":"the atoms: java’s primitive types","slug":"atoms-javas-primitive-types","canonicalUrl":"","seo":{"metaDescription":"The words int and double are examples of primitive types (also known as simple types) in Java. The Java language has exactly eight primitive types. As a newcome","noIndex":0,"noFollow":0},"content":"The words <em>int</em> and <em>double</em> are examples of <em>primitive types</em> (also known as <em>simple</em> types) in Java. The Java language has exactly eight primitive types. As a newcomer to Java, you can pretty much ignore all but four of these types. (As programming languages go, Java is nice and compact that way.)\r\n\r\nThe types that you shouldn’t ignore are <code>int</code>, <code>double</code>, <code>char</code>, and <code>boolean</code>.\r\n<h2 id=\"tab1\" >The char type</h2>\r\nSeveral decades ago, people thought computers existed only for doing big number-crunching calculations. Nowadays, nobody thinks that way. So, if you haven’t been in a cryogenic freezing chamber for the past 20 years, you know that computers store letters, punctuation symbols, and other characters.\r\n\r\nThe Java type that’s used to store characters is called <em>char.</em> The code below has a simple program that uses the <code>char</code> type. This image shows the output of the program in the code below.\r\n\r\n[caption id=\"attachment_239304\" align=\"aligncenter\" width=\"163\"]<a href=\"https://www.dummies.com/wp-content/uploads/java-7e-char-type.jpg\"><img class=\"wp-image-239304 size-full\" src=\"https://www.dummies.com/wp-content/uploads/java-7e-char-type.jpg\" alt=\"java char type\" width=\"163\" height=\"122\" /></a> An exciting run of the program of below as it appears in the Eclipse Console view.[/caption]\r\n\r\n<code>public class CharDemo {</code>\r\n\r\n \r\n\r\n<code>public static void main(String args[]) {</code>\r\n\r\n<code>char myLittleChar = 'b';</code>\r\n\r\n<code>char myBigChar = Character.toUpperCase(myLittleChar);</code>\r\n\r\n<code>System.out.println(myBigChar);</code>\r\n\r\n<code>}</code>\r\n\r\n<code>}</code>\r\n\r\nIn this code, the first initialization stores the letter <em>b</em> in the variable <code>myLittleChar</code>. In the initialization, notice how <em>b</em> is surrounded by single quote marks. In Java, every <code>char</code> literally starts and ends with a single quote mark.\r\n<p class=\"article-tips remember\">In a Java program, single quote marks surround the letter in a <code>char</code> literal.</p>\r\n<em>Character.toUpperCase.</em> The <code>Character.toUpperCase</code> method does just what its name suggests — the method produces the uppercase equivalent of the letter <em>b.</em> This uppercase equivalent (the letter <em>B</em>) is assigned to the <code>myBigChar</code> variable, and the <em>B</em> that’s in <code>myBigChar</code> prints onscreen.\r\n\r\nIf you’re tempted to write the following statement,\r\n\r\n<code>char myLittleChars = &apos;barry&apos;; //Don&apos;t do this</code>\r\n\r\nplease resist the temptation. You can’t store more than one letter at a time in a <code>char</code> variable, and you can’t put more than one letter between a pair of single quotes. If you’re trying to store words or sentences (not just single letters), you need to use something called a String.\r\n<p class=\"article-tips warning\">If you’re used to writing programs in other languages, you may be aware of something called ASCII character encoding. Most languages use ASCII; Java uses Unicode. In the old ASCII representation, each character takes up only 8 bits, but in Unicode, each character takes up 8, 16, or 32 bits. Whereas ASCII stores the letters of the Roman (English) alphabet, Unicode has room for characters from most of the world’s commonly spoken languages.</p>\r\nThe only problem is that some of the Java API methods are geared specially toward 16-bit Unicode. Occasionally, this bites you in the back (or it bytes you in the back, as the case may be). If you’re using a method to write <code>Hello</code> on the screen and <code>H e l l o</code> shows up instead, check the method’s documentation for mention of Unicode characters.\r\n\r\nIt’s worth noticing that the two methods, <code>Character.toUpperCase</code> and <code>System.out.println</code>, are used quite differently in the code above. The method <code>Character.toUpperCase</code> is called as part of an initialization or an assignment statement, but the method <code>System.out.println</code> is called on its own.\r\n<h2 id=\"tab2\" >The boolean type</h2>\r\nA variable of type <code>boolean</code> stores one of two values: <code>true</code> or <code>false</code>. The code below demonstrates the use of a <code>boolean</code> variable.\r\n\r\n<code>public class ElevatorFitter2 {</code>\r\n\r\n \r\n\r\n<code>public static void main(String args[]) {</code>\r\n\r\n<code>System.out.println(\"True or False?\");</code>\r\n\r\n<code>System.out.println(\"You can fit all ten of the\");</code>\r\n\r\n<code>System.out.println(\"Brickenchicker dectuplets\");</code>\r\n\r\n<code>System.out.println(\"on the elevator:\");</code>\r\n\r\n<code>System.out.println();</code>\r\n\r\n \r\n\r\n<code>int weightOfAPerson = 150;</code>\r\n\r\n<code>int elevatorWeightLimit = 1400;</code>\r\n\r\n<code>int numberOfPeople = elevatorWeightLimit / weightOfAPerson;</code>\r\n\r\n \r\n\r\n<code>&lt;strong&gt; boolean allTenOkay = numberOfPeople &gt;= 10;&lt;/strong&gt;</code>\r\n\r\n \r\n\r\n<code>System.out.println(allTenOkay);</code>\r\n\r\n<code>}</code>\r\n\r\n<code>}</code>\r\n\r\nIn this code, the <code>allTenOkay</code> variable is of type <code>boolean</code>. To find a value for the <code>allTenOkay</code> variable, the program checks to see whether <code>numberOfPeople</code> is greater than or equal to ten. (The symbols >= stand for <em>greater than or equal to.</em>)\r\n\r\nAt this point, it pays to be fussy about terminology. Any part of a Java program that has a value is an <em>expression.</em> If you write\r\n\r\n<code>weightOfAPerson = 150;</code>\r\n\r\nthen <code>150 ,</code>is an expression (an expression whose value is the quantity <code>150</code>). If you write\r\n\r\n<code>numberOfEggs = 2 + 2;</code>\r\n\r\nthen 2 + 2 is an expression (because <code>2 + 2</code> has the value <code>4</code>). If you write\r\n\r\n<code>int numberOfPeople = elevatorWeightLimit / weightOfAPerson;</code>\r\n\r\nthen <code>elevatorWeightLimit / weightOfAPerson</code> is an expression. (The value of the expression <code>elevatorWeightLimit / weightOfAPerson</code> depends on whatever values the variables <code>elevatorWeightLimit</code> and <code>weightOfAPerson</code> have when the code containing the expression is executed.)\r\n<p class=\"article-tips remember\">Any part of a Java program that has a value is an expression.</p>\r\nIn the second set of code, <code>numberOfPeople &gt;= 10</code> is an expression. The expression’s value depends on the value stored in the <code>numberOfPeople</code> variable. But, as you know from seeing the strawberry shortcake at the Brickenchicker family’s catered lunch, the value of <code>numberOfPeople</code> isn’t greater than or equal to ten. As a result, the value of <code>numberOfPeople &gt;= 10</code> is <code>false</code>. So, in the statement in the second set of code, in which <code>allTenOkay</code> is assigned a value, the <code>allTenOkay</code> variable is assigned a <code>false</code> value.\r\n<p class=\"article-tips tip\">In the second set of code, <code>System.out.println()</code> is called with nothing inside the parentheses. When you do this, Java adds a line break to the program’s output. In the second set of code, <code>System.out.println()</code> tells the program to display a blank line.</p>","description":"The words <em>int</em> and <em>double</em> are examples of <em>primitive types</em> (also known as <em>simple</em> types) in Java. The Java language has exactly eight primitive types. As a newcomer to Java, you can pretty much ignore all but four of these types. (As programming languages go, Java is nice and compact that way.)\r\n\r\nThe types that you shouldn’t ignore are <code>int</code>, <code>double</code>, <code>char</code>, and <code>boolean</code>.\r\n<h2 id=\"tab1\" >The char type</h2>\r\nSeveral decades ago, people thought computers existed only for doing big number-crunching calculations. Nowadays, nobody thinks that way. So, if you haven’t been in a cryogenic freezing chamber for the past 20 years, you know that computers store letters, punctuation symbols, and other characters.\r\n\r\nThe Java type that’s used to store characters is called <em>char.</em> The code below has a simple program that uses the <code>char</code> type. This image shows the output of the program in the code below.\r\n\r\n[caption id=\"attachment_239304\" align=\"aligncenter\" width=\"163\"]<a href=\"https://www.dummies.com/wp-content/uploads/java-7e-char-type.jpg\"><img class=\"wp-image-239304 size-full\" src=\"https://www.dummies.com/wp-content/uploads/java-7e-char-type.jpg\" alt=\"java char type\" width=\"163\" height=\"122\" /></a> An exciting run of the program of below as it appears in the Eclipse Console view.[/caption]\r\n\r\n<code>public class CharDemo {</code>\r\n\r\n \r\n\r\n<code>public static void main(String args[]) {</code>\r\n\r\n<code>char myLittleChar = 'b';</code>\r\n\r\n<code>char myBigChar = Character.toUpperCase(myLittleChar);</code>\r\n\r\n<code>System.out.println(myBigChar);</code>\r\n\r\n<code>}</code>\r\n\r\n<code>}</code>\r\n\r\nIn this code, the first initialization stores the letter <em>b</em> in the variable <code>myLittleChar</code>. In the initialization, notice how <em>b</em> is surrounded by single quote marks. In Java, every <code>char</code> literally starts and ends with a single quote mark.\r\n<p class=\"article-tips remember\">In a Java program, single quote marks surround the letter in a <code>char</code> literal.</p>\r\n<em>Character.toUpperCase.</em> The <code>Character.toUpperCase</code> method does just what its name suggests — the method produces the uppercase equivalent of the letter <em>b.</em> This uppercase equivalent (the letter <em>B</em>) is assigned to the <code>myBigChar</code> variable, and the <em>B</em> that’s in <code>myBigChar</code> prints onscreen.\r\n\r\nIf you’re tempted to write the following statement,\r\n\r\n<code>char myLittleChars = &apos;barry&apos;; //Don&apos;t do this</code>\r\n\r\nplease resist the temptation. You can’t store more than one letter at a time in a <code>char</code> variable, and you can’t put more than one letter between a pair of single quotes. If you’re trying to store words or sentences (not just single letters), you need to use something called a String.\r\n<p class=\"article-tips warning\">If you’re used to writing programs in other languages, you may be aware of something called ASCII character encoding. Most languages use ASCII; Java uses Unicode. In the old ASCII representation, each character takes up only 8 bits, but in Unicode, each character takes up 8, 16, or 32 bits. Whereas ASCII stores the letters of the Roman (English) alphabet, Unicode has room for characters from most of the world’s commonly spoken languages.</p>\r\nThe only problem is that some of the Java API methods are geared specially toward 16-bit Unicode. Occasionally, this bites you in the back (or it bytes you in the back, as the case may be). If you’re using a method to write <code>Hello</code> on the screen and <code>H e l l o</code> shows up instead, check the method’s documentation for mention of Unicode characters.\r\n\r\nIt’s worth noticing that the two methods, <code>Character.toUpperCase</code> and <code>System.out.println</code>, are used quite differently in the code above. The method <code>Character.toUpperCase</code> is called as part of an initialization or an assignment statement, but the method <code>System.out.println</code> is called on its own.\r\n<h2 id=\"tab2\" >The boolean type</h2>\r\nA variable of type <code>boolean</code> stores one of two values: <code>true</code> or <code>false</code>. The code below demonstrates the use of a <code>boolean</code> variable.\r\n\r\n<code>public class ElevatorFitter2 {</code>\r\n\r\n \r\n\r\n<code>public static void main(String args[]) {</code>\r\n\r\n<code>System.out.println(\"True or False?\");</code>\r\n\r\n<code>System.out.println(\"You can fit all ten of the\");</code>\r\n\r\n<code>System.out.println(\"Brickenchicker dectuplets\");</code>\r\n\r\n<code>System.out.println(\"on the elevator:\");</code>\r\n\r\n<code>System.out.println();</code>\r\n\r\n \r\n\r\n<code>int weightOfAPerson = 150;</code>\r\n\r\n<code>int elevatorWeightLimit = 1400;</code>\r\n\r\n<code>int numberOfPeople = elevatorWeightLimit / weightOfAPerson;</code>\r\n\r\n \r\n\r\n<code>&lt;strong&gt; boolean allTenOkay = numberOfPeople &gt;= 10;&lt;/strong&gt;</code>\r\n\r\n \r\n\r\n<code>System.out.println(allTenOkay);</code>\r\n\r\n<code>}</code>\r\n\r\n<code>}</code>\r\n\r\nIn this code, the <code>allTenOkay</code> variable is of type <code>boolean</code>. To find a value for the <code>allTenOkay</code> variable, the program checks to see whether <code>numberOfPeople</code> is greater than or equal to ten. (The symbols >= stand for <em>greater than or equal to.</em>)\r\n\r\nAt this point, it pays to be fussy about terminology. Any part of a Java program that has a value is an <em>expression.</em> If you write\r\n\r\n<code>weightOfAPerson = 150;</code>\r\n\r\nthen <code>150 ,</code>is an expression (an expression whose value is the quantity <code>150</code>). If you write\r\n\r\n<code>numberOfEggs = 2 + 2;</code>\r\n\r\nthen 2 + 2 is an expression (because <code>2 + 2</code> has the value <code>4</code>). If you write\r\n\r\n<code>int numberOfPeople = elevatorWeightLimit / weightOfAPerson;</code>\r\n\r\nthen <code>elevatorWeightLimit / weightOfAPerson</code> is an expression. (The value of the expression <code>elevatorWeightLimit / weightOfAPerson</code> depends on whatever values the variables <code>elevatorWeightLimit</code> and <code>weightOfAPerson</code> have when the code containing the expression is executed.)\r\n<p class=\"article-tips remember\">Any part of a Java program that has a value is an expression.</p>\r\nIn the second set of code, <code>numberOfPeople &gt;= 10</code> is an expression. The expression’s value depends on the value stored in the <code>numberOfPeople</code> variable. But, as you know from seeing the strawberry shortcake at the Brickenchicker family’s catered lunch, the value of <code>numberOfPeople</code> isn’t greater than or equal to ten. As a result, the value of <code>numberOfPeople &gt;= 10</code> is <code>false</code>. So, in the statement in the second set of code, in which <code>allTenOkay</code> is assigned a value, the <code>allTenOkay</code> variable is assigned a <code>false</code> value.\r\n<p class=\"article-tips tip\">In the second set of code, <code>System.out.println()</code> is called with nothing inside the parentheses. When you do this, Java adds a line break to the program’s output. In the second set of code, <code>System.out.println()</code> tells the program to display a blank line.</p>","blurb":"","authors":[{"authorId":11028,"name":"Barry A. Burd","slug":"barry-a-burd","description":"","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/11028"}}],"primaryCategoryTaxonomy":{"categoryId":33602,"title":"Java","slug":"java","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33602"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[{"label":"The char type","target":"#tab1"},{"label":"The boolean type","target":"#tab2"}],"relatedArticles":{"fromBook":[{"articleId":239553,"title":"Using Streams and Lambda Expressions in Java","slug":"using-streams-lambda-expressions-java","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/239553"}},{"articleId":239544,"title":"Command Line Arguments in Java","slug":"command-line-arguments-java","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/239544"}},{"articleId":239529,"title":"How to Add Searching Capability with Java","slug":"add-searching-capability-java","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/239529"}},{"articleId":239524,"title":"How to Use Subclasses in Java","slug":"use-subclasses-java","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/239524"}},{"articleId":239520,"title":"Defining a Class in Java (What It Means to Be an Account)","slug":"defining-class-java-means-account","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/239520"}}],"fromCategory":[{"articleId":275099,"title":"How to Download and Install TextPad","slug":"how-to-download-and-install-textpad","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/275099"}},{"articleId":275089,"title":"Important Features of the Java Language","slug":"important-features-of-the-java-language","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/275089"}},{"articleId":245151,"title":"How to Install JavaFX and Scene Builder","slug":"install-javafx-scene-builder","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/245151"}},{"articleId":245148,"title":"A Few Things about Java GUIs","slug":"things-java-guis","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/245148"}},{"articleId":245141,"title":"Getting a Value from a Method in Java","slug":"getting-value-method-java","categoryList":["technology","programming-web-design","java"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/245141"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281748,"slug":"java-for-dummies-2","isbn":"9781119861645","categoryList":["technology","programming-web-design","java"],"amazon":{"default":"https://www.amazon.com/gp/product/1119861640/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1119861640/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119861640-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1119861640/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1119861640/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/9781119861645-203x255.jpg","width":203,"height":255},"title":"Java For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"<p><b>Dr. <b data-author-id=\"9069\">Barry Burd</b></b> holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of <i>Beginning Programming with Java For Dummies, Java for Android For Dummies,</i> and <i>Flutter For Dummies.</i></p>","authors":[{"authorId":9069,"name":"Barry Burd","slug":"barry-burd","description":" <p><b>Dr. Barry Burd</b> holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of <i>Beginning Programming with Java For Dummies, Java for Android For Dummies,</i> and <i>Flutter For Dummies.</i></p> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9069"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;java&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119861645&quot;]}]\" id=\"du-slot-671fd1658c809\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;java&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119861645&quot;]}]\" id=\"du-slot-671fd1658d3f6\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"Two years","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":239303},{"headers":{"creationTime":"2017-07-12T12:46:38+00:00","modifiedTime":"2024-10-28T17:43:29+00:00","timestamp":"2024-10-28T18:01:08+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"Coding","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33599"},"slug":"coding","categoryId":33599}],"title":"Tips for Debugging the Code in Your Mobile App","strippedTitle":"tips for debugging the code in your mobile app","slug":"tips-debugging-code-mobile-app","canonicalUrl":"","seo":{"metaDescription":"When coding your app, you will almost inevitably write code that does not behave as you intended. HTML and CSS are relatively forgiving, with the browser even g","noIndex":0,"noFollow":0},"content":"When coding your app, you will almost inevitably write code that does not behave as you intended. HTML and CSS are relatively forgiving, with the browser even going so far as to insert tags so the page renders properly. However, JavaScript isn’t so forgiving, and the smallest error, such as a missing quotation mark, can cause the page to not render properly.\r\n\r\nErrors in web applications can consist of syntax errors, logic errors, and display errors. Often, the most likely culprit causing errors in your code will be syntax related. Here are some common errors to check when debugging your code:\r\n<ul>\r\n \t<li><strong>Opening and closing tags:</strong> In HTML, every opening tag has a closing tag, and you always close the most recently opened tag first.</li>\r\n \t<li><strong>Right and left angle brackets:</strong> In HTML, every left angle bracket <span style=\"text-decoration: line-through;\"><</span> has a right angle bracket <span style=\"text-decoration: line-through;\">></span>.</li>\r\n \t<li><strong>Right and left curly brackets:</strong> In CSS and JavaScript, every left curly bracket must have a right curly bracket. It can be easy to accidentally delete it or forget to include it.</li>\r\n \t<li><strong>Indentation:</strong> Indent your code and use plenty of tabs and returns to make your code as readable as possible. Proper indentation will make it easier for you to identify missing tags, angle brackets, and curly brackets.</li>\r\n \t<li><strong>Misspelled statements:</strong> Tags in any language can be misspelled, or spelled correctly but not part of the specification. For example, in HTML,\r\n<pre class=\"code\">&lt;img scr=\"image.jpg\"&gt;</pre>\r\nis incorrect because <code>scr</code> should really be <code>src</code> for the image to render properly. Similarly, in CSS <code>font-color</code> looks like it is spelled correctly but no such property exists. The correct property to set font color is just <code>color</code>.</li>\r\n</ul>\r\nKeep these errors in mind when debugging — they may not solve all your problems, but they should solve many of them. If you have tried the steps above and still cannot debug your code, tweet <code>@nikhilgabraham</code> and include the <code>#codingFD</code> hashtag and your <a href=\"https://www.codepen.io/\" target=\"_blank\" rel=\"noopener\">codepen.io</a> URL in your tweet.","description":"When coding your app, you will almost inevitably write code that does not behave as you intended. HTML and CSS are relatively forgiving, with the browser even going so far as to insert tags so the page renders properly. However, JavaScript isn’t so forgiving, and the smallest error, such as a missing quotation mark, can cause the page to not render properly.\r\n\r\nErrors in web applications can consist of syntax errors, logic errors, and display errors. Often, the most likely culprit causing errors in your code will be syntax related. Here are some common errors to check when debugging your code:\r\n<ul>\r\n \t<li><strong>Opening and closing tags:</strong> In HTML, every opening tag has a closing tag, and you always close the most recently opened tag first.</li>\r\n \t<li><strong>Right and left angle brackets:</strong> In HTML, every left angle bracket <span style=\"text-decoration: line-through;\"><</span> has a right angle bracket <span style=\"text-decoration: line-through;\">></span>.</li>\r\n \t<li><strong>Right and left curly brackets:</strong> In CSS and JavaScript, every left curly bracket must have a right curly bracket. It can be easy to accidentally delete it or forget to include it.</li>\r\n \t<li><strong>Indentation:</strong> Indent your code and use plenty of tabs and returns to make your code as readable as possible. Proper indentation will make it easier for you to identify missing tags, angle brackets, and curly brackets.</li>\r\n \t<li><strong>Misspelled statements:</strong> Tags in any language can be misspelled, or spelled correctly but not part of the specification. For example, in HTML,\r\n<pre class=\"code\">&lt;img scr=\"image.jpg\"&gt;</pre>\r\nis incorrect because <code>scr</code> should really be <code>src</code> for the image to render properly. Similarly, in CSS <code>font-color</code> looks like it is spelled correctly but no such property exists. The correct property to set font color is just <code>color</code>.</li>\r\n</ul>\r\nKeep these errors in mind when debugging — they may not solve all your problems, but they should solve many of them. If you have tried the steps above and still cannot debug your code, tweet <code>@nikhilgabraham</code> and include the <code>#codingFD</code> hashtag and your <a href=\"https://www.codepen.io/\" target=\"_blank\" rel=\"noopener\">codepen.io</a> URL in your tweet.","blurb":"","authors":[{"authorId":9097,"name":"Nikhil Abraham","slug":"nikhil-abraham","description":" <p><b>Nikhil Abraham</b> was Director of Business Development &#38; Growth at Codecademy. In that role, he taught and trained thousands of beginning coders across a variety of professions. He helped refine Codecademy&#39;s online courses, which have introduced basic coding skills to millions of learners. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9097"}}],"primaryCategoryTaxonomy":{"categoryId":33599,"title":"Coding","slug":"coding","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33599"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[{"articleId":242447,"title":"The People Who Bring a Web App to Life","slug":"people-bring-web-app-life","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/242447"}},{"articleId":242444,"title":"Research Sources for Coding Your Own App","slug":"research-sources-coding-app","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/242444"}},{"articleId":242436,"title":"Getting Ready to Code? Do These Things First","slug":"getting-ready-code-things-first","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/242436"}},{"articleId":242408,"title":"Dealing with Dates in Your Data","slug":"dealing-dates-data","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/242408"}},{"articleId":242404,"title":"The Limits of Rating Data in Machine Learning","slug":"limits-rating-data-machine-learning","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/242404"}}],"fromCategory":[{"articleId":253846,"title":"Helping Kids with Coding: Distributing Mobile Apps","slug":"helping-kids-coding-distributing-mobile-apps","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253846"}},{"articleId":253837,"title":"Using the MIT App Inventor to Teach Kids Coding","slug":"using-mit-app-inventor-teach-kids-coding","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253837"}},{"articleId":253831,"title":"Teaching Kids Strategies for Debugging Code","slug":"teaching-kids-strategies-debugging-code","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253831"}},{"articleId":253826,"title":"Helping Kids Find Common Coding Semantic Errors","slug":"helping-kids-find-common-coding-semantic-errors","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253826"}},{"articleId":253818,"title":"Teaching Kids to Code Subprograms with Parameters","slug":"teaching-kids-code-subprograms-parameters","categoryList":["technology","programming-web-design","coding"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253818"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281666,"slug":"coding-all-in-one-for-dummies","isbn":"9781119889564","categoryList":["technology","programming-web-design","coding"],"amazon":{"default":"https://www.amazon.com/gp/product/1119889561/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1119889561/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119889561-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1119889561/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1119889561/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/coding-all-in-one-for-dummies-9781119889564-203x255.jpg","width":203,"height":255},"title":"Coding All-in-One For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"<p><p> <b><b data-author-id=\"9070\">Chris Minnick</b></b> is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the <i>For Dummies </i>series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies.</p>","authors":[{"authorId":9070,"name":"Chris Minnick","slug":"chris-minnick","description":" <p> <b>Chris Minnick</b> is an accomplished author, teacher, and programmer. Minnick authored or co-authored over 20 books, including titles in the <i>For Dummies </i>series. He has developed video courses for top online training platforms and he teaches programming and machine learning to professional developers at some of the largest global companies. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9070"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;coding&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119889564&quot;]}]\" id=\"du-slot-671fd164bb0f6\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;coding&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119889564&quot;]}]\" id=\"du-slot-671fd164bbdb5\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"One year","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":241918},{"headers":{"creationTime":"2016-08-23T13:02:45+00:00","modifiedTime":"2024-10-28T17:29:15+00:00","timestamp":"2024-10-28T18:01:08+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Notable Websites","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33588"},"slug":"notable-websites","categoryId":33588},{"name":"eBay","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33590"},"slug":"ebay","categoryId":33590}],"title":"How to Add a Video to Your eBay Listing","strippedTitle":"how to add a video to your ebay listing","slug":"add-video-ebay-listing","canonicalUrl":"","seo":{"metaDescription":"When a demonstration of the product you are selling on eBay would benefit from more graphic illustration, consider adding a video. The easiest way to add a vide","noIndex":0,"noFollow":0},"content":"When a demonstration of the product you are selling on eBay would benefit from more graphic illustration, consider adding a video. The easiest way to add a video to your eBay listing is to use <a href=\"https://export.ebay.com/en/first-steps/how-create-listing/how-create-listing/\" target=\"_blank\" rel=\"noopener\">eBay's new listing tool</a> when you are creating or revising your listing. Follow these steps\r\n<ol>\r\n \t<li class=\"NumListItem\">Click on the <strong>Add video</strong> button.</li>\r\n \t<li class=\"NumListItem\">Select a file on your device or drag and drop the video to the web page.</li>\r\n \t<li class=\"NumListItem\">You can also use the <strong>Import from mobile</strong> and <strong>Import from web</strong> buttons.</li>\r\n</ol>\r\nWhen you type your description, you have the option of jazzing things up with a bit of HTML coding, or you can use eBay’s HTML text editor. If you know how to use a word processor, you’ll have no trouble touching up your text with this tool. Here are a few additional codes if you’d like to manually insert the code in the HTML view.\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"244\"><strong>HTML Code</strong></td>\r\n<td width=\"271\"><strong>How to Use It</strong></td>\r\n<td width=\"388\"><strong>What It Does</strong></td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"244\"><b></b></td>\r\n<td width=\"271\"><b>cool collectible</b></td>\r\n<td width=\"388\"><strong>cool collectible</strong> (bold type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><i></i></td>\r\n<td width=\"271\"><i>cool collectible</i></td>\r\n<td width=\"388\"><em>cool collectible</em> (italic type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><b><i></i></b></td>\r\n<td width=\"271\"><b><i>cool collectible</b></i></td>\r\n<td width=\"388\"><strong><em>cool collectible</em></strong> (bold and italic type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><font color=red></font></td>\r\n<td width=\"271\"><font color=red>cool collectible</font></td>\r\n<td width=\"388\">Selected text appears in red.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><font size=+1></font></td>\r\n<td width=\"271\"><font size=+3>cool</font> collectible</td>\r\n<td width=\"388\">cool collectible (font size normal +1 through 4, increases size <em>x</em> times)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><br></td>\r\n<td width=\"271\">cool<br>collectible</td>\r\n<td width=\"388\">cool collectible (inserts line break)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><p></td>\r\n<td width=\"271\">cool<p>collectible</td>\r\n<td width=\"388\">cool collectible (inserts paragraph space)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><hr></td>\r\n<td width=\"271\">cool collectible<hr>cheap</td>\r\n<td width=\"388\">cool collectible_____________cheap (inserts horizontal rule)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><h1><h1></td>\r\n<td width=\"271\"><h1>cool collectible</h1></td>\r\n<td width=\"388\">cool collectible (converts text to headline size)</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<div class=\"mceTemp\"></div>\r\n<p class=\"article-tips tip\">You can go back and forth from the HTML text editor to regular input and add additional codes here and there by clicking from the Standard form to the HTML entry form tabs. You can prepare your listings ahead of time and save them in My eBay folder as plain HTML files — that way they’re always retrievable for use (you can just copy and paste) — no matter what program or form you’re using to list.</p>\r\nTo insert additional photos in your description, use the following code. (Just insert the URL of your hosted picture, along with the photo’s file name.) The example above used the following code:\r\n\r\n<code>&lt;img scr=##http://www.collierad.com/catbed.jpg##&gt;</code>\r\n<p class=\"article-tips tip\">Occasionally, sellers offer an item as a presale, or an item that the seller doesn’t yet have in stock but expects to. If you’re offering this kind of item, make sure that you spell out all the details in the description. eBay policy states that you must ship a presale item within 30 days of the auction’s end, so be sure that you will have the item within that time span and include the actual shipping date.</p>\r\nPutting an item up for sale without having it in hand is a practice fraught with risk. The item you’re expecting may not arrive in time or may arrive damaged. There are many sellers who have had to go out and purchase an item at retail for a buyer to preserve their feedback when caught in this situation.","description":"When a demonstration of the product you are selling on eBay would benefit from more graphic illustration, consider adding a video. The easiest way to add a video to your eBay listing is to use <a href=\"https://export.ebay.com/en/first-steps/how-create-listing/how-create-listing/\" target=\"_blank\" rel=\"noopener\">eBay's new listing tool</a> when you are creating or revising your listing. Follow these steps\r\n<ol>\r\n \t<li class=\"NumListItem\">Click on the <strong>Add video</strong> button.</li>\r\n \t<li class=\"NumListItem\">Select a file on your device or drag and drop the video to the web page.</li>\r\n \t<li class=\"NumListItem\">You can also use the <strong>Import from mobile</strong> and <strong>Import from web</strong> buttons.</li>\r\n</ol>\r\nWhen you type your description, you have the option of jazzing things up with a bit of HTML coding, or you can use eBay’s HTML text editor. If you know how to use a word processor, you’ll have no trouble touching up your text with this tool. Here are a few additional codes if you’d like to manually insert the code in the HTML view.\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"244\"><strong>HTML Code</strong></td>\r\n<td width=\"271\"><strong>How to Use It</strong></td>\r\n<td width=\"388\"><strong>What It Does</strong></td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"244\"><b></b></td>\r\n<td width=\"271\"><b>cool collectible</b></td>\r\n<td width=\"388\"><strong>cool collectible</strong> (bold type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><i></i></td>\r\n<td width=\"271\"><i>cool collectible</i></td>\r\n<td width=\"388\"><em>cool collectible</em> (italic type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><b><i></i></b></td>\r\n<td width=\"271\"><b><i>cool collectible</b></i></td>\r\n<td width=\"388\"><strong><em>cool collectible</em></strong> (bold and italic type)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><font color=red></font></td>\r\n<td width=\"271\"><font color=red>cool collectible</font></td>\r\n<td width=\"388\">Selected text appears in red.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><font size=+1></font></td>\r\n<td width=\"271\"><font size=+3>cool</font> collectible</td>\r\n<td width=\"388\">cool collectible (font size normal +1 through 4, increases size <em>x</em> times)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><br></td>\r\n<td width=\"271\">cool<br>collectible</td>\r\n<td width=\"388\">cool collectible (inserts line break)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><p></td>\r\n<td width=\"271\">cool<p>collectible</td>\r\n<td width=\"388\">cool collectible (inserts paragraph space)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><hr></td>\r\n<td width=\"271\">cool collectible<hr>cheap</td>\r\n<td width=\"388\">cool collectible_____________cheap (inserts horizontal rule)</td>\r\n</tr>\r\n<tr>\r\n<td width=\"244\"><h1><h1></td>\r\n<td width=\"271\"><h1>cool collectible</h1></td>\r\n<td width=\"388\">cool collectible (converts text to headline size)</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<div class=\"mceTemp\"></div>\r\n<p class=\"article-tips tip\">You can go back and forth from the HTML text editor to regular input and add additional codes here and there by clicking from the Standard form to the HTML entry form tabs. You can prepare your listings ahead of time and save them in My eBay folder as plain HTML files — that way they’re always retrievable for use (you can just copy and paste) — no matter what program or form you’re using to list.</p>\r\nTo insert additional photos in your description, use the following code. (Just insert the URL of your hosted picture, along with the photo’s file name.) The example above used the following code:\r\n\r\n<code>&lt;img scr=##http://www.collierad.com/catbed.jpg##&gt;</code>\r\n<p class=\"article-tips tip\">Occasionally, sellers offer an item as a presale, or an item that the seller doesn’t yet have in stock but expects to. If you’re offering this kind of item, make sure that you spell out all the details in the description. eBay policy states that you must ship a presale item within 30 days of the auction’s end, so be sure that you will have the item within that time span and include the actual shipping date.</p>\r\nPutting an item up for sale without having it in hand is a practice fraught with risk. The item you’re expecting may not arrive in time or may arrive damaged. There are many sellers who have had to go out and purchase an item at retail for a buyer to preserve their feedback when caught in this situation.","blurb":"","authors":[{"authorId":9131,"name":"Marsha Collier","slug":"marsha-collier","description":" <p><b>Marsha Collier (Los Angeles, CA)&nbsp;</b>is one of the top-selling&nbsp;<i>For Dummies&nbsp;</i>authors of all time with her books on eBay, social selling, and social media platforms adding up to well over a million copies in print. Marsha is a recognized social influencer as well, regularly making top influencer lists in the business and tech categories.</p>","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9131"}}],"primaryCategoryTaxonomy":{"categoryId":33590,"title":"eBay","slug":"ebay","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33590"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":267483,"title":"How to Sell eBay Items through Social Media","slug":"how-to-sell-ebay-items-through-social-media","categoryList":["technology","notable-websites","ebay"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/267483"}},{"articleId":267464,"title":"eBay Selling and Buying: Helping Nonprofits","slug":"ebay-selling-and-buying-helping-nonprofits","categoryList":["technology","notable-websites","ebay"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/267464"}},{"articleId":250336,"title":"eBay Business Tips for Protecting Your Data","slug":"ebay-business-tips-protecting-data","categoryList":["technology","notable-websites","ebay"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/250336"}},{"articleId":250332,"title":"Having QuickBooks Report on Your eBay Business","slug":"quickbooks-report-ebay-business","categoryList":["technology","notable-websites","ebay"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/250332"}},{"articleId":250327,"title":"Becoming an eBay Elite Seller","slug":"becoming-ebay-elite-seller","categoryList":["technology","notable-websites","ebay"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/250327"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;notable-websites&quot;,&quot;ebay&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671fd1645edcd\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;notable-websites&quot;,&quot;ebay&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671fd16460de3\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Explore","lifeExpectancy":"Six months","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":222944},{"headers":{"creationTime":"2018-12-04T20:01:08+00:00","modifiedTime":"2024-10-28T14:08:39+00:00","timestamp":"2024-10-28T15:01:14+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Software","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33618"},"slug":"software","categoryId":33618},{"name":"Microsoft Products","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33642"},"slug":"microsoft-products","categoryId":33642},{"name":"General Microsoft","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33652"},"slug":"general-microsoft","categoryId":33652}],"title":"How to Search and Filter an Access 2019 Database","strippedTitle":"how to search and filter an access 2019 database","slug":"how-to-search-and-filter-an-access-2019-database","canonicalUrl":"","seo":{"metaDescription":"A paper database is useful for storing information, but not so useful for finding it again. With Access 2019, searching and finding information is easy. If you ","noIndex":0,"noFollow":0},"content":"A paper database is useful for storing information, but not so useful for finding it again. With Access 2019, searching and finding information is easy. If you have a thousand business cards stored in a Rolodex file, how much time do you want to waste trying to find the phone number of a single person? With Access 2019, that is no longer a concern.\r\n\r\nSearching a database is crucial to make your data useful, so Access provides two ways to search a database:\r\n<ul>\r\n \t<li>Search for a specific record.</li>\r\n \t<li>Use a filter to show one or more records that meet a specific criterion.</li>\r\n</ul>\r\n<h2 id=\"tab1\" >Searching MS Access for a specific record</h2>\r\nThe simplest type of search looks for a specific record. To search for a record, you need to know the data stored in at least one of its fields, such as a phone number or an email address.\r\n\r\nThe more information you already know, the more likely Access will find the one record you want. If you search for all records that contain the first name <em>Bill,</em> Access could find dozens of records. If you just search for all records that contain the first name <em>Bill,</em> the last name <em>Johnson,</em> and a state address of <em>Alaska,</em> Access will likely find just the record you want.\r\n\r\nTo search for a specific record in an Access database table, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to search. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>In the Find group, click the Find icon. The Find and Replace dialog box appears.\r\n\r\n[caption id=\"attachment_257934\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257934 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-find-record-access.jpg\" alt=\"record search Access 2019\" width=\"535\" height=\"300\" /> Search for a specific record in a database table.[/caption]</li>\r\n \t<li>Click in the Find What text box and type the data you know is stored in the record you want to find. For example, if you want to find the phone number of a person but you know only the person’s last name, type the last name in the Find What text box.</li>\r\n \t<li>Click the Look In list box and choose Current field or Current document (searches in all fields).</li>\r\n \t<li>(Optional) Click in the Match list box and choose one of the following:\r\n<ul>\r\n \t<li><em>Any Part of Field:</em> The Find What text can appear in any part of a field.</li>\r\n \t<li><em>Whole Field:</em> The Find What text is the only text stored in a field.</li>\r\n \t<li><em>Start of Field:</em> The Find What text can be only at the beginning of a field.</li>\r\n</ul>\r\n</li>\r\n \t<li>(Optional) Click in the Search list box and choose one of the following:\r\n<ul>\r\n \t<li><em>Up:</em> Searches from the record where the cursor appears, up to the beginning of the database table</li>\r\n \t<li><em>Down:</em> Searches from the record where the cursor appears, down to the end of the database table</li>\r\n \t<li><em>All:</em> Searches the entire database table</li>\r\n</ul>\r\n</li>\r\n \t<li>Click Find Next. Access highlights the field where it finds the text you typed in Step 4.</li>\r\n \t<li>Repeat Step 8 to search for more records that may contain the text you typed in Step 4.</li>\r\n \t<li>Click Cancel or the Close button.</li>\r\n</ol>\r\n<h2 id=\"tab2\" >Filtering an Access database</h2>\r\nSearching a database is easy but somewhat limited because you can retrieve only a single record at a time that matches any text that you want to find. If you want to find multiple records, you can use a filter.\r\n\r\nA <em>filter</em> lets you tell Access to display only those records that meet certain criteria, such all records that contain people who earn more than $200,000 a year, are currently married, live in Las Vegas, Nevada, and own two or more cats.\r\n\r\nTo filter a database table, you must tell Access which field or fields to use as a filter, and then you must define the criteria for that filter. For example, if you want to filter your database table to see only records listing the names of people who are at least 65, you filter the Age field and set the criterion to <em>Greater than or equal to 65.</em>\r\n<p class=\"article-tips remember\">Filtering simply hides all records in a database table that don’t match your criteria. Filtering doesn’t delete or erase any records.</p>\r\n\r\n<h3>Using an exact match for a filter in Access 2019</h3>\r\nThe simplest filtering criterion searches for an exact match. When you filter a field by an exact match, you’re telling Access, “I want to see only those records that contain this specific chunk of data in this particular field.” By using an exact match filter, you can display, for example, only the records that contain CA in the State field.\r\n\r\nTo filter a database table, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>Click in the field (column) that you want to use as a filter.</li>\r\n \t<li>In the Sort & Filter group, click the Filter icon.A pop-up menu appears. You can either\r\n<ul>\r\n \t<li>Select or clear check boxes from this menu.</li>\r\n \t<li>Continue with Steps 5 through 7 for more flexibility.</li>\r\n</ul>\r\n</li>\r\n \t<li>Choose Text Filters. A submenu appears.\r\n\r\n[caption id=\"attachment_257936\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257936 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-menu.jpg\" alt=\"Access Filter menu\" width=\"535\" height=\"300\" /> The Filter pop-up menu lets you specify the criteria for a specific field.[/caption]</li>\r\n \t<li>Choose a filter option, such as Equals, Begins With, or Contains. A Custom Filter dialog box appears.\r\n\r\n[caption id=\"attachment_257938\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257938 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-custom-filter.jpg\" alt=\"custonm filter Access 2019\" width=\"535\" height=\"300\" /> The Custom Filter dialog box lets you further refine a filter criteria.[/caption]</li>\r\n \t<li>Type the data you want to find and click OK. Access displays your filtered data, and a filter icon appears in the column heading. Access remembers your filter settings. If you want to clear the filter, click the filter icon in the column heading; when a pop-up menu appears, choose Clear Filter.\r\n\r\n[caption id=\"attachment_257941\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257941 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-clear-access-filter.jpg\" alt=\"clear Access filter\" width=\"535\" height=\"263\" /> You can clear a filter from a column heading.[/caption]</li>\r\n</ol>\r\n<p class=\"article-tips remember\">To view all the data in your database table, click the Home tab. Then in the Sort & Filter group, click the Toggle Filter icon.</p>\r\n\r\n<h3>Filtering Access databases by form</h3>\r\nOne problem with defining filters in Datasheet view is that you have all your database table records cluttering the screen. To avoid this problem, Access lets you define filters by using a <em>form,</em> which basically displays an empty record so you can click the fields that you want to use to filter your database table.\r\n\r\nTo define a filter by form, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table that you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>In the Sort & Filter group, click the Advanced icon. A pull-down menu appears.</li>\r\n \t<li>Choose Filter by Form.\r\n\r\n[caption id=\"attachment_257943\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257943 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-advanced-filtering-access.jpg\" alt=\"advanced filtering Access database\" width=\"535\" height=\"135\" /> The Advanced pop-up menu lets you specify the criteria for a specific field.[/caption]\r\n\r\nAccess displays a blank record.</li>\r\n \t<li>Click in any field, then type the data you want to filter such as a last name.</li>\r\n \t<li>In the Sort & Filter group, click the Advanced icon and then click Apply Filter/Sort. Access displays a filtered view of your database table.</li>\r\n</ol>\r\n<p class=\"article-tips remember\">You can click the Toggle Filter icon again to view all the data in your database table.</p>\r\n\r\n<h3>Using a filter criteria in Access 2019</h3>\r\nSearching for an exact match in a field can be handy, but sometimes you may want to see records that meet certain criteria, such as finding the names of everyone whose salary is greater than $50,000 a year. Instead of filtering by an exact match, you have to define the filter criteria.\r\n\r\nThe type of data stored in each field determines the type of criteria you can create. Three common types of data stored in fields are text, numbers, and dates, which you can filter in different ways.\r\n<h4>Common Criteria for Filtering Text Data</h4>\r\n<table width=\"546\">\r\n<thead>\r\n<tr>\r\n<td width=\"177\">Filtering Criteria</td>\r\n<td width=\"369\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"177\">Equals</td>\r\n<td width=\"369\">Field must match filter text exactly.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Equal</td>\r\n<td width=\"369\">Field must not match filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Begins With</td>\r\n<td width=\"369\">Field must start with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Begin With</td>\r\n<td width=\"369\">Field must not begin with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Contains</td>\r\n<td width=\"369\">Field must contain the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Contain</td>\r\n<td width=\"369\">Field must not contain any part of the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Ends With</td>\r\n<td width=\"369\">Field ends with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not End With</td>\r\n<td width=\"369\">Field does not end with the filter text.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h4>Common Criteria for Filtering Numeric Data</h4>\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"198\">Filtering Criteria</td>\r\n<td width=\"350\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"198\">Equals</td>\r\n<td width=\"350\">Field must equal filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Does Not Equal</td>\r\n<td width=\"350\">Field must not equal filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Less Than or Equal To</td>\r\n<td width=\"350\">Field must contain a number less than or equal to the filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Greater Than or Equal To</td>\r\n<td width=\"350\">Field must contain a number greater than or equal to the filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Between</td>\r\n<td width=\"350\">Field must contain a number that falls between two filter numbers.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h4>Common Criteria for Filtering Dates</h4>\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"222\">Filtering Criteria</td>\r\n<td width=\"271\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"222\">Equals</td>\r\n<td width=\"271\">Field must equal the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">Does Not Equal</td>\r\n<td width=\"271\">Field must not equal the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">On or Before</td>\r\n<td width=\"271\">Field date must be equal or earlier than the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">On or After</td>\r\n<td width=\"271\">Field date must be equal or later than the filter date.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\nTo create the filter criteria, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>Click in the field (column) that you want to use as a filter.</li>\r\n \t<li>In the Sort & Filter group, click the Filter icon. A pop-up menu appears.</li>\r\n \t<li>Select the Filters option, such as Text Filters or Number Filters. A submenu of filter options appears.\r\n\r\n[caption id=\"attachment_257945\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257945 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-options.jpg\" alt=\"Access2019 filter options\" width=\"535\" height=\"216\" /> The Filter pop-up menu lets you specify the criteria for a specific field.[/caption]</li>\r\n \t<li>Click a filter option, such as Between or Less Than. The Custom Filter dialog box appears. The Custom Filter dialog box contains the name of your filter option, such as Between Numbers or Less Than.\r\n\r\n[caption id=\"attachment_257946\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257946 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-criteria.jpg\" alt=\"Access 2019 filter criteria\" width=\"535\" height=\"174\" /> Type a value for your filter criteria.[/caption]</li>\r\n \t<li>Type one or more values in each text box in the Custom Filter dialog box, and then click OK. Access filters your database table according to your criteria.</li>\r\n \t<li>Repeat Steps 5 through 7 for each additional filter you want to add.</li>\r\n</ol>\r\n<p class=\"article-tips remember\">You can click the Toggle Filter icon again to view all the data in your database table.</p>\r\n\r\n<h3>Clearing a filter in Access 2019</h3>\r\nWhen you apply a filter to a database table, you see only those records that match that filter. Access displays a Filtered message at the bottom of the screen to let you know when you’re looking at a filtered database table.\r\n\r\nTo remove a filter so you can see all the records, choose one of the following:\r\n<ul>\r\n \t<li>Click the Toggle Filter icon in the Sort & Filter group.</li>\r\n \t<li>Click the Filtered or Unfiltered button on the status bar near the bottom of the screen.</li>\r\n</ul>\r\nAccess temporarily turns off any filters so you can see all the information stored in your database table.\r\n<p class=\"article-tips remember\">When you choose the Save command (Ctrl+S) to save a database table, Access also saves your last filter. The next time you open that database table, you’ll be able to use the last filter you created. If you want to save multiple filters, you’ll have to save them as a query.</p>\r\n<p class=\"article-tips tip\">See these <a href=\"https://www.dummies.com/article/technology/software/microsoft-products/access/handy-access-2019-keyboard-shortcuts-257187/\">handy Access keyboard shortcuts</a> for further information.</p>","description":"A paper database is useful for storing information, but not so useful for finding it again. With Access 2019, searching and finding information is easy. If you have a thousand business cards stored in a Rolodex file, how much time do you want to waste trying to find the phone number of a single person? With Access 2019, that is no longer a concern.\r\n\r\nSearching a database is crucial to make your data useful, so Access provides two ways to search a database:\r\n<ul>\r\n \t<li>Search for a specific record.</li>\r\n \t<li>Use a filter to show one or more records that meet a specific criterion.</li>\r\n</ul>\r\n<h2 id=\"tab1\" >Searching MS Access for a specific record</h2>\r\nThe simplest type of search looks for a specific record. To search for a record, you need to know the data stored in at least one of its fields, such as a phone number or an email address.\r\n\r\nThe more information you already know, the more likely Access will find the one record you want. If you search for all records that contain the first name <em>Bill,</em> Access could find dozens of records. If you just search for all records that contain the first name <em>Bill,</em> the last name <em>Johnson,</em> and a state address of <em>Alaska,</em> Access will likely find just the record you want.\r\n\r\nTo search for a specific record in an Access database table, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to search. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>In the Find group, click the Find icon. The Find and Replace dialog box appears.\r\n\r\n[caption id=\"attachment_257934\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257934 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-find-record-access.jpg\" alt=\"record search Access 2019\" width=\"535\" height=\"300\" /> Search for a specific record in a database table.[/caption]</li>\r\n \t<li>Click in the Find What text box and type the data you know is stored in the record you want to find. For example, if you want to find the phone number of a person but you know only the person’s last name, type the last name in the Find What text box.</li>\r\n \t<li>Click the Look In list box and choose Current field or Current document (searches in all fields).</li>\r\n \t<li>(Optional) Click in the Match list box and choose one of the following:\r\n<ul>\r\n \t<li><em>Any Part of Field:</em> The Find What text can appear in any part of a field.</li>\r\n \t<li><em>Whole Field:</em> The Find What text is the only text stored in a field.</li>\r\n \t<li><em>Start of Field:</em> The Find What text can be only at the beginning of a field.</li>\r\n</ul>\r\n</li>\r\n \t<li>(Optional) Click in the Search list box and choose one of the following:\r\n<ul>\r\n \t<li><em>Up:</em> Searches from the record where the cursor appears, up to the beginning of the database table</li>\r\n \t<li><em>Down:</em> Searches from the record where the cursor appears, down to the end of the database table</li>\r\n \t<li><em>All:</em> Searches the entire database table</li>\r\n</ul>\r\n</li>\r\n \t<li>Click Find Next. Access highlights the field where it finds the text you typed in Step 4.</li>\r\n \t<li>Repeat Step 8 to search for more records that may contain the text you typed in Step 4.</li>\r\n \t<li>Click Cancel or the Close button.</li>\r\n</ol>\r\n<h2 id=\"tab2\" >Filtering an Access database</h2>\r\nSearching a database is easy but somewhat limited because you can retrieve only a single record at a time that matches any text that you want to find. If you want to find multiple records, you can use a filter.\r\n\r\nA <em>filter</em> lets you tell Access to display only those records that meet certain criteria, such all records that contain people who earn more than $200,000 a year, are currently married, live in Las Vegas, Nevada, and own two or more cats.\r\n\r\nTo filter a database table, you must tell Access which field or fields to use as a filter, and then you must define the criteria for that filter. For example, if you want to filter your database table to see only records listing the names of people who are at least 65, you filter the Age field and set the criterion to <em>Greater than or equal to 65.</em>\r\n<p class=\"article-tips remember\">Filtering simply hides all records in a database table that don’t match your criteria. Filtering doesn’t delete or erase any records.</p>\r\n\r\n<h3>Using an exact match for a filter in Access 2019</h3>\r\nThe simplest filtering criterion searches for an exact match. When you filter a field by an exact match, you’re telling Access, “I want to see only those records that contain this specific chunk of data in this particular field.” By using an exact match filter, you can display, for example, only the records that contain CA in the State field.\r\n\r\nTo filter a database table, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>Click in the field (column) that you want to use as a filter.</li>\r\n \t<li>In the Sort & Filter group, click the Filter icon.A pop-up menu appears. You can either\r\n<ul>\r\n \t<li>Select or clear check boxes from this menu.</li>\r\n \t<li>Continue with Steps 5 through 7 for more flexibility.</li>\r\n</ul>\r\n</li>\r\n \t<li>Choose Text Filters. A submenu appears.\r\n\r\n[caption id=\"attachment_257936\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257936 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-menu.jpg\" alt=\"Access Filter menu\" width=\"535\" height=\"300\" /> The Filter pop-up menu lets you specify the criteria for a specific field.[/caption]</li>\r\n \t<li>Choose a filter option, such as Equals, Begins With, or Contains. A Custom Filter dialog box appears.\r\n\r\n[caption id=\"attachment_257938\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257938 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-custom-filter.jpg\" alt=\"custonm filter Access 2019\" width=\"535\" height=\"300\" /> The Custom Filter dialog box lets you further refine a filter criteria.[/caption]</li>\r\n \t<li>Type the data you want to find and click OK. Access displays your filtered data, and a filter icon appears in the column heading. Access remembers your filter settings. If you want to clear the filter, click the filter icon in the column heading; when a pop-up menu appears, choose Clear Filter.\r\n\r\n[caption id=\"attachment_257941\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257941 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-clear-access-filter.jpg\" alt=\"clear Access filter\" width=\"535\" height=\"263\" /> You can clear a filter from a column heading.[/caption]</li>\r\n</ol>\r\n<p class=\"article-tips remember\">To view all the data in your database table, click the Home tab. Then in the Sort & Filter group, click the Toggle Filter icon.</p>\r\n\r\n<h3>Filtering Access databases by form</h3>\r\nOne problem with defining filters in Datasheet view is that you have all your database table records cluttering the screen. To avoid this problem, Access lets you define filters by using a <em>form,</em> which basically displays an empty record so you can click the fields that you want to use to filter your database table.\r\n\r\nTo define a filter by form, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table that you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>In the Sort & Filter group, click the Advanced icon. A pull-down menu appears.</li>\r\n \t<li>Choose Filter by Form.\r\n\r\n[caption id=\"attachment_257943\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257943 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-advanced-filtering-access.jpg\" alt=\"advanced filtering Access database\" width=\"535\" height=\"135\" /> The Advanced pop-up menu lets you specify the criteria for a specific field.[/caption]\r\n\r\nAccess displays a blank record.</li>\r\n \t<li>Click in any field, then type the data you want to filter such as a last name.</li>\r\n \t<li>In the Sort & Filter group, click the Advanced icon and then click Apply Filter/Sort. Access displays a filtered view of your database table.</li>\r\n</ol>\r\n<p class=\"article-tips remember\">You can click the Toggle Filter icon again to view all the data in your database table.</p>\r\n\r\n<h3>Using a filter criteria in Access 2019</h3>\r\nSearching for an exact match in a field can be handy, but sometimes you may want to see records that meet certain criteria, such as finding the names of everyone whose salary is greater than $50,000 a year. Instead of filtering by an exact match, you have to define the filter criteria.\r\n\r\nThe type of data stored in each field determines the type of criteria you can create. Three common types of data stored in fields are text, numbers, and dates, which you can filter in different ways.\r\n<h4>Common Criteria for Filtering Text Data</h4>\r\n<table width=\"546\">\r\n<thead>\r\n<tr>\r\n<td width=\"177\">Filtering Criteria</td>\r\n<td width=\"369\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"177\">Equals</td>\r\n<td width=\"369\">Field must match filter text exactly.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Equal</td>\r\n<td width=\"369\">Field must not match filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Begins With</td>\r\n<td width=\"369\">Field must start with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Begin With</td>\r\n<td width=\"369\">Field must not begin with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Contains</td>\r\n<td width=\"369\">Field must contain the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not Contain</td>\r\n<td width=\"369\">Field must not contain any part of the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Ends With</td>\r\n<td width=\"369\">Field ends with the filter text.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"177\">Does Not End With</td>\r\n<td width=\"369\">Field does not end with the filter text.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h4>Common Criteria for Filtering Numeric Data</h4>\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"198\">Filtering Criteria</td>\r\n<td width=\"350\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"198\">Equals</td>\r\n<td width=\"350\">Field must equal filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Does Not Equal</td>\r\n<td width=\"350\">Field must not equal filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Less Than or Equal To</td>\r\n<td width=\"350\">Field must contain a number less than or equal to the filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Greater Than or Equal To</td>\r\n<td width=\"350\">Field must contain a number greater than or equal to the filter number.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"198\">Between</td>\r\n<td width=\"350\">Field must contain a number that falls between two filter numbers.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\n<h4>Common Criteria for Filtering Dates</h4>\r\n<table>\r\n<thead>\r\n<tr>\r\n<td width=\"222\">Filtering Criteria</td>\r\n<td width=\"271\">Description</td>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n<tr>\r\n<td width=\"222\">Equals</td>\r\n<td width=\"271\">Field must equal the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">Does Not Equal</td>\r\n<td width=\"271\">Field must not equal the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">On or Before</td>\r\n<td width=\"271\">Field date must be equal or earlier than the filter date.</td>\r\n</tr>\r\n<tr>\r\n<td width=\"222\">On or After</td>\r\n<td width=\"271\">Field date must be equal or later than the filter date.</td>\r\n</tr>\r\n</tbody>\r\n</table>\r\nTo create the filter criteria, follow these steps:\r\n<ol>\r\n \t<li>In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database.</li>\r\n \t<li>Click the Home tab.</li>\r\n \t<li>Click in the field (column) that you want to use as a filter.</li>\r\n \t<li>In the Sort & Filter group, click the Filter icon. A pop-up menu appears.</li>\r\n \t<li>Select the Filters option, such as Text Filters or Number Filters. A submenu of filter options appears.\r\n\r\n[caption id=\"attachment_257945\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257945 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-options.jpg\" alt=\"Access2019 filter options\" width=\"535\" height=\"216\" /> The Filter pop-up menu lets you specify the criteria for a specific field.[/caption]</li>\r\n \t<li>Click a filter option, such as Between or Less Than. The Custom Filter dialog box appears. The Custom Filter dialog box contains the name of your filter option, such as Between Numbers or Less Than.\r\n\r\n[caption id=\"attachment_257946\" align=\"aligncenter\" width=\"535\"]<img class=\"wp-image-257946 size-full\" src=\"https://www.dummies.com/wp-content/uploads/office-2019-access-filter-criteria.jpg\" alt=\"Access 2019 filter criteria\" width=\"535\" height=\"174\" /> Type a value for your filter criteria.[/caption]</li>\r\n \t<li>Type one or more values in each text box in the Custom Filter dialog box, and then click OK. Access filters your database table according to your criteria.</li>\r\n \t<li>Repeat Steps 5 through 7 for each additional filter you want to add.</li>\r\n</ol>\r\n<p class=\"article-tips remember\">You can click the Toggle Filter icon again to view all the data in your database table.</p>\r\n\r\n<h3>Clearing a filter in Access 2019</h3>\r\nWhen you apply a filter to a database table, you see only those records that match that filter. Access displays a Filtered message at the bottom of the screen to let you know when you’re looking at a filtered database table.\r\n\r\nTo remove a filter so you can see all the records, choose one of the following:\r\n<ul>\r\n \t<li>Click the Toggle Filter icon in the Sort & Filter group.</li>\r\n \t<li>Click the Filtered or Unfiltered button on the status bar near the bottom of the screen.</li>\r\n</ul>\r\nAccess temporarily turns off any filters so you can see all the information stored in your database table.\r\n<p class=\"article-tips remember\">When you choose the Save command (Ctrl+S) to save a database table, Access also saves your last filter. The next time you open that database table, you’ll be able to use the last filter you created. If you want to save multiple filters, you’ll have to save them as a query.</p>\r\n<p class=\"article-tips tip\">See these <a href=\"https://www.dummies.com/article/technology/software/microsoft-products/access/handy-access-2019-keyboard-shortcuts-257187/\">handy Access keyboard shortcuts</a> for further information.</p>","blurb":"","authors":[{"authorId":9043,"name":"Wallace Wang","slug":"wallace-wang","description":" <p><b>Wallace Wang</b> specializes in making complex topics understandable. His assorted <i>For Dummies</i> tech books have sold nearly half a million copies. He has a master&#8217;s degree in computer science along with side hustles in stand-up comedy and screenwriting because life is too short to focus on just one thing.</p> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9043"}}],"primaryCategoryTaxonomy":{"categoryId":33652,"title":"General Microsoft","slug":"general-microsoft","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33652"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[{"label":"Searching MS Access for a specific record","target":"#tab1"},{"label":"Filtering an Access database","target":"#tab2"}],"relatedArticles":{"fromBook":[{"articleId":258146,"title":"10 Ways to Make Office 2019 Easier to Use","slug":"10-ways-to-make-office-2019-easier-to-use","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258146"}},{"articleId":258139,"title":"Access Report Design: Applying Themes and Conditional Formatting in Access 2019","slug":"access-report-design-applying-themes-and-conditional-formatting-in-access-2019","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258139"}},{"articleId":258132,"title":"Access 2019 Reports: Editing the Data in a Report","slug":"access-2019-reports-editing-the-data-in-a-report","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258132"}},{"articleId":258092,"title":"How to Use the Report Wizard in Access 2019","slug":"how-to-use-the-report-wizard-in-access-2019","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258092"}},{"articleId":258013,"title":"10 Useful Features in Office 2019","slug":"10-useful-features-in-office-2019","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/258013"}}],"fromCategory":[{"articleId":294664,"title":"Windows 365 For Dummies Cheat Sheet","slug":"windows-365-for-dummies-cheat-sheet","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/294664"}},{"articleId":291623,"title":"Office 2021 For Macs For Dummies Cheat Sheet","slug":"office-2021-for-macs-for-dummies-cheat-sheet","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/291623"}},{"articleId":290233,"title":"Microsoft 365 For Dummies Cheat Sheet","slug":"microsoft-365-for-dummies-cheat-sheet","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/290233"}},{"articleId":290196,"title":"Office 2021 All-in-One For Dummies Cheat Sheet","slug":"office-2021-all-in-one-for-dummies-cheat-sheet","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/290196"}},{"articleId":289688,"title":"Office 2021 For Seniors For Dummies Cheat Sheet","slug":"office-2021-for-seniors-for-dummies-cheat-sheet","categoryList":["technology","software","microsoft-products","general-microsoft"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/289688"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281802,"slug":"office-2019-for-dummies","isbn":"9781119513988","categoryList":["technology","software","microsoft-products","general-microsoft"],"amazon":{"default":"https://www.amazon.com/gp/product/1119513987/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1119513987/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119513987-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1119513987/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1119513987/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/office-2019-for-dummies-cover-9781119513988-203x255.jpg","width":203,"height":255},"title":"Office 2019 For Dummies","testBankPinActivationLink":"","bookOutOfPrint":false,"authorsInfo":"<p><b data-author-id=\"9043\">Wallace Wang</b> is the bestselling author of more than 50 computer books, with over three million of his <i>For Dummies</i> books in print. They include numerous versions of <i>Office For Dummies</i> as well as <i>Beginning Programming For Dummies</i>. When not playing with computers, Wallace splits his time between teaching, writing, game designing, screenwriting, and stand-up comedy. </p>","authors":[{"authorId":9043,"name":"Wallace Wang","slug":"wallace-wang","description":" <p><b>Wallace Wang</b> specializes in making complex topics understandable. His assorted <i>For Dummies</i> tech books have sold nearly half a million copies. He has a master&#8217;s degree in computer science along with side hustles in stand-up comedy and screenwriting because life is too short to focus on just one thing.</p> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9043"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;software&quot;,&quot;microsoft-products&quot;,&quot;general-microsoft&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119513988&quot;]}]\" id=\"du-slot-671fa73ab626a\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;software&quot;,&quot;microsoft-products&quot;,&quot;general-microsoft&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119513988&quot;]}]\" id=\"du-slot-671fa73ab69eb\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"Six months","lifeExpectancySetFrom":"2024-10-28T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":257932},{"headers":{"creationTime":"2016-08-18T14:13:09+00:00","modifiedTime":"2024-10-28T13:48:38+00:00","timestamp":"2024-10-28T15:01:13+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Information Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33572"},"slug":"information-technology","categoryId":33572},{"name":"Networking","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33581"},"slug":"networking","categoryId":33581},{"name":"General Networking","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33585"},"slug":"general-networking","categoryId":33585}],"title":"Configuring Network Connections for Windows 10","strippedTitle":"configuring network connections for windows 10","slug":"configuring-network-connections-windows-10","canonicalUrl":"","seo":{"metaDescription":"Windows usually detects the presence of a network adapter automatically; typically, you don’t have to install device drivers manually for the adapter. When Wind","noIndex":0,"noFollow":0},"content":"Windows usually detects the presence of a network adapter automatically; typically, you don’t have to install device drivers manually for the adapter. When Windows detects a network adapter, Windows automatically creates a network connection and configures it to support basic networking protocols. You may need to change the configuration of a network connection manually, however.\r\n\r\nThe following steps show you how to configure your network adapter on a Windows 10 system:\r\n\r\n ","description":"Windows usually detects the presence of a network adapter automatically; typically, you don’t have to install device drivers manually for the adapter. When Windows detects a network adapter, Windows automatically creates a network connection and configures it to support basic networking protocols. You may need to change the configuration of a network connection manually, however.\r\n\r\nThe following steps show you how to configure your network adapter on a Windows 10 system:\r\n\r\n ","blurb":"","authors":[{"authorId":8946,"name":"Doug Lowe","slug":"doug-lowe","description":" <p><b>Doug Lowe </b>is the information technology director at Blair, Church & Flynn Consulting Engineers, a civil engineering firm. He has written more than 50 <i>For Dummies</i> books on topics ranging from Java to electronics to PowerPoint.</p> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/8946"}}],"primaryCategoryTaxonomy":{"categoryId":33585,"title":"General Networking","slug":"general-networking","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33585"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":290654,"title":"Windows Server 2022 and PowerShell All-in-One For Dummies Cheat Sheet","slug":"windows-server-2022-and-powershell-all-in-one-for-dummies-cheat-sheet","categoryList":["technology","information-technology","networking","general-networking"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/290654"}},{"articleId":271553,"title":"What Is a Network: An Overview of Necessary Networking Components","slug":"what-is-a-network-an-overview-of-necessary-networking-components","categoryList":["technology","information-technology","networking","general-networking"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/271553"}},{"articleId":253759,"title":"The 2 Pillars of Cybersecurity","slug":"2-pillars-cybersecurity","categoryList":["technology","information-technology","networking","general-networking"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253759"}},{"articleId":253756,"title":"Securing the Human Firewall","slug":"securing-human-firewall","categoryList":["technology","information-technology","networking","general-networking"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/253756"}},{"articleId":222508,"title":"Network Administration: How to Create a New User in Active Directory","slug":"network-administration-create-new-user-windows-server-2016","categoryList":["technology","information-technology","networking","general-networking"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/222508"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;networking&quot;,&quot;general-networking&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671fa739c15f1\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;networking&quot;,&quot;general-networking&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-671fa739c1e99\"></div></div>"},"articleType":{"articleType":"Step by Step","articleList":null,"content":[{"title":"Click the Start icon (or press the Start button on the keyboard), and then tap or click Settings.","thumb":{"src":null,"width":0,"height":0},"image":{"src":null,"width":0,"height":0},"content":"<p>The Settings page appears.</p>\n"},{"title":"Click Network & Internet.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Network-Internet-page.jpg","width":220,"height":173},"image":{"src":"https://www.dummies.com/wp-content/uploads/Network-Internet-page.jpg","width":535,"height":422},"content":"<p>The Network &amp; Internet page appears.</p>\n"},{"title":"Click Ethernet.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Ethernet-settings-page.jpg","width":220,"height":173},"image":{"src":"https://www.dummies.com/wp-content/uploads/Ethernet-settings-page.jpg","width":535,"height":422},"content":"<p>The Ethernet settings page appears.</p>\n"},{"title":"Click Change Adapter Options.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Network-Connections-page.jpg","width":220,"height":165},"image":{"src":"https://www.dummies.com/wp-content/uploads/Network-Connections-page.jpg","width":535,"height":403},"content":"<p>The Network Connections page appears. This page lists each of your network adapters. In this case, only a single wired Ethernet adapter is shown. If the device has more than one adapter, additional adapters will appear on this page.</p>\n"},{"title":"Right-click the connection that you want to configure and then choose Properties from the contextual menu that appears.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Ethernet-Properties-198x255.jpg","width":198,"height":255},"image":{"src":"https://www.dummies.com/wp-content/uploads/Ethernet-Properties2.jpg","width":535,"height":689},"content":"<p>This action opens the Ethernet Properties dialog box.</p>\n"},{"title":"To configure the network adapter card settings, click Configure.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Properties-220x255.jpg","width":220,"height":255},"image":{"src":"https://www.dummies.com/wp-content/uploads/Properties2.jpg","width":535,"height":620},"content":"<p>The Properties dialog box for your network adapter appears. This dialog box has seven tabs that let you configure the adapter:</p>\n<ul>\n<li><em>General:</em> Shows basic information about the adapter, such as the device type and status.</li>\n<li><em>Advanced:</em> Lets you set a variety of device-specific parameters that affect the operation of the adapter.</li>\n<li><em>About:</em> Displays information about the device’s patent protection.</li>\n<li><em>Driver</em>: Displays information about the device driver that’s bound to the NIC and lets you update the driver to a newer version, roll back the driver to a previously working version, or uninstall the driver.</li>\n<li><em>Details:</em> With this tab, you can inspect various properties of the adapter such as the date and version of the device driver. To view the setting of a particular property, select the property name from the drop-down list.</li>\n<li><em>Events:</em> Lists recent events that have been logged for the device.</li>\n<li><em>Power Management:</em> Lets you configure power management options for the device.</li>\n</ul>\n<p>When you click OK to dismiss the dialog box, the network connection’s Properties dialog box closes and you’re returned to the Network Connections page. Right-click the network adapter and choose Properties again to continue the procedure.</p>\n"},{"title":"Review the list of connection items listed in the Properties dialog box.","thumb":{"src":null,"width":0,"height":0},"image":{"src":null,"width":0,"height":0},"content":"<ul>\n<li><em>Client for Microsoft Networks:</em> This item is required if you want to access a Microsoft Windows network. It should always be present.</li>\n<li><em>File and Printer Sharing for Microsoft Networks:</em> This item allows your computer to share its files or printers with other computers on the network.This option is usually used with peer-to-peer networks, but you can use it even if your network has dedicated servers. If you don’t plan to share files or printers on the client computer, however, you should disable this item.</li>\n<li><em>Internet Protocol Version 4 (TCP/IPv4):</em> This item enables the client computer to communicate by using the version 4 standard TCP/IP protocol.</li>\n<li><em>Internet Protocol Version 6 (TCP/IPv6):</em> This item enables version 6 of the standard TCP/IP protocol. Typically, both IP4 and IP6 are enabled, even though most networks rely primarily on IP4.</li>\n</ul>\n"},{"title":"If a protocol that you need isn’t listed, click the Install button to add the needed protocol.","thumb":{"src":null,"width":0,"height":0},"image":{"src":null,"width":0,"height":0},"content":"<p>A dialog box appears, asking whether you want to add a network client, protocol, or service. Click Protocol and then click Add. A list of available protocols appears. Select the one you want to add; then click OK.</p>\n"},{"title":"To remove a network item that you don’t need (such as File and Printer Sharing for Microsoft Networks), select the item, and click the Uninstall button.","thumb":{"src":null,"width":0,"height":0},"image":{"src":null,"width":0,"height":0},"content":"<p>For security reasons, you should make it a point to remove any clients, protocols, or services that you don’t need.</p>\n"},{"title":"To configure TCP/IP settings, click Internet Protocol (TCP/IP); click Properties to display the TCP/IP Properties dialog box; adjust the settings; and then click OK.","thumb":{"src":"https://www.dummies.com/wp-content/uploads/Configuring-TCP-IP.jpg","width":220,"height":250},"image":{"src":"https://www.dummies.com/wp-content/uploads/Configuring-TCP-IP2.jpg","width":535,"height":609},"content":"<p>The TCP/IP Properties dialog box lets you choose among these options:</p>\n<ul>\n<li><em>Obtain an IP Address Automatically:</em> Choose this option if your network has a DHCP server that assigns IP addresses automatically. Choosing this option dramatically simplifies administering TCP/IP on your network.</li>\n<li><em>Use the Following IP Address:</em> If your computer must have a specific IP address, choose this option and then type the computer’s IP address, subnet mask, and default gateway address.</li>\n<li><em>Obtain DNS Server Address Automatically:</em> The DHCP server can also provide the address of the Domain Name System (DNS) server that the computer should use. Choose this option if your network has a DHCP server.</li>\n<li><em>Use the Following DNS Server Addresses:</em> Choose this option if a DNS server isn’t available. Then type the IP addresses of the primary and secondary DNS servers.</li>\n</ul>\n"}],"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"One year","lifeExpectancySetFrom":"2024-08-27T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":221858},{"headers":{"creationTime":"2024-10-17T18:18:12+00:00","modifiedTime":"2024-10-17T18:18:12+00:00","timestamp":"2024-10-17T21:01:11+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Information Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33572"},"slug":"information-technology","categoryId":33572},{"name":"AI","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33574"},"slug":"ai","categoryId":33574},{"name":"Generative AI","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33576"},"slug":"general-ai","categoryId":33576}],"title":"Generative AI For Dummies Cheat Sheet","strippedTitle":"generative ai for dummies cheat sheet","slug":"generative-ai-for-dummies-cheat-sheet","canonicalUrl":"","seo":{"metaDescription":"Navigate the world of Generative AI with ease. Our cheat sheet offers advanced prompting strategies and practical tips to optimize your AI tool usage.","noIndex":0,"noFollow":0},"content":"The first public release of ChatGPT ignited the world’s demand for increasingly sophisticated Generative AI (GenAI) models and tools, and the market was quick to deliver. But what’s the use of having so many GenAI tools if you get stuck using them? And make no mistake, everyone gets stuck quite often!\r\n\r\nThis cheat sheet helps you get the very best results by introducing you to advanced (but pretty easy) prompting techniques and giving you useful tips on how to choose models or applications that are right for the task.","description":"The first public release of ChatGPT ignited the world’s demand for increasingly sophisticated Generative AI (GenAI) models and tools, and the market was quick to deliver. But what’s the use of having so many GenAI tools if you get stuck using them? And make no mistake, everyone gets stuck quite often!\r\n\r\nThis cheat sheet helps you get the very best results by introducing you to advanced (but pretty easy) prompting techniques and giving you useful tips on how to choose models or applications that are right for the task.","blurb":"","authors":[{"authorId":34669,"name":"Pam Baker","slug":"pamela-baker","description":"<b>Pam Baker </b>is a veteran business analyst, speaker, and journalist whose work is focused on big data, artificial intelligence, machine learning, business intelligence, and data analysis. She is the author of <i>Data Divination – Big Data Strategies </i>and <i>ChatGPT For Dummies.</i>","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/34669"}}],"primaryCategoryTaxonomy":{"categoryId":33576,"title":"Generative AI","slug":"general-ai","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33576"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":302176,"title":"Improving CLM with Generative AI: Key Use Cases","slug":"improving-clm-with-generative-ai-key-use-cases","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/302176"}},{"articleId":301980,"title":"Enterprise Generative AI: Transforming Your Business","slug":"enterprise-generative-ai-transforming-your-business","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/301980"}},{"articleId":301240,"title":"Five Ways Machine Health Delivers Real Business Value","slug":"five-ways-machine-health-delivers-real-business-value","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/301240"}},{"articleId":299369,"title":"How ChatGPT Could Change Our Lives","slug":"how-chatgpt-could-change-our-lives","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/299369"}},{"articleId":299281,"title":"How to Write Prompts for ChatGPT","slug":"how-to-write-prompts-for-chatgpt","categoryList":["technology","information-technology","ai","general-ai"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/299281"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":302330,"slug":"generative-ai-for-dummies","isbn":"9781394270743","categoryList":["technology","information-technology","ai","general-ai"],"amazon":{"default":"https://www.amazon.com/gp/product/1394270747/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1394270747/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1394270747-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1394270747/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1394270747/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/generative-ai-for-dummies-cover-9781394270743-203x255.jpg","width":203,"height":255},"title":"Generative AI For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"<p><p><b><b data-author-id=\"35299\">Pam Baker</b></b> is an award-winning freelance journalist, analyst, and author. Her previous book, <i>ChatGPT For Dummies</i>, was one of the first how-to guides for effective use of the ChatGPT platform. She writes for several media outlets, including <i>The New York Times</i>, CNN, <i>Ars Technica</i>, <i>InformationWeek</i>, and <I>CSO</I>. Baker is also an instructor on GenAI for LinkedIn Learning.</p>","authors":[{"authorId":35299,"name":"Pam Baker","slug":"pam-baker","description":" <p><b>Pam Baker</b> is an award-winning freelance journalist, analyst, and author. Her previous book, <i>ChatGPT For Dummies</i>, was one of the first how-to guides for effective use of the ChatGPT platform. She writes for several media outlets, including <i>The New York Times</i>, CNN, <i>Ars Technica</i>, <i>InformationWeek</i>, and <I>CSO</I>. Baker is also an instructor on GenAI for LinkedIn Learning. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/35299"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;ai&quot;,&quot;general-ai&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781394270743&quot;]}]\" id=\"du-slot-67117b17a541e\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;ai&quot;,&quot;general-ai&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781394270743&quot;]}]\" id=\"du-slot-67117b17a5c03\"></div></div>"},"articleType":{"articleType":"Cheat Sheet","articleList":[{"articleId":0,"title":"","slug":null,"categoryList":[],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/"}}],"content":[{"title":"What GenAI Is, in Brief","thumb":null,"image":null,"content":"<p>Generative AI is software that behaves unlike any other software ever known. It’s not a robot. Robots are hardware. You could think of any AI as the brains of robots, but they can exist on other hardware that is not a robot, like a supercomputer, a laptop, or an autonomous car. Think of GenAI as arguably the most creative of all AI types and certainly the easiest to use since it understands and responds to human languages.</p>\n<p>GenAI can perform like an artist, writer, or composer to whip up paintings, stories, or music from scratch after just a quick chat about what you like or want it to do. This type of AI doesn’t just copy from its training data (although it can certainly do that, too, so watch out for plagiarism and copyright infringements); it learns from tons of examples and then generates hopefully original pieces, mixing and matching ideas and data like a chef creating a new recipe. It’s also the tech behind many of those cool apps you love like the ones that turn your selfies into cartoon characters or help you make brilliant and beautiful websites with just a few clicks!</p>\n<p>Generative AI operates by training on huge datasets to recognize patterns and understand different forms of content. One of the star players in this field is GPT (short for Generative Pre-trained Transformer), which is a type of language model that’s really good at understanding and generating human-like text. It’s like a virtual wordsmith that can chat, answer questions, write essays, or even write computer code.</p>\n<p>But Generative AI isn’t just about generating text. There are other options out there, like DALL-E and Midjourney, which can create images from descriptions you give it, or DeepMind’s WaveNet, which can generate life-like speech. These systems use neural networks, which are a bit like a web of digital brain cells, to learn from examples and then generate new content. They’re transforming how we create and interact with content across the board, from gaming to marketing to entertainment.</p>\n<p>It’s important to note that GPTs are not the only GenAI game in town. For example, Claude is built on a language model similar to but not GPT (Generative Pre-trained Transformer) architectures. Claude is built on a family of large language models (LLMs) developed by Anthropic. The latest generation is the Claude 3 model family, which includes three main variants: Opus, Sonnet, and Haiku. Midjourney is another example of a GenAI tool built on a non-GPT model. Midjourney is built on its own proprietary model architecture. Other examples also are based on open-source models.</p>\n"},{"title":"Common GenAI Tasks and Use Cases","thumb":null,"image":null,"content":"<p>Generative AI (GenAI) is used to spur and speed creativity, innovations, and problem-solving across numerous fields. Following are some of the most widespread applications, with a few specific examples:</p>\n<h3>Content Creation</h3>\n<ul>\n<li><strong>Writing and Editing:</strong> GenAI can craft engaging blog posts for a travel website, snappy social media updates for a fashion brand, or persuasive marketing copy for a new tech gadget. It can also refine or adjust existing articles to fit different audiences or word counts. It can help write more complex and esoteric works, too, such as white papers, scientific studies, medical research studies, and other long-form works such as feature articles, analytical reports, financial reports, ebooks, and traditional books.</li>\n<li><strong>Creative Writing:</strong> GenAI tools can also help write creative works such as a fantasy short story, compose a piece of ambient music for a meditation app, or generate unique recipes for a cooking blog.</li>\n</ul>\n<h3>Software Development</h3>\n<ul>\n<li><strong>Code Generation:</strong> GenAI tools like GitHub’s Copilot can suggest code snippets for a new app feature, find and fix bugs, or refactor code to improve its efficiency.</li>\n<li><strong>Documentation and Quality Assurance:</strong> GenAI can automatically generate user manuals and other documentation for a software release or create comprehensive test cases to ensure a new video game is bug-free.</li>\n</ul>\n<h3>Marketing and Sales</h3>\n<ul>\n<li><strong>Inbound and Outbound Marketing:</strong> GenAI can draft compelling email campaign subject lines for an e-commerce store or produce targeted ad copy for a fitness service’s Google Ads campaign or a newsletter.</li>\n<li><strong>Customer Relationship Management:</strong> GenAI-driven chatbots, such as those on a bank’s website, can answer customer inquiries about account services or suggest the best credit card options based on spending habits.</li>\n</ul>\n<h3>Data Analysis and Synthesis</h3>\n<ul>\n<li><strong>Summarizing Documents:</strong> GenAI can condense a lengthy financial report into a digestible executive summary or distill the main points from a series of customer feedback surveys.</li>\n<li><strong>Synthesizing Information:</strong> GenAI can sift through thousands of product reviews to provide a sentiment analysis or extract the most frequently mentioned features.</li>\n<li><strong>Data discovery:</strong> GenAI can find patterns in huge data sets that humans can’t and connect data points from a new perspective or to a new use. It’s so good at this that it’s a top use case for GenAI. Examples include finding new early detection methods for diseases and discovering emerging consumer trends earlier than traditional tools can.</li>\n</ul>\n<h3>Design and Product Development</h3>\n<ul>\n<li><strong>Generative Design:</strong> GenAI can, for example, propose a variety of smartphone case designs with optimal grip and aesthetics or generate aerodynamic shapes for a new sports car prototype.</li>\n<li><strong>Fashion Design:</strong> GenAI can turn a simple dress sketch into a range of style variations or create virtual models showcasing different fabrics and outfits for an online store.</li>\n</ul>\n<h3>Healthcare and Pharmaceuticals</h3>\n<ul>\n<li><strong>Drug Discovery: </strong>GenAI can accelerate the search for new drugs by predicting how different molecules will interact, potentially identifying new treatments for diseases like cancer.</li>\n<li><strong>Medical Imaging:</strong> GenAI can enhance MRI scans to help radiologists detect early signs of abnormalities or support the diagnosis of conditions such as fractures in X-rays.</li>\n</ul>\n<h3>Translation and Localization</h3>\n<ul>\n<li><strong>Language Translation:</strong> GenAI can assist in translating a user manual for a smartphone into multiple languages, though it may require human review to ensure cultural nuances are respected.</li>\n</ul>\n<h3>Fraud Detection and Risk Management</h3>\n<ul>\n<li><strong>Anomaly Detection:</strong> GenAI can monitor transaction data for a credit card company to spot unusual patterns that might indicate fraud or sift through insurance claims to detect inconsistencies.</li>\n</ul>\n<p class=\"article-tips tip\">These examples illustrate just a slice of the impressive range and potential of Generative AI, across industries from tech and marketing to fashion, healthcare, finance, and beyond.</p>\n"},{"title":"GenAI Options and How to Choose One for Your Projects","thumb":null,"image":null,"content":"<p>When assessing GenAI models for specific types of content creation, it’s crucial to conduct a thorough evaluation to ensure that the chosen model meets your specific needs. Here’s a distilled guide to help you navigate this process:</p>\n<ul>\n<li><strong>Understanding GenAI model types:</strong> Begin by acquainting yourself with the various GenAI models available that produce the type of outputs you seek. For example, if you want to produce images, check out DALL-E, Stable Diffusion, Midjourney, and other image generators. A multimodal GenAI tool like ChatGPT4o might serve you well, too. If you are looking to produce content in a specialized field like healthcare or customer service, check the enterprise apps your company is already using as they likely have GenAI embedded in the software that is trained to do that specific type of work. Take a look at GPTs in OpenAI’s GPT Store on ChatGPT, too, as well as the collection of specialized GenAI tools listed on services like Poe.</li>\n<li>If you’re looking to build a GenAI model or app yourself, check out cloud services like AWS, Azure, and Google to see which AI tools and services are easiest for you and your team to work with. Several options are available in open-source GenAI models. You might also want to consider integrating your application(s) with a GenAI model instead of building one from scratch. Look for APIs and keys like those offered by OpenAI</li>\n<li>If you are an individual or a small business, you might want to turn to one of the many GenAI-based chatbots on the market. For example, OpenAI’s GPTs and ChatGPT. ChatGPT Plus only costs $20 a month and gives you access to more features and access than the free version. Choose ChaptGPT Team if you want higher usage limits and to add people on the account. Team costs $25 per person/per month. An Enterprise version is also available that has far more bells and whistles in the way of features, and you can have more people on your account. You’ll have to contact the company for a quote as there isn’t a published price list for the Enterprise version. Prices, terms and features available on competing GenAI chatbots vary, and I recommend you check out several of them before selecting one or more to use.</li>\n<li><strong>Identifying content requirements</strong>: Clearly define the type of content you aim to produce. Whether it’s text-based like social media posts and articles or visual content such as images, your content requirements will guide you in selecting a GenAI model or application that can effectively fulfill those needs.</li>\n<li><strong>Evaluating performance metrics:</strong> Consider important performance indicators such as the relevance and quality of the generated content, the diversity of output, the speed of content generation, and the model’s ability to capture complex details. Evaluating these factors are essential in determining the suitability of a GenAI model for your content creation tasks.</li>\n<li><strong>Testing for fit</strong>: When you have narrowed down which GenAI models are most likely to do the job you want them to do, try them out and see how they fit. Most GenAI models have a free version or a free trial period. Even though the freebie versions may not contain the same capabilities as the premium versions, you can still get a feel for how each model fits your needs overall.</li>\n<li><strong>Considering integration:</strong> Assess the ease with which the GenAI models can be integrated into your existing workflows. A smooth integration process is key to streamlining content creation and enhancing the efficiency of producing various content types.</li>\n<li>If you don’t need to integrate GenAI with any other apps, you still might want to use integrated or embedded GenAI models. For example, consider using ChatGPT Plus to generate your text content and summoning the GPT Image Generator to build illustrations for you — while you’re still working in ChatGPT Plus. You can also find GenAI embedded or integrated in commercially available software that you’re probably already using, or that you can easily obtain. You’ll likely find software that is specialized for tasks in your industry or the work you want to do with GenAI to be particularly helpful.</li>\n<li>\n<p class=\"article-tips tip\">You may also want to consider copying and pasting the GenAI output into other software where you can edit and format the content more easily as well as distribute it. Most people port or copy &amp; paste outputs or integrate GenAI models for just this very reason.</p>\n</li>\n<li><strong>Efficiency and time savings:</strong> Determine the extent to which GenAI models can automate manual content creation tasks. This can free up your team to concentrate on strategic and creative aspects of content development, saving time and boosting productivity.</li>\n<li><strong>Ethical considerations:</strong> Finally, ensure that the GenAI models comply with ethical standards concerning data privacy, security, transparency, explainability, and intellectual property rights. Adherence to these guidelines is critical when creating content. Be sure to check and see whether your prompts and responses are retained by the GenAI model maker to train other GenAI models as this can expose proprietary data or company secrets.</li>\n</ul>\n<p>By following this guide and considering these key aspects, you can effectively evaluate how well different GenAI models meet your specific content creation needs.</p>\n"},{"title":"Advanced Prompting and Other Methods and Tips","thumb":null,"image":null,"content":"<p>Whether you’re looking to refine your GenAI-generated content or unlock new levels of creativity, mastering advanced prompting techniques and a few other tactics is how you get the content you want. From stitching together seamless narratives to orchestrating the work of multiple GenAI tools, each method gives you a different kind of control over the content you are creating with GenAI.</p>\n<p>Here are some ways and tips that will elevate you from a casual user to a skilled prompter and GenAI master:</p>\n<h3>Output Stitching</h3>\n<ul>\n<li><strong>Definition:</strong> This technique involves combining the outputs from more than one GenAI tool and manually combining the bits and pieces to create a cohesive final product. Or, you can also use this method to complete a work from chunk writing (working on one section at a time of a longer piece so as not to confuse the GenAI and get better results).</li>\n<li><strong>Example:</strong> If you’re generating a long-form article, you might first ask the GenAI to outline the piece and then generate each section individually, and finally, stitch them together in a coherent structure. Or, you can give the same prompt to two or more GenAI tools and stitch together the bits and pieces you choose from each to create a better output than you got from any one of them alone.</li>\n</ul>\n<h3>AI Aggregation</h3>\n<ul>\n<li><strong>Definition:</strong> AI aggregation refers to the process of collecting and synthesizing information or responses from multiple GenAI models or sources and using them collectively in a unified work.</li>\n<li><strong>Example:</strong> When looking for comprehensive information on a topic, you might prompt different GenAI models for their insights and compile the responses to form a well-rounded view. Or, you might use one GenAI model to write a blog post, another to generate an image or illustration, and another type of software with embedded GenAI to create a video to embed in that same post, too.</li>\n</ul>\n<h3>AI Chaining</h3>\n<ul>\n<li><strong>Definition:</strong> AI chaining is the sequential use of GenAI outputs as part or all of inputs for other GenAI tools.</li>\n<li><strong>Example: </strong>To make a computer game, a training video, or a movie film, you might prompt one GenAI tool to create character profiles and then use the output from that as the main substance of a prompt that you use in another GenAI tool to build a storyboard, generate a storyline, and draw key scenes. Then you might continue with subsequent prompts in yet another GenAI tool to flesh out a full narrative in an actual script. You can change the order of these steps, if you like. The point is that you are using multiple GenAI tools to do specialized tasks and then using those outputs as part of or the main thrust in prompts for other GenAI tools that are specialized in the next step or task you need to complete to eventually arrive at a finished, unified work.</li>\n</ul>\n<h3>Prompt Chaining</h3>\n<ul>\n<li><strong>Definition:</strong> Prompt chaining involves using the output of one prompt as part of the input for the next in the same chat on the same GenAI tool, creating a series of linked prompts and responses.</li>\n<li><strong>Example:</strong> If you’re designing a product, start with a prompt to generate a concept, use the response as a base for the next prompt to refine the design, and continue until you reach a final detailed blueprint.</li>\n</ul>\n<h3>Prompting with Different Roles in the Same Prompt</h3>\n<ul>\n<li><strong>Definition:</strong> This method assigns different roles or perspectives within the same prompt to generate diverse and multi-faceted content.</li>\n<li><strong>Example: </strong>When creating a training dialogue, you might prompt the GenAI to adopt the roles of both a customer and a customer service representative to simulate a realistic conversation. Another example is to form a virtual committee of experts. test audiences, communities, voters, users, and any mix of people and experts you like as a command in your prompt. The response will deliver answers and interactions from these different roles and personas to further enlighten, inspire or deliver divers insights for your work.</li>\n</ul>\n<p>By leveraging these advanced prompting and methods, you’ll not only refine the quality of the content produced but also expand the capabilities of the GenAI to meet your more complex and nuanced demands.</p>\n<p class=\"article-tips remember\">The key to successful prompting lies in clarity, specificity, and creativity — so experiment freely and watch as your prompts bring forth GenAI-generated works that are truly useful and better matched to your needs and goals.</p>\n"}],"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"One year","lifeExpectancySetFrom":"2024-10-17T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":302379},{"headers":{"creationTime":"2020-02-18T20:45:52+00:00","modifiedTime":"2024-09-24T17:47:01+00:00","timestamp":"2024-09-24T18:01:08+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Information Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33572"},"slug":"information-technology","categoryId":33572},{"name":"Data Science","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33577"},"slug":"data-science","categoryId":33577},{"name":"General Data Science","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33580"},"slug":"general-data-science","categoryId":33580}],"title":"Linear Regression vs. Logistic Regression","strippedTitle":"linear regression vs. logistic regression","slug":"linear-regression-vs-logistic-regression","canonicalUrl":"","seo":{"metaDescription":"Wondering how to differentiate between linear and logistic regression? Learn the difference here and see how it applies to data science.","noIndex":0,"noFollow":0},"content":"Both linear and logistic regression see a lot of use in <a href=\"https://www.dummies.com/article/technology/information-technology/data-science/general-data-science/data-science-programming-all-in-one-for-dummies-cheat-sheet-266847/\">data science</a> but are commonly used for different kinds of problems. You need to know and understand both types of regression to perform a full range of data science tasks.\r\n\r\nOf the two, logistic regression is harder to understand in many respects because it necessarily uses a more complex equation model. The following information gives you a basic overview of how linear and logistic regression differ.\r\n<h2 id=\"tab1\" >The equation model</h2>\r\nAny discussion of the difference between linear and logistic regression must start with the underlying equation model. The equation for linear regression is straightforward.\r\n<pre class=\"code\">y = a + bx</pre>\r\nYou may see this equation in other forms and you may see it called ordinary least squares regression, but the essential concept is always the same. Depending on the source you use, some of the equations used to express logistic regression can become downright terrifying unless you’re a math major. However, the start of this discussion can use one of the simplest views of logistic regression:\r\n<pre class=\"code\">p = f(a + bx)</pre>\r\n<code>&gt;p</code>, is equal to the logistic function, <span style=\"text-decoration: line-through;\">f</span>, applied to two model parameters, <code>a</code> and <code>b</code>, and one explanatory variable, <code>x</code>. When you look at this particular model, you see that it really isn’t all that different from the linear regression model, except that you now feed the result of the linear regression through the logistic function to obtain the required curve.\r\n\r\nThe output (dependent variable) is a probability ranging from 0 (not going to happen) to 1 (definitely will happen), or a categorization that says something is either part of the category or not part of the category. (You can also perform multiclass categorization, but focus on the binary response for now.) The best way to view the difference between linear regression output and logistic regression output is to say that the following:\r\n<ul>\r\n \t<li><strong>Linear regression is continuous.</strong> A continuous value can take any value within a specified interval (range) of values. For example, no matter how closely the height of two individuals matches, you can always find someone whose height fits between those two individuals. Examples of continuous values include:\r\n<ul>\r\n \t<li>Height</li>\r\n \t<li>Weight</li>\r\n \t<li>Waist size</li>\r\n</ul>\r\n</li>\r\n \t<li><strong>Logistic regression is discrete.</strong> A discrete value has specific values that it can assume. For example, a hospital can admit only a specific number of patients in a given day. You can’t admit half a patient (at least, not alive). Examples of discrete values include:\r\n<ul>\r\n \t<li>Number of people at the fair</li>\r\n \t<li>Number of jellybeans in the jar</li>\r\n \t<li>Colors of automobiles produced by a vendor</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n<h2 id=\"tab2\" >The logistic function</h2>\r\nOf course, now you need to know about the logistic function. You can find a variety of forms of this function as well, but here’s the easiest one to understand:\r\n<pre class=\"code\">f(x) = e&lt;sup&gt;x&lt;/sup&gt; / e&lt;sup&gt;x&lt;/sup&gt; + 1</pre>\r\nYou already know about <code>f</code>, which is the logistic function, and <code>x</code> equals the algorithm you want to use, which is <code>a + bx </code>in this case. That leaves <code>e</code>, which is the natural logarithm and has an irrational value of 2.718, for the sake of discussion (<a href=\"https://www.intmath.com/exponential-logarithmic-functions/5-logs-base-e-ln.php\">check out a better approximation of the whole value</a>). Another way you see this function expressed is\r\n<pre class=\"code\">f(x) = 1 / (1 + e&lt;sup&gt;-x&lt;/sup&gt;)</pre>\r\nBoth forms are correct, but the first form is easier to use. Consider a simple problem in which <code>a</code>, the y-intercept, is 0, and <code>\"&gt;b</code>, the slope, is 1. The example uses <code>x</code> values from –6 to 6. Consequently, the first <code>f(x)</code> value would look like this when calculated (all values are rounded):\r\n<pre class=\"code\"> \r\n(1) e&lt;sup&gt;-6&lt;/sup&gt; / (1 + e&lt;sup&gt;-6&lt;/sup&gt;)\r\n(2) 0.00248 / 1 + 0.00248\r\n(3) 0.002474</pre>\r\nAs you might expect, an <code>x</code>value of 0 would result in an <code>f(x)</code> value of 0.5, and an <code>x</code> value of 6 would result in an <code>f(x)</code> value of 0.9975. Obviously, a linear regression would show different results for precisely the same <code>x</code> values. If you calculate and plot all the results from both logistic and linear regression using the following code, you receive a plot like the one below.\r\n<pre class=\"code\">import matplotlib.pyplot as plt\r\n%matplotlib inline\r\nfrom math import exp\r\n \r\nx_values = range(-6, 7)\r\nlin_values = [(0 + 1*x) / 13 for x in range(0, 13)]\r\nlog_values = [exp(0 + 1*x) / (1 + exp(0 + 1*x))\r\nfor x in x_values]\r\n \r\nplt.plot(x_values, lin_values, 'b-^')\r\nplt.plot(x_values, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic'])\r\nplt.show()</pre>\r\n[caption id=\"attachment_268339\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268339 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-contrast-linear-logistic-regression.jpg\" alt=\"Contrasting linear to logistic regression\" width=\"556\" height=\"368\" /> Contrasting linear to logistic regression.[/caption]\r\n\r\nThis example relies on <a href=\"https://www.pythonforbeginners.com/basics/list-comprehensions-in-python\">list comprehension</a> to calculate the values because it makes the calculations clearer. The linear regression uses a different numeric range because you must normalize the values to appear in the 0 to 1 range for comparison. This is also why you divide the calculated values by 13. The <code>exp(x)</code> call used for the logistic regression raises <code>e</code> to the power of <code>x</code>, <code>e&lt;sup&gt;x&lt;/sup&gt;</code>, as needed for the logistic function.\r\n<p class=\"article-tips warning\">The model discussed here is simplified, and some math majors out there are probably throwing a temper tantrum of the most profound proportions right now. The Python or R package you use will actually take care of the math in the background, so really, what you need to know is how the math works at a basic level so that you can understand<a href=\"https://www.dummies.com/programming/python/view-python-package-documentation/\"> how to use the packages</a>. This section provides what you need to use the packages. However, if you insist on carrying out the calculations the old way, chalk to chalkboard, you’ll likely need a lot more information.</p>\r\n\r\n<h2 id=\"tab3\" >The problems that logistic regression solves</h2>\r\nYou can separate logistic regression into several categories. The first is simple logistic regression, in which you have one dependent variable and one independent variable, much as you see in simple linear regression. However, because of how you calculate the logistic regression, you can expect only two kinds of output:\r\n<ul>\r\n \t<li><strong>Classification:</strong> Decides between two available outcomes, such as male or female, yes or no, or high or low. The outcome is dependent on which side of the line a particular data point falls.</li>\r\n \t<li><strong>Probability:</strong> Determines the probability that something is true or false. The values true and false can have specific meanings. For example, you might want to know the probability that a particular apple will be yellow or red based on the presence of yellow and red apples in a bin.</li>\r\n</ul>\r\n<h2 id=\"tab4\" >Fit the curve</h2>\r\nAs part of understanding the difference between linear and logistic regression, consider this grade prediction problem, which lends itself well to linear regression. In the following code, you see the effect of trying to use logistic regression with that data:\r\n<pre class=\"code\">x1 = range(0,9)\r\ny1 = (0.25, 0.33, 0.41, 0.53, 0.59,\r\n0.70, 0.78, 0.86, 0.98)\r\nplt.scatter(x1, y1, c='r')\r\n \r\nlin_values = [0.242 + 0.0933*x for x in x1]\r\nlog_values = [exp(0.242 + .9033*x) /\r\n(1 + exp(0.242 + .9033*x))\r\nfor x in range(-4, 5)]\r\n \r\nplt.plot(x1, lin_values, 'b-^')\r\nplt.plot(x1, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic', 'Org Data'])\r\nplt.show()</pre>\r\nThe example has undergone a few changes to make it easier to see precisely what is happening. It relies on the same data that was converted from questions answered correctly on the exam to a percentage. If you have 100 questions and you answer 25 of them correctly, you have answered 25 percent (0.25) of them correctly. The values are normalized to produce values between 0 and 1 percent.\r\n\r\n[caption id=\"attachment_268336\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268336 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-fitting-data.jpg\" alt=\"fitting the data for data science\" width=\"556\" height=\"365\" /> Considering the approach to fitting the data.[/caption]\r\n\r\nAs you can see from the image above, the linear regression follows the data points closely. The logistic regression doesn’t. However, logistic regression often is the correct choice when the data points naturally follow the logistic curve, which happens far more often than you might think. You must use the technique that fits your data best, which means using linear regression in this case.\r\n<h2 id=\"tab5\" >A pass/fail example</h2>\r\nAn essential point to remember is that logistic regression works best for probability and classification. Consider that points on an exam ultimately predict passing or failing the course. If you get a certain percentage of the answers correct, you pass, but you fail otherwise. The following code considers the same data used for the example above, but converts it to a pass/fail list. When a student gets at least 70 percent of the questions correct, success is assured.\r\n<pre class=\"code\">y2 = [0 if x &lt; 0.70 else 1 for x in y1]\r\nplt.scatter(x1, y2, c='r')\r\n \r\nlin_values = [0.242 + 0.0933*x for x in x1]\r\nlog_values = [exp(0.242 + .9033*x) /\r\n(1 + exp(0.242 + .9033*x))\r\nfor x in range(-4, 5)]\r\n \r\nplt.plot(x1, lin_values, 'b-^')\r\nplt.plot(x1, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic', 'Org Data'])\r\nplt.show()</pre>\r\nThis is an example of how <a href=\"https://www.dummies.com/programming/big-data/data-science/using-the-python-ecosystem-for-data-science/\">you can use list comprehensions in Python</a> to obtain a required dataset or data transformation. The list comprehension for <code>y2</code> starts with the continuous data in <code>y1</code> and turns it into discrete data. Note that the example uses precisely the same equations as before. All that has changed is the manner in which you view the data, as you can see below.\r\n\r\n[caption id=\"attachment_268335\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268335 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-linear-vs-logistic-regression.jpg\" alt=\"linear vs logistic regression\" width=\"556\" height=\"363\" /> Contrasting linear to logistic regression.[/caption]\r\n\r\nBecause of the change in the data, linear regression is no longer the option to choose. Instead, you use logistic regression to fit the data. Take into account that this example really hasn’t done any sort of analysis to optimize the results. The logistic regression fits the data even better if you do so.","description":"Both linear and logistic regression see a lot of use in <a href=\"https://www.dummies.com/article/technology/information-technology/data-science/general-data-science/data-science-programming-all-in-one-for-dummies-cheat-sheet-266847/\">data science</a> but are commonly used for different kinds of problems. You need to know and understand both types of regression to perform a full range of data science tasks.\r\n\r\nOf the two, logistic regression is harder to understand in many respects because it necessarily uses a more complex equation model. The following information gives you a basic overview of how linear and logistic regression differ.\r\n<h2 id=\"tab1\" >The equation model</h2>\r\nAny discussion of the difference between linear and logistic regression must start with the underlying equation model. The equation for linear regression is straightforward.\r\n<pre class=\"code\">y = a + bx</pre>\r\nYou may see this equation in other forms and you may see it called ordinary least squares regression, but the essential concept is always the same. Depending on the source you use, some of the equations used to express logistic regression can become downright terrifying unless you’re a math major. However, the start of this discussion can use one of the simplest views of logistic regression:\r\n<pre class=\"code\">p = f(a + bx)</pre>\r\n<code>&gt;p</code>, is equal to the logistic function, <span style=\"text-decoration: line-through;\">f</span>, applied to two model parameters, <code>a</code> and <code>b</code>, and one explanatory variable, <code>x</code>. When you look at this particular model, you see that it really isn’t all that different from the linear regression model, except that you now feed the result of the linear regression through the logistic function to obtain the required curve.\r\n\r\nThe output (dependent variable) is a probability ranging from 0 (not going to happen) to 1 (definitely will happen), or a categorization that says something is either part of the category or not part of the category. (You can also perform multiclass categorization, but focus on the binary response for now.) The best way to view the difference between linear regression output and logistic regression output is to say that the following:\r\n<ul>\r\n \t<li><strong>Linear regression is continuous.</strong> A continuous value can take any value within a specified interval (range) of values. For example, no matter how closely the height of two individuals matches, you can always find someone whose height fits between those two individuals. Examples of continuous values include:\r\n<ul>\r\n \t<li>Height</li>\r\n \t<li>Weight</li>\r\n \t<li>Waist size</li>\r\n</ul>\r\n</li>\r\n \t<li><strong>Logistic regression is discrete.</strong> A discrete value has specific values that it can assume. For example, a hospital can admit only a specific number of patients in a given day. You can’t admit half a patient (at least, not alive). Examples of discrete values include:\r\n<ul>\r\n \t<li>Number of people at the fair</li>\r\n \t<li>Number of jellybeans in the jar</li>\r\n \t<li>Colors of automobiles produced by a vendor</li>\r\n</ul>\r\n</li>\r\n</ul>\r\n<h2 id=\"tab2\" >The logistic function</h2>\r\nOf course, now you need to know about the logistic function. You can find a variety of forms of this function as well, but here’s the easiest one to understand:\r\n<pre class=\"code\">f(x) = e&lt;sup&gt;x&lt;/sup&gt; / e&lt;sup&gt;x&lt;/sup&gt; + 1</pre>\r\nYou already know about <code>f</code>, which is the logistic function, and <code>x</code> equals the algorithm you want to use, which is <code>a + bx </code>in this case. That leaves <code>e</code>, which is the natural logarithm and has an irrational value of 2.718, for the sake of discussion (<a href=\"https://www.intmath.com/exponential-logarithmic-functions/5-logs-base-e-ln.php\">check out a better approximation of the whole value</a>). Another way you see this function expressed is\r\n<pre class=\"code\">f(x) = 1 / (1 + e&lt;sup&gt;-x&lt;/sup&gt;)</pre>\r\nBoth forms are correct, but the first form is easier to use. Consider a simple problem in which <code>a</code>, the y-intercept, is 0, and <code>\"&gt;b</code>, the slope, is 1. The example uses <code>x</code> values from –6 to 6. Consequently, the first <code>f(x)</code> value would look like this when calculated (all values are rounded):\r\n<pre class=\"code\"> \r\n(1) e&lt;sup&gt;-6&lt;/sup&gt; / (1 + e&lt;sup&gt;-6&lt;/sup&gt;)\r\n(2) 0.00248 / 1 + 0.00248\r\n(3) 0.002474</pre>\r\nAs you might expect, an <code>x</code>value of 0 would result in an <code>f(x)</code> value of 0.5, and an <code>x</code> value of 6 would result in an <code>f(x)</code> value of 0.9975. Obviously, a linear regression would show different results for precisely the same <code>x</code> values. If you calculate and plot all the results from both logistic and linear regression using the following code, you receive a plot like the one below.\r\n<pre class=\"code\">import matplotlib.pyplot as plt\r\n%matplotlib inline\r\nfrom math import exp\r\n \r\nx_values = range(-6, 7)\r\nlin_values = [(0 + 1*x) / 13 for x in range(0, 13)]\r\nlog_values = [exp(0 + 1*x) / (1 + exp(0 + 1*x))\r\nfor x in x_values]\r\n \r\nplt.plot(x_values, lin_values, 'b-^')\r\nplt.plot(x_values, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic'])\r\nplt.show()</pre>\r\n[caption id=\"attachment_268339\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268339 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-contrast-linear-logistic-regression.jpg\" alt=\"Contrasting linear to logistic regression\" width=\"556\" height=\"368\" /> Contrasting linear to logistic regression.[/caption]\r\n\r\nThis example relies on <a href=\"https://www.pythonforbeginners.com/basics/list-comprehensions-in-python\">list comprehension</a> to calculate the values because it makes the calculations clearer. The linear regression uses a different numeric range because you must normalize the values to appear in the 0 to 1 range for comparison. This is also why you divide the calculated values by 13. The <code>exp(x)</code> call used for the logistic regression raises <code>e</code> to the power of <code>x</code>, <code>e&lt;sup&gt;x&lt;/sup&gt;</code>, as needed for the logistic function.\r\n<p class=\"article-tips warning\">The model discussed here is simplified, and some math majors out there are probably throwing a temper tantrum of the most profound proportions right now. The Python or R package you use will actually take care of the math in the background, so really, what you need to know is how the math works at a basic level so that you can understand<a href=\"https://www.dummies.com/programming/python/view-python-package-documentation/\"> how to use the packages</a>. This section provides what you need to use the packages. However, if you insist on carrying out the calculations the old way, chalk to chalkboard, you’ll likely need a lot more information.</p>\r\n\r\n<h2 id=\"tab3\" >The problems that logistic regression solves</h2>\r\nYou can separate logistic regression into several categories. The first is simple logistic regression, in which you have one dependent variable and one independent variable, much as you see in simple linear regression. However, because of how you calculate the logistic regression, you can expect only two kinds of output:\r\n<ul>\r\n \t<li><strong>Classification:</strong> Decides between two available outcomes, such as male or female, yes or no, or high or low. The outcome is dependent on which side of the line a particular data point falls.</li>\r\n \t<li><strong>Probability:</strong> Determines the probability that something is true or false. The values true and false can have specific meanings. For example, you might want to know the probability that a particular apple will be yellow or red based on the presence of yellow and red apples in a bin.</li>\r\n</ul>\r\n<h2 id=\"tab4\" >Fit the curve</h2>\r\nAs part of understanding the difference between linear and logistic regression, consider this grade prediction problem, which lends itself well to linear regression. In the following code, you see the effect of trying to use logistic regression with that data:\r\n<pre class=\"code\">x1 = range(0,9)\r\ny1 = (0.25, 0.33, 0.41, 0.53, 0.59,\r\n0.70, 0.78, 0.86, 0.98)\r\nplt.scatter(x1, y1, c='r')\r\n \r\nlin_values = [0.242 + 0.0933*x for x in x1]\r\nlog_values = [exp(0.242 + .9033*x) /\r\n(1 + exp(0.242 + .9033*x))\r\nfor x in range(-4, 5)]\r\n \r\nplt.plot(x1, lin_values, 'b-^')\r\nplt.plot(x1, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic', 'Org Data'])\r\nplt.show()</pre>\r\nThe example has undergone a few changes to make it easier to see precisely what is happening. It relies on the same data that was converted from questions answered correctly on the exam to a percentage. If you have 100 questions and you answer 25 of them correctly, you have answered 25 percent (0.25) of them correctly. The values are normalized to produce values between 0 and 1 percent.\r\n\r\n[caption id=\"attachment_268336\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268336 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-fitting-data.jpg\" alt=\"fitting the data for data science\" width=\"556\" height=\"365\" /> Considering the approach to fitting the data.[/caption]\r\n\r\nAs you can see from the image above, the linear regression follows the data points closely. The logistic regression doesn’t. However, logistic regression often is the correct choice when the data points naturally follow the logistic curve, which happens far more often than you might think. You must use the technique that fits your data best, which means using linear regression in this case.\r\n<h2 id=\"tab5\" >A pass/fail example</h2>\r\nAn essential point to remember is that logistic regression works best for probability and classification. Consider that points on an exam ultimately predict passing or failing the course. If you get a certain percentage of the answers correct, you pass, but you fail otherwise. The following code considers the same data used for the example above, but converts it to a pass/fail list. When a student gets at least 70 percent of the questions correct, success is assured.\r\n<pre class=\"code\">y2 = [0 if x &lt; 0.70 else 1 for x in y1]\r\nplt.scatter(x1, y2, c='r')\r\n \r\nlin_values = [0.242 + 0.0933*x for x in x1]\r\nlog_values = [exp(0.242 + .9033*x) /\r\n(1 + exp(0.242 + .9033*x))\r\nfor x in range(-4, 5)]\r\n \r\nplt.plot(x1, lin_values, 'b-^')\r\nplt.plot(x1, log_values, 'g-*')\r\nplt.legend(['Linear', 'Logistic', 'Org Data'])\r\nplt.show()</pre>\r\nThis is an example of how <a href=\"https://www.dummies.com/programming/big-data/data-science/using-the-python-ecosystem-for-data-science/\">you can use list comprehensions in Python</a> to obtain a required dataset or data transformation. The list comprehension for <code>y2</code> starts with the continuous data in <code>y1</code> and turns it into discrete data. Note that the example uses precisely the same equations as before. All that has changed is the manner in which you view the data, as you can see below.\r\n\r\n[caption id=\"attachment_268335\" align=\"aligncenter\" width=\"556\"]<img class=\"wp-image-268335 size-full\" src=\"https://www.dummies.com/wp-content/uploads/data-science-programming-linear-vs-logistic-regression.jpg\" alt=\"linear vs logistic regression\" width=\"556\" height=\"363\" /> Contrasting linear to logistic regression.[/caption]\r\n\r\nBecause of the change in the data, linear regression is no longer the option to choose. Instead, you use logistic regression to fit the data. Take into account that this example really hasn’t done any sort of analysis to optimize the results. The logistic regression fits the data even better if you do so.","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}},{"authorId":9110,"name":"Luca Massaron","slug":"luca-massaron","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9110"}}],"primaryCategoryTaxonomy":{"categoryId":33580,"title":"General Data Science","slug":"general-data-science","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33580"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":266072,"title":"10 of the Most Haunted Places in America","slug":"10-of-the-most-haunted-places-in-america","categoryList":["body-mind-spirit","religion-spirituality","the-paranormal"],"_links":{"self":"/articles/266072"}},{"articleId":191479,"title":"How to Decorate a Halloween Haunted Mansion Cake","slug":"how-to-decorate-your-halloween-haunted-mansion-cake","categoryList":["home-auto-hobbies","food-drink","holiday-meals-entertaining"],"_links":{"self":"/articles/191479"}},{"articleId":175788,"title":"Trig Identities for Pre-Calculus","slug":"trig-identities-for-pre-calculus","categoryList":["academics-the-arts","math","pre-calculus"],"_links":{"self":"/articles/175788"}},{"articleId":147241,"title":"How to Use the Z-Table","slug":"how-to-use-the-z-table","categoryList":["academics-the-arts","math","statistics"],"_links":{"self":"/articles/147241"}},{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}}],"inThisArticle":[{"label":"The equation model","target":"#tab1"},{"label":"The logistic function","target":"#tab2"},{"label":"The problems that logistic regression solves","target":"#tab3"},{"label":"Fit the curve","target":"#tab4"},{"label":"A pass/fail example","target":"#tab5"}],"relatedArticles":{"fromBook":[{"articleId":268303,"title":"How Data is Collected and Why It Can Be Problematic","slug":"how-data-is-collected-and-why-it-can-be-problematic","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/268303"}},{"articleId":268298,"title":"How to Perform Pattern Matching in Python","slug":"how-to-perform-pattern-matching-in-python","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/268298"}},{"articleId":268293,"title":"How Pattern Matching Works in Data Science","slug":"how-pattern-matching-works-in-data-science","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/268293"}},{"articleId":268288,"title":"The Need for Reliable Sources in Data Science Applications","slug":"the-need-for-reliable-sources-in-data-science-applications","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/268288"}},{"articleId":268285,"title":"The Basics of Deep Learning Framework Usage and Low-End Framework Options","slug":"the-basics-of-deep-learning-framework-usage-and-low-end-framework-options","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/268285"}}],"fromCategory":[{"articleId":301769,"title":"Data Analytics & Visualization All-in-One Cheat Sheet","slug":"data-analytics-visualization-all-in-one-cheat-sheet","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/301769"}},{"articleId":289776,"title":"Decision Intelligence For Dummies Cheat Sheet","slug":"decision-intelligence-for-dummies-cheat-sheet","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/289776"}},{"articleId":289744,"title":"Microsoft Power BI For Dummies Cheat Sheet","slug":"microsoft-power-bi-for-dummies-cheat-sheet","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/289744"}},{"articleId":275249,"title":"Laws and Regulations You Should Know for Blockchain Data Analysis Projects","slug":"laws-and-regulations-you-should-know-for-blockchain-data-analysis-projects","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/275249"}},{"articleId":275244,"title":"Aligning Blockchain Data with Real-World Business Processes","slug":"aligning-blockchain-data-with-real-world-business-processes","categoryList":["technology","information-technology","data-science","general-data-science"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/275244"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":281678,"slug":"data-science-programming-all-in-one-for-dummies-2","isbn":"9781119626114","categoryList":["technology","information-technology","data-science","general-data-science"],"amazon":{"default":"https://www.amazon.com/gp/product/1119626110/ref=as_li_tl?ie=UTF8&tag=wiley01-20","ca":"https://www.amazon.ca/gp/product/1119626110/ref=as_li_tl?ie=UTF8&tag=wiley01-20","indigo_ca":"http://www.tkqlhce.com/click-9208661-13710633?url=https://www.chapters.indigo.ca/en-ca/books/product/1119626110-item.html&cjsku=978111945484","gb":"https://www.amazon.co.uk/gp/product/1119626110/ref=as_li_tl?ie=UTF8&tag=wiley01-20","de":"https://www.amazon.de/gp/product/1119626110/ref=as_li_tl?ie=UTF8&tag=wiley01-20"},"image":{"src":"https://www.dummies.com/wp-content/uploads/data-science-programming-all-in-one-for-dummies-cover-9781119626114-203x255.jpg","width":203,"height":255},"title":"Data Science Programming All-in-One For Dummies","testBankPinActivationLink":"","bookOutOfPrint":true,"authorsInfo":"<p><p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, <b data-author-id=\"9109\">John Paul Mueller</b>, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, <b data-author-id=\"9110\">Luca Massaron</b>, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b></p>","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}},{"authorId":9110,"name":"Luca Massaron","slug":"luca-massaron","description":" <p> <b>This All-in-One draws on the work of top authors in the <i>For Dummies </i>series who’ve created books designed to help data professionals do their work. The experts are Jack Hyman, Luca Massaron, Paul McFedries, John Paul Mueller, Lillian Pierson, Jonathan Reichental PhD, Joseph Schmuller PhD, Alan Simon, and Allen G. Taylor.</b> ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9110"}}],"_links":{"self":"https://dummies-api.dummies.com/v2/books/"}},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;data-science&quot;,&quot;general-data-science&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119626114&quot;]}]\" id=\"du-slot-66f2fe651eb5d\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;information-technology&quot;,&quot;data-science&quot;,&quot;general-data-science&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[&quot;9781119626114&quot;]}]\" id=\"du-slot-66f2fe6520a09\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":"One year","lifeExpectancySetFrom":"2024-09-24T00:00:00+00:00","dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":268328}],"_links":{"self":{"self":"https://dummies-api.dummies.com/v2/categories/33512/categoryArticles?sortField=time&sortOrder=1&size=10&offset=0"},"next":{"self":"https://dummies-api.dummies.com/v2/categories/33512/categoryArticles?sortField=time&sortOrder=1&size=10&offset=10"},"last":{"self":"https://dummies-api.dummies.com/v2/categories/33512/categoryArticles?sortField=time&sortOrder=1&size=10&offset=9413"}}},"objectTitle":"","status":"success","pageType":"article-category","objectId":"33512","page":1,"sortField":"time","sortOrder":1,"categoriesIds":[],"articleTypes":[],"filterData":{"categoriesFilter":[{"itemId":0,"itemName":"All Categories","count":9404},{"itemId":33513,"itemName":"Computers","count":1392},{"itemId":33537,"itemName":"Cybersecurity","count":59},{"itemId":33538,"itemName":"Digital Audio & Radio","count":131},{"itemId":33543,"itemName":"Electronics","count":1756},{"itemId":33572,"itemName":"Information Technology","count":812},{"itemId":33587,"itemName":"Internet Basics","count":86},{"itemId":33588,"itemName":"Notable Websites","count":188},{"itemId":33592,"itemName":"Programming & Web Design","count":1395},{"itemId":33611,"itemName":"Social Media","count":385},{"itemId":33618,"itemName":"Software","count":3194},{"itemId":33512,"itemName":"Technology","count":1},{"itemId":35241,"itemName":"Virtual Reality","count":5}],"articleTypeFilter":[{"articleType":"All Types","count":9404},{"articleType":"Articles","count":8246},{"articleType":"Cheat Sheet","count":309},{"articleType":"Step by Step","count":762},{"articleType":"Videos","count":87}]},"filterDataLoadedStatus":"success","pageSize":10},"adsState":{"pageScripts":{"headers":{"timestamp":"2024-11-01T05:50:01+00:00"},"adsId":0,"data":{"scripts":[{"pages":["all"],"location":"header","script":"<!--Optimizely Script-->\r\n<script src=\"https://cdn.optimizely.com/js/10563184655.js\"></script>","enabled":false},{"pages":["all"],"location":"header","script":"<!-- comScore Tag -->\r\n<script>var _comscore = _comscore || [];_comscore.push({ c1: \"2\", c2: \"15097263\" });(function() {var s = document.createElement(\"script\"), el = document.getElementsByTagName(\"script\")[0]; s.async = true;s.src = (document.location.protocol == \"https:\" ? \"https://sb\" : \"http://b\") + \".scorecardresearch.com/beacon.js\";el.parentNode.insertBefore(s, el);})();</script><noscript><img src=\"https://sb.scorecardresearch.com/p?c1=2&c2=15097263&cv=2.0&cj=1\" /></noscript>\r\n<!-- / comScore Tag -->","enabled":true},{"pages":["all"],"location":"footer","script":"<!--BEGIN QUALTRICS WEBSITE FEEDBACK SNIPPET-->\r\n<script type='text/javascript'>\r\n(function(){var g=function(e,h,f,g){\r\nthis.get=function(a){for(var a=a+\"=\",c=document.cookie.split(\";\"),b=0,e=c.length;b<e;b++){for(var d=c[b];\" \"==d.charAt(0);)d=d.substring(1,d.length);if(0==d.indexOf(a))return d.substring(a.length,d.length)}return null};\r\nthis.set=function(a,c){var b=\"\",b=new Date;b.setTime(b.getTime()+6048E5);b=\"; expires=\"+b.toGMTString();document.cookie=a+\"=\"+c+b+\"; path=/; \"};\r\nthis.check=function(){var a=this.get(f);if(a)a=a.split(\":\");else if(100!=e)\"v\"==h&&(e=Math.random()>=e/100?0:100),a=[h,e,0],this.set(f,a.join(\":\"));else return!0;var c=a[1];if(100==c)return!0;switch(a[0]){case \"v\":return!1;case \"r\":return c=a[2]%Math.floor(100/c),a[2]++,this.set(f,a.join(\":\")),!c}return!0};\r\nthis.go=function(){if(this.check()){var a=document.createElement(\"script\");a.type=\"text/javascript\";a.src=g;document.body&&document.body.appendChild(a)}};\r\nthis.start=function(){var t=this;\"complete\"!==document.readyState?window.addEventListener?window.addEventListener(\"load\",function(){t.go()},!1):window.attachEvent&&window.attachEvent(\"onload\",function(){t.go()}):t.go()};};\r\ntry{(new g(100,\"r\",\"QSI_S_ZN_5o5yqpvMVjgDOuN\",\"https://zn5o5yqpvmvjgdoun-wiley.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_5o5yqpvMVjgDOuN\")).start()}catch(i){}})();\r\n</script><div id='ZN_5o5yqpvMVjgDOuN'><!--DO NOT REMOVE-CONTENTS PLACED HERE--></div>\r\n<!--END WEBSITE FEEDBACK SNIPPET-->","enabled":false},{"pages":["all"],"location":"header","script":"<!-- Hotjar Tracking Code for http://www.dummies.com -->\r\n<script>\r\n (function(h,o,t,j,a,r){\r\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\r\n h._hjSettings={hjid:257151,hjsv:6};\r\n a=o.getElementsByTagName('head')[0];\r\n r=o.createElement('script');r.async=1;\r\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\r\n a.appendChild(r);\r\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\r\n</script>","enabled":false},{"pages":["article"],"location":"header","script":"<!-- //Connect Container: dummies --> <script src=\"//get.s-onetag.com/bffe21a1-6bb8-4928-9449-7beadb468dae/tag.min.js\" async defer></script>","enabled":true},{"pages":["homepage"],"location":"header","script":"<meta name=\"facebook-domain-verification\" content=\"irk8y0irxf718trg3uwwuexg6xpva0\" />","enabled":true},{"pages":["homepage","article","category","search"],"location":"footer","script":"<!-- Facebook Pixel Code -->\r\n<noscript>\r\n<img height=\"1\" width=\"1\" src=\"https://www.facebook.com/tr?id=256338321977984&ev=PageView&noscript=1\"/>\r\n</noscript>\r\n<!-- End Facebook Pixel Code -->","enabled":true}]}},"pageScriptsLoadedStatus":"success"},"navigationState":{"navigationCollections":[{"collectionId":287568,"title":"BYOB (Be Your Own Boss)","hasSubCategories":false,"url":"/collection/for-the-entry-level-entrepreneur-287568"},{"collectionId":293237,"title":"Be a Rad Dad","hasSubCategories":false,"url":"/collection/be-the-best-dad-293237"},{"collectionId":295890,"title":"Career Shifting","hasSubCategories":false,"url":"/collection/career-shifting-295890"},{"collectionId":294090,"title":"Contemplating the Cosmos","hasSubCategories":false,"url":"/collection/theres-something-about-space-294090"},{"collectionId":287563,"title":"For Those Seeking Peace of Mind","hasSubCategories":false,"url":"/collection/for-those-seeking-peace-of-mind-287563"},{"collectionId":287570,"title":"For the Aspiring Aficionado","hasSubCategories":false,"url":"/collection/for-the-bougielicious-287570"},{"collectionId":291903,"title":"For the Budding Cannabis Enthusiast","hasSubCategories":false,"url":"/collection/for-the-budding-cannabis-enthusiast-291903"},{"collectionId":299891,"title":"For the College Bound","hasSubCategories":false,"url":"/collection/for-the-college-bound-299891"},{"collectionId":291934,"title":"For the Exam-Season Crammer","hasSubCategories":false,"url":"/collection/for-the-exam-season-crammer-291934"},{"collectionId":301547,"title":"For the Game Day Prepper","hasSubCategories":false,"url":"/collection/big-game-day-prep-made-easy-301547"}],"navigationCollectionsLoadedStatus":"success","navigationCategories":{"books":{"0":{"data":[{"categoryId":33512,"title":"Technology","hasSubCategories":true,"url":"/category/books/technology-33512"},{"categoryId":33662,"title":"Academics & The Arts","hasSubCategories":true,"url":"/category/books/academics-the-arts-33662"},{"categoryId":33809,"title":"Home, Auto, & Hobbies","hasSubCategories":true,"url":"/category/books/home-auto-hobbies-33809"},{"categoryId":34038,"title":"Body, Mind, & Spirit","hasSubCategories":true,"url":"/category/books/body-mind-spirit-34038"},{"categoryId":34224,"title":"Business, Careers, & Money","hasSubCategories":true,"url":"/category/books/business-careers-money-34224"}],"breadcrumbs":[],"categoryTitle":"Level 0 Category","mainCategoryUrl":"/category/books/level-0-category-0"}},"articles":{"0":{"data":[{"categoryId":33512,"title":"Technology","hasSubCategories":true,"url":"/category/articles/technology-33512"},{"categoryId":33662,"title":"Academics & The Arts","hasSubCategories":true,"url":"/category/articles/academics-the-arts-33662"},{"categoryId":33809,"title":"Home, Auto, & Hobbies","hasSubCategories":true,"url":"/category/articles/home-auto-hobbies-33809"},{"categoryId":34038,"title":"Body, Mind, & Spirit","hasSubCategories":true,"url":"/category/articles/body-mind-spirit-34038"},{"categoryId":34224,"title":"Business, Careers, & Money","hasSubCategories":true,"url":"/category/articles/business-careers-money-34224"}],"breadcrumbs":[],"categoryTitle":"Level 0 Category","mainCategoryUrl":"/category/articles/level-0-category-0"}}},"navigationCategoriesLoadedStatus":"success"},"searchState":{"searchList":[],"searchStatus":"initial","relatedArticlesList":[],"relatedArticlesStatus":"initial"},"routeState":{"name":"ArticleCategory","path":"/category/articles/technology-33512/","hash":"","query":{},"params":{"category":"technology-33512"},"fullPath":"/category/articles/technology-33512/","meta":{"routeType":"category","breadcrumbInfo":{"suffix":"Articles","baseRoute":"/category/articles"},"prerenderWithAsyncData":true},"from":{"name":null,"path":"/","hash":"","query":{},"params":{},"fullPath":"/","meta":{}}},"profileState":{"auth":{},"userOptions":{},"status":"success"}}
Logo
  • Articles Open Article Categories
  • Books Open Book Categories
  • Collections Open Collections list
  • Custom Solutions

Article Categories

Book Categories

Collections

Explore all collections
BYOB (Be Your Own Boss)
Be a Rad Dad
Career Shifting
Contemplating the Cosmos
For Those Seeking Peace of Mind
For the Aspiring Aficionado
For the Budding Cannabis Enthusiast
For the College Bound
For the Exam-Season Crammer
For the Game Day Prepper
Log In
  • Home
  • Technology Articles

Technology Articles

Technology. It makes the world go 'round. And whether you're a self-confessed techie or a total newbie, you'll find something to love among our hundreds of technology articles and books.

Browse By Category

Virtual Reality

Virtual Reality

Computers

Computers

Cybersecurity

Cybersecurity

Digital Audio & Radio

Digital Audio & Radio

Electronics

Electronics

Information Technology

Information Technology

Internet Basics

Internet Basics

Notable Websites

Notable Websites

Programming & Web Design

Programming & Web Design

Social Media

Social Media

Software

Software

Previous slideNext slide
Virtual Reality

Virtual Reality

Computers

Computers

Cybersecurity

Cybersecurity

Digital Audio & Radio

Digital Audio & Radio

Electronics

Electronics

Information Technology

Information Technology

Internet Basics

Internet Basics

Notable Websites

Notable Websites

Programming & Web Design

Programming & Web Design

Social Media

Social Media

Software

Software

Articles From Technology

page 1
page 2
page 3
page 4
page 5
page 6
page 7
page 8
page 9
page 10
page 11
page 12
page 13
page 14
page 15
page 16
page 17
page 18
page 19
page 20
page 21
page 22
page 23
page 24
page 25
page 26
page 27
page 28
page 29
page 30
page 31
page 32
page 33
page 34
page 35
page 36
page 37
page 38
page 39
page 40
page 41
page 42
page 43
page 44
page 45
page 46
page 47
page 48
page 49
page 50
page 51
page 52
page 53
page 54
page 55
page 56
page 57
page 58
page 59
page 60
page 61
page 62
page 63
page 64
page 65
page 66
page 67
page 68
page 69
page 70
page 71
page 72
page 73
page 74
page 75
page 76
page 77
page 78
page 79
page 80
page 81
page 82
page 83
page 84
page 85
page 86
page 87
page 88
page 89
page 90
page 91
page 92
page 93
page 94
page 95
page 96
page 97
page 98
page 99
page 100
page 101
page 102
page 103
page 104
page 105
page 106
page 107
page 108
page 109
page 110
page 111
page 112
page 113
page 114
page 115
page 116
page 117
page 118
page 119
page 120
page 121
page 122
page 123
page 124
page 125
page 126
page 127
page 128
page 129
page 130
page 131
page 132
page 133
page 134
page 135
page 136
page 137
page 138
page 139
page 140
page 141
page 142
page 143
page 144
page 145
page 146
page 147
page 148
page 149
page 150
page 151
page 152
page 153
page 154
page 155
page 156
page 157
page 158
page 159
page 160
page 161
page 162
page 163
page 164
page 165
page 166
page 167
page 168
page 169
page 170
page 171
page 172
page 173
page 174
page 175
page 176
page 177
page 178
page 179
page 180
page 181
page 182
page 183
page 184
page 185
page 186
page 187
page 188
page 189
page 190
page 191
page 192
page 193
page 194
page 195
page 196
page 197
page 198
page 199
page 200
page 201
page 202
page 203
page 204
page 205
page 206
page 207
page 208
page 209
page 210
page 211
page 212
page 213
page 214
page 215
page 216
page 217
page 218
page 219
page 220
page 221
page 222
page 223
page 224
page 225
page 226
page 227
page 228
page 229
page 230
page 231
page 232
page 233
page 234
page 235
page 236
page 237
page 238
page 239
page 240
page 241
page 242
page 243
page 244
page 245
page 246
page 247
page 248
page 249
page 250
page 251
page 252
page 253
page 254
page 255
page 256
page 257
page 258
page 259
page 260
page 261
page 262
page 263
page 264
page 265
page 266
page 267
page 268
page 269
page 270
page 271
page 272
page 273
page 274
page 275
page 276
page 277
page 278
page 279
page 280
page 281
page 282
page 283
page 284
page 285
page 286
page 287
page 288
page 289
page 290
page 291
page 292
page 293
page 294
page 295
page 296
page 297
page 298
page 299
page 300
page 301
page 302
page 303
page 304
page 305
page 306
page 307
page 308
page 309
page 310
page 311
page 312
page 313
page 314
page 315
page 316
page 317
page 318
page 319
page 320
page 321
page 322
page 323
page 324
page 325
page 326
page 327
page 328
page 329
page 330
page 331
page 332
page 333
page 334
page 335
page 336
page 337
page 338
page 339
page 340
page 341
page 342
page 343
page 344
page 345
page 346
page 347
page 348
page 349
page 350
page 351
page 352
page 353
page 354
page 355
page 356
page 357
page 358
page 359
page 360
page 361
page 362
page 363
page 364
page 365
page 366
page 367
page 368
page 369
page 370
page 371
page 372
page 373
page 374
page 375
page 376
page 377
page 378
page 379
page 380
page 381
page 382
page 383
page 384
page 385
page 386
page 387
page 388
page 389
page 390
page 391
page 392
page 393
page 394
page 395
page 396
page 397
page 398
page 399
page 400
page 401
page 402
page 403
page 404
page 405
page 406
page 407
page 408
page 409
page 410
page 411
page 412
page 413
page 414
page 415
page 416
page 417
page 418
page 419
page 420
page 421
page 422
page 423
page 424
page 425
page 426
page 427
page 428
page 429
page 430
page 431
page 432
page 433
page 434
page 435
page 436
page 437
page 438
page 439
page 440
page 441
page 442
page 443
page 444
page 445
page 446
page 447
page 448
page 449
page 450
page 451
page 452
page 453
page 454
page 455
page 456
page 457
page 458
page 459
page 460
page 461
page 462
page 463
page 464
page 465
page 466
page 467
page 468
page 469
page 470
page 471
page 472
page 473
page 474
page 475
page 476
page 477
page 478
page 479
page 480
page 481
page 482
page 483
page 484
page 485
page 486
page 487
page 488
page 489
page 490
page 491
page 492
page 493
page 494
page 495
page 496
page 497
page 498
page 499
page 500
page 501
page 502
page 503
page 504
page 505
page 506
page 507
page 508
page 509
page 510
page 511
page 512
page 513
page 514
page 515
page 516
page 517
page 518
page 519
page 520
page 521
page 522
page 523
page 524
page 525
page 526
page 527
page 528
page 529
page 530
page 531
page 532
page 533
page 534
page 535
page 536
page 537
page 538
page 539
page 540
page 541
page 542
page 543
page 544
page 545
page 546
page 547
page 548
page 549
page 550
page 551
page 552
page 553
page 554
page 555
page 556
page 557
page 558
page 559
page 560
page 561
page 562
page 563
page 564
page 565
page 566
page 567
page 568
page 569
page 570
page 571
page 572
page 573
page 574
page 575
page 576
page 577
page 578
page 579
page 580
page 581
page 582
page 583
page 584
page 585
page 586
page 587
page 588
page 589
page 590
page 591
page 592
page 593
page 594
page 595
page 596
page 597
page 598
page 599
page 600
page 601
page 602
page 603
page 604
page 605
page 606
page 607
page 608
page 609
page 610
page 611
page 612
page 613
page 614
page 615
page 616
page 617
page 618
page 619
page 620
page 621
page 622
page 623
page 624
page 625
page 626
page 627
page 628
page 629
page 630
page 631
page 632
page 633
page 634
page 635
page 636
page 637
page 638
page 639
page 640
page 641
page 642
page 643
page 644
page 645
page 646
page 647
page 648
page 649
page 650
page 651
page 652
page 653
page 654
page 655
page 656
page 657
page 658
page 659
page 660
page 661
page 662
page 663
page 664
page 665
page 666
page 667
page 668
page 669
page 670
page 671
page 672
page 673
page 674
page 675
page 676
page 677
page 678
page 679
page 680
page 681
page 682
page 683
page 684
page 685
page 686
page 687
page 688
page 689
page 690
page 691
page 692
page 693
page 694
page 695
page 696
page 697
page 698
page 699
page 700
page 701
page 702
page 703
page 704
page 705
page 706
page 707
page 708
page 709
page 710
page 711
page 712
page 713
page 714
page 715
page 716
page 717
page 718
page 719
page 720
page 721
page 722
page 723
page 724
page 725
page 726
page 727
page 728
page 729
page 730
page 731
page 732
page 733
page 734
page 735
page 736
page 737
page 738
page 739
page 740
page 741
page 742
page 743
page 744
page 745
page 746
page 747
page 748
page 749
page 750
page 751
page 752
page 753
page 754
page 755
page 756
page 757
page 758
page 759
page 760
page 761
page 762
page 763
page 764
page 765
page 766
page 767
page 768
page 769
page 770
page 771
page 772
page 773
page 774
page 775
page 776
page 777
page 778
page 779
page 780
page 781
page 782
page 783
page 784
page 785
page 786
page 787
page 788
page 789
page 790
page 791
page 792
page 793
page 794
page 795
page 796
page 797
page 798
page 799
page 800
page 801
page 802
page 803
page 804
page 805
page 806
page 807
page 808
page 809
page 810
page 811
page 812
page 813
page 814
page 815
page 816
page 817
page 818
page 819
page 820
page 821
page 822
page 823
page 824
page 825
page 826
page 827
page 828
page 829
page 830
page 831
page 832
page 833
page 834
page 835
page 836
page 837
page 838
page 839
page 840
page 841
page 842
page 843
page 844
page 845
page 846
page 847
page 848
page 849
page 850
page 851
page 852
page 853
page 854
page 855
page 856
page 857
page 858
page 859
page 860
page 861
page 862
page 863
page 864
page 865
page 866
page 867
page 868
page 869
page 870
page 871
page 872
page 873
page 874
page 875
page 876
page 877
page 878
page 879
page 880
page 881
page 882
page 883
page 884
page 885
page 886
page 887
page 888
page 889
page 890
page 891
page 892
page 893
page 894
page 895
page 896
page 897
page 898
page 899
page 900
page 901
page 902
page 903
page 904
page 905
page 906
page 907
page 908
page 909
page 910
page 911
page 912
page 913
page 914
page 915
page 916
page 917
page 918
page 919
page 920
page 921
page 922
page 923
page 924
page 925
page 926
page 927
page 928
page 929
page 930
page 931
page 932
page 933
page 934
page 935
page 936
page 937
page 938
page 939
page 940
page 941
page 942
page 943

Filter Results

9,423 results
9,423 results
Python How to Define and Use Python Lists

Article / Updated 10-28-2024

The simplest data collection in Python is a list. A list is any list of data items, separated by commas, inside square brackets. Typically, you assign a name to the Python list using an = sign, just as you would with variables. If the list contains numbers, then don't use quotation marks around them. For example, here is a list of test scores: scores = [88, 92, 78, 90, 98, 84] If the list contains strings then, as always, those strings should be enclosed in single or double quotation marks, as in this example: To display the contents of a list on the screen, you can print it just as you would print any regular variable. For example, executing print(students) in your code after defining that list shows this on the screen. ['Mark', 'Amber', 'Todd', 'Anita', 'Sandy'] This may not be exactly what you had in mind. But don’t worry, Python offers lots of great ways to access data in lists and display it however you like. Referencing Python list items by position Each item in a list has a position number, starting with zero, even though you don’t see any numbers. You can refer to any item in the list by its number using the name for the list followed by a number in square brackets. In other words, use this syntax: <em>listname</em>[<em>x</em>] Replace <em><code>listname</code></em> with the name of the list you're accessing and replace <em><code>x</code></em> with the position number of item you want. Remember, the first item is always number zero, not one. For example, in the first line below, I define a list named <code>students</code>, and then print item number zero from that list. The result, when executing the code, is that the name <code>Mark</code> is displayed. students = ["Mark", "Amber", "Todd", "Anita", "Sandy"] print(students[0]) Mark When reading access list items, professionals use the word sub before the number. For example, students[0] would be spoken as students sub zero. This next example shows a list named scores. The print() function prints the position number of the last score in the list, which is 4 (because the first one is always zero). scores = [88, 92, 78, 90, 84] print(scores[4]) 84 If you try to access a list item that doesn't exist, you get an “index out of range” error. The index part is a reference to the number inside the square brackets. For example, the image below shows a little experiment in a Jupyter notebook where a list of scores was created and then the printing of score[5] was attempted. It failed and generated an error because there is no scores[5]. There's only scores[0], scores[1], scores[2], scores[3], and scores[4] because the counting always starts at zero with the first one on the list. Looping through a Python list To access each item in a list, just use a for loop with this syntax: for <em>x</em> in <em>list</em>: Replace >x with a variable name of your choosing. Replace list with the name of the list. An easy way to make the code readable is to always use a plural for the list name (such as students, scores). Then you can use the singular name (student, score) for the variable name. You don't need to use subscript numbers (numbers in square brackets) with this approach either. For example, the following code prints each score in the scores list: for score in scores: print(score) Remember to always indent the code that’s to be executed within the loop. This image shows a more complete example where you can see the result of running the code in a Jupyter notebook. Seeing whether a Python list contains an item If you want your code to check the contents of a list to see whether it already contains some item, use in <em>listname</em> in an if statement or a variable assignment. For example, the code in the image below creates a list of names. Then, two variables store the results of searching the list for the names Anita and Bob. Printing the contents of each variable shows True for the one where the name (Anita) is in the list. The test to see whether Bob is in the list proves False. Getting the length of a Python list To determine how many items are in a list, use the len() function (short for length). Put the name of the list inside the parentheses. For example, type the following code into a Jupyter notebook or Python prompt or whatever: students = ["Mark", "Amber", "Todd", "Anita", "Sandy"] print(len(students)) Running that code produces this output: 5 There are indeed five items in the list, though the last one is always one less than the number because Python starts counting at zero. So the last one, Sandy, actually refers to students[4] and not students[5]. Appending an item to the end of a Python list When you want your Python code to add a new item to the end of a list, use the .append() method with the value you want to add inside the parentheses. You can use either a variable name or a literal value inside the quotation marks. For instance, in the following image the line that reads students.append("Goober") adds the name Goober to the list. The line that reads students.append(new_student) adds whatever name is stored in the variable named new_student to the list. The .append() method always adds to the end of the list. So when you print the list you see those two new names at the end. You can use a test to see whether an item is in a list and then append it only when the item isn't already there. For example, the code below won’t add the name Amber to the list because that name is already in the list: student_name = "Amanda" #Add student_name but only if not already in the list. if student_name in students: print (student_name + " already in the list") else: students.append(student_name) print (student_name + " added to the list") Inserting an item into a Python list Although the append() method allows you to add an item to the end of a list, the insert() method allows you to add an item to the list in any position. The syntax for insert() is <em>listname</em>.insert(<em>position</em>, <em>item</em>) Replace listname with the name of the list, position with the position at which you want to insert the item (for example, 0 to make it the first item, 1 to make it the second item, and so forth). Replace item with the value, or the name of a variable that contains the value, that you want to put into the list. For example, the following code makes Lupe the first item in the list: #Create a list of strings (names). students = ["Mark", "Amber", "Todd", "Anita", "Sandy"] student_name = "Lupe" # Add student name to front of the list. students.insert(0,student_name) #Show me the new list. print(students) If you run the code, print(students) will show the list after the new name has been inserted, as follows: ['Lupe', 'Mark', 'Amber', 'Todd', 'Anita', 'Sandy'] Changing an item in a Python list You can change an item in a list using the = assignment operator (check out these common Python operators) just like you do with variables. Just make sure you include the index number in square brackets of the item you want to change. The syntax is: listname[index]=newvalue Replace listname with the name of the list; replace index with the subscript (index number) of the item you want to change; and replace newvalue with whatever you want to put in the list item. For example, take a look at this code: #Create a list of strings (names). students = ["Mark", "Amber", "Todd", "Anita", "Sandy"] students[3] = "Hobart" print(students) When you run this code, the output is as follows, because Anita's name has been changed to Hobart. ['Mark', 'Amber', 'Todd', 'Hobart', 'Sandy'] Combining Python lists If you have two lists that you want to combine into a single list, use the extend() function with the syntax: <em>original_list</em>.extend(<em>additional_items_list</em>) In your code, replace original_list with the name of the list to which you’ll be adding new list items. Replace additional_items_list with the name of the list that contains the items you want to add to the first list. Here is a simple example using lists named list1 and list2. After executing list1.extend(list2), the first list contains the items from both lists, as you can see in the output of the print() statement at the end. # Create two lists of Names. list1 = ["Zara", "Lupe", "Hong", "Alberto", "Jake"] list2 = ["Huey", "Dewey", "Louie", "Nader", "Bubba"] # Add list2 names to list1. list1.extend(list2) # Print list 1. print(list1) ['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake', 'Huey', 'Dewey', 'Louie', 'Nader', 'Bubba'] Easy Parcheesi, no? Removing Python list items Python offers a remove() method so you can remove any value from the list. If the item is in the list multiple times, only the first occurrence is removed. For example, the following code shows a list of letters with the letter C repeated a few times. Then the code uses letters.remove("C") to remove the letter C from the list: # Remove "C" from the list. letters.remove("C") #Show me the new list. print(letters) When you actually execute this code and then print the list, you'll see that only the first letter C has been removed: ['A', 'B', 'D', 'C', 'E', 'C'] If you need to remove all of an item, you can use a while loop to repeat the .remove as long as the item still remains in the list. For example, this code repeats the .remove as long as the “C” is still in the list. #Create a list of strings. letters = ["A", "B", "C", "D", "C", "E", "C"] If you want to remove an item based on its position in the list, use pop() with an index number rather than remove() with a value. If you want to remove the last item from the list, use pop() without an index number. For example, the following code creates a list, one line removes the first item (0), and another removes the last item (pop() with nothing in the parentheses). Printing the list shows those two items have been removed: #Create a list of strings. letters = ["A", "B", "C", "D", "E", "F", "G"] #Remove the first item. letters.pop(0) #Remove the last item. letters.pop() #Show me the new list. print(letters) Running the code shows that the popping the first and last items did, indeed, work: ['B', 'C', 'D', 'E', 'F'] When you pop() an item off the list, you can store a copy of that value in some variable. For example this image shows the same code as above. However, it stores copies of what's been removed in variables named first_removed and last_removed. At the end it prints the Python list, and also shows which letters were removed. Python also offers a del (short for delete) command that deletes any item from a list based on its index number (position). But again, you have to remember that the first item is zero. So, let's say you run the following code to delete item number 2 from the list: # Create a list of strings. letters = ["A", "B", "C", "D", "E", "F", "G"] # Remove item sub 2. del letters[2] print(letters) Running that code shows the list again, as follows. The letter C has been deleted, which is the correct item to delete because letters are numbered 0, 1, 2, 3, and so forth. ['A', 'B', 'D', 'E', 'F', 'G'] You can also use del to delete an entire list. Just don’t use the square brackets and the index number. For example, the code you see below creates a list then deletes it. Trying to print the list after the deletion causes an error, because the list no longer exists when the print() statement is executed. Clearing out a Python list If you want to delete the contents of a list but not the list itself, use .clear(). The list still exists; however, it contains no items. In other words, it's an empty list. The following code shows how you could test this. Running the code displays [] at the end, which lets you know the list is empty: # Create a list of strings. letters = ["A", "B", "C", "D", "E", "F", "G"] # Clear the list of all entries. letters.clear() # Show me the new list. print(letters) Counting how many times an item appears in a Python list You can use the Python count() method to count how many times an item appears in a list. As with other list methods, the syntax is simple: <em>listname</em>.count(<em>x</em>) Replace listname with the name of your list, and x with the value you're looking for (or the name of a variable that contains that value). The code in the image below counts how many times the letter B appears in the list, using a literal B inside the parentheses of .count(). This same code also counts the number of C grades, but that value was stored in a variable just to show the difference in syntax. Both counts worked, as you can see in the output of the program at the bottom. One was added to count the F's, not using any variables. The F’s were counted right in the code that displays the message. There are no F grades, so this returns zero, as you can see in the output. When trying to combine numbers and strings to form a message, remember you have to convert the numbers to strings using the str() function. Otherwise, you get an error that reads something like can only concatenate str (not "int") to str. In that message, int is short for integer, and str is short for string. Finding a Python list item's index Python offers an .index() method that returns a number indicating the position, based on index number, of an item in a list. The syntax is: <em>listname</em>.index(<em>x</em>) As always, replace listname with name of the list you want to search. Replace x what whatever you're looking for (either as a literal or as a variable name, as always). Of course, there’s no guarantee that the item is in the list, and even if it is, there’s no guarantee that the item is in the list only once. If the item isn’t in the list, then an error occurs. If the item is in the list multiple times, then the index of the first matching item is returned. The following image shows an example where the program crashes at the line f_index = grades.index(look_for) because there is no F in the list. An easy way to get around that problem is to use an if statement to see whether an item is in the list before you try to get its index number. If the item isn't in the list, display a message saying so. Otherwise, get the index number and show it in a message. That code is as follows: # Create a list of strings. grades = ["C", "B", "A", "D", "C", "B", "C"] # Decide what to look for look_for = "F" # See if the item is in the list. if look_for in grades: # If it's in the list, get and show the index. print(str(look_for) + " is at index " + str(grades.index(look_for))) else: # If not in the list, don't even try for index number. print(str(look_for) + " isn't in the list.") Alphabetizing and sorting Python lists Python offers a sort() method for sorting lists. In its simplest form, it alphabetizes the items in the list (if they’re strings). If the list contains numbers, they’re sorted smallest to largest. For a simple sort like that, just use sort() with empty parentheses: <em>listname</em>.sort() Replace listname with the name of your list. The following image shows an example using a list of strings and a list of numbers. In the example, a new list was created for each of them simply by assigning each sorted list to a new list name. Then the code prints the contents of each sorted list. If your list contains strings with a mixture of uppercase and lowercase letters, and if the results of the sort don't look right, try replacing .sort() with .sort(key=lambda s:s.lower()) and then running the code again. Dates are a little trickier because you can’t just type them in as strings, like "12/31/2020". They have to be the date data type to sort correctly. This means using the datetime module and the date() method to define each date. You can add the dates to the list as you would any other list. For example, in the following line, the code creates a list of four dates, and the code is perfectly fine. dates = [dt.date(2020,12,31), dt.date(2019,1,31), dt.date(2018,2,28), dt.date(2020,1,1)] The computer certainly won't mind if you create the list this way. But if you want to make the code more readable to yourself or other developers, you may want to create and append each date, one at a time, so just so it’s a little easier to see what’s going on and so you don’t have to deal with so many commas in one line of code. The image below shows an example where an empty list named datelist was created: datelist = [] Then one date at a time was appended to the list using the dt.date(<em>year</em>,<em>month</em>,<em>day</em>) syntax. After the list is created, the code uses datelist.sort() to sort them into chronological order (earliest to latest). You don’t need to use print(datelist) in that code because that method displays the dates with the data type information included, like this: [datetime.date(2018, 2, 28), datetime.date(2019, 1, 31), datetime.date (2020, 1, 1), datetime.date(2020, 12, 31)] Not the easiest list to read. So, rather than print the whole list with one print() statement, you can loop through each date in the list, and printed each one formatted with the f-string %m/%d/%Y. This displays each date on its own line in mm/dd/yyyy format, as you can see at the bottom of the image above. If you want to sort items in reverse order, put reverse=True inside the sort() parentheses (and don't forget to make the first letter uppercase). The image below shows examples of sorting all three lists in descending (reverse) order using reverse=True. Reversing a Python list You can also reverse the order of items in a list using the .reverse method. This is not the same as sorting in reverse, because when you sort in reverse, you still actually sort: Z–A for strings, largest to smallest for numbers, latest to earliest for dates. When you reverse a list, you simply reverse the items in the list, no matter their order, without trying to sort them in any way. The following code shows an example in which you reverse the order of the names in the list and then print the list. The output shows the list items reversed from their original order: # Create a list of strings. names = ["Zara", "Lupe", "Hong", "Alberto", "Jake"] # Reverse the list names.reverse() # Print the list print(names) ['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara'] Copying a Python list If you ever need to work with a copy of a list, use the .copy() method so as not to alter the original list,. For example, the following code is similar to the preceding code, except that instead of reversing the order of the original list, you make a copy of the list and reverse that one. Printing the contents of each list shows how the first list is still in the original order whereas the second one is reversed: # Create a list of strings. names = ["Zara", "Lupe", "Hong", "Alberto", "Jake"] # Make a copy of the list backward_names = names.copy() # Reverse the copy backward_names.reverse() # Print the list print(names) print(backward_names) ['Zara', 'Lupe', 'Hong', 'Alberto', 'Jake'] ['Jake', 'Alberto', 'Hong', 'Lupe', 'Zara'] For future references, the following table summarizes the methods you've learned about. Methods for Working with Lists Method What it Does append() Adds an item to the end of the list. clear() Removes all items from the list, leaving it empty. copy() Makes a copy of a list. count() Counts how many times an element appears in a list. extend() Appends the items from one list to the end of another list. index() Returns the index number (position) of an element within a list. insert() Inserts an item into the list at a specific position. pop() Removes an element from the list, and provides a copy of that item that you can store in a variable. remove() Removes one item from the list. reverse() Reverses the order of items in the list. sort() Sorts the list in ascending order. Put reverse=True inside the parentheses to sort in descending order.

View Article
Generative AI Envision the World as a Graph with Bayes' Theorem

Article / Updated 10-28-2024

Bayes’ theorem can help you deduce how likely something is to happen in a certain context, based on the general probabilities of the fact itself and the evidence you examine, and combined with the probability of the evidence given the fact. Seldom will a single piece of evidence diminish doubts and provide enough certainty in a prediction to ensure that it will happen. As a true detective, to reach certainty, you have to collect more evidence and make the individual pieces work together in your investigation. Noticing that a person has long hair isn’t enough to determine whether person is female or a male. Adding data about height and weight could help increase confidence. The Naïve Bayes algorithm helps you arrange all the evidence you gather and reach a more solid prediction with a higher likelihood of being correct. Gathered evidence considered singularly couldn’t save you from the risk of predicting incorrectly, but all evidence summed together can reach a more definitive resolution. The following example shows how things work in a Naïve Bayes classification. This is an old, renowned problem, but it represents the kind of capability that you can expect from an AI. The dataset is from the paper “Induction of Decision Trees,” by John Ross Quinlan. Quinlan is a computer scientist who contributed to the development of another machine learning algorithm, decision trees, in a fundamental way, but his example works well with any kind of learning algorithm. The problem requires that the AI guess the best conditions to play tennis given the weather conditions. The set of features described by Quinlan is as follows: Outlook: Sunny, overcast, or rainy Temperature: Cool, mild, or hot Humidity: High or normal Windy: True or false The following table contains the database entries used for the example: Outlook Temperature Humidity Windy PlayTennis Sunny Hot High False No Sunny Hot High True No Overcast Hot High False Yes Rainy Mild High False Yes Rainy Cool Normal False Yes Rainy Cool Normal True No Overcast Cool Normal True Yes Sunny Mild High False No Sunny Cool Normal False Yes Rainy Mild Normal False Yes Sunny Mild Normal True Yes Overcast Mild High True Yes Overcast Hot Normal False Yes Rainy Mild High True No The option of playing tennis depends on the four arguments shown here. The result of this AI learning example is a decision as to whether to play tennis, given the weather conditions (the evidence). Using just the outlook (sunny, overcast, or rainy) won’t be enough, because the temperature and humidity could be too high or the wind might be strong. These arguments represent real conditions that have multiple causes, or causes that are interconnected. The Naïve Bayes algorithm is skilled at guessing correctly when multiple causes exist. The algorithm computes a score, based on the probability of making a particular decision and multiplied by the probabilities of the evidence connected to that decision. For instance, to determine whether to play tennis when the outlook is sunny but the wind is strong, the algorithm computes the score for a positive answer by multiplying the general probability of playing (9 played games out of 14 occurrences) by the probability of the day’s being sunny (2 out of 9 played games) and of having windy conditions when playing tennis (3 out of 9 played games). The same rules apply for the negative case (which has different probabilities for not playing given certain conditions): likelihood of playing: 9/14 * 2/9 * 3/9 = 0.05 likelihood of not playing: 5/14 * 3/5 * 3/5 = 0.13 Because the score for the likelihood is higher, the algorithm decides that it’s safer not to play under such conditions. It computes such likelihood by summing the two scores and dividing both scores by their sum: probability of playing : 0.05 / (0.05 + 0.13) = 0.278 probability of not playing : 0.13 / (0.05 + 0.13) = 0.722 You can further extend Naïve Bayes to represent relationships that are more complex than a series of factors that hint at the likelihood of an outcome using a Bayesian network, which consists of graphs showing how events affect each other. Bayesian graphs have nodes that represent the events and arcs showing which events affect others, accompanied by a table of conditional probabilities that show how the relationship works in terms of probability. The figure shows a famous example of a Bayesian network taken from a 1988 academic paper, “Local computations with probabilities on graphical structures and their application to expert systems,” by Lauritzen, Steffen L. and David J. Spiegelhalter, published by the Journal of the Royal Statistical Society. The depicted network is called Asia. It shows possible patient conditions and what causes what. For instance, if a patient has dyspnea, it could be an effect of tuberculosis, lung cancer, or bronchitis. Knowing whether the patient smokes, has been to Asia, or has anomalous x-ray results (thus giving certainty to certain pieces of evidence, a priori in Bayesian language) helps infer the real (posterior) probabilities of having any of the pathologies in the graph. Bayesian networks, though intuitive, have complex math behind them, and they’re more powerful than a simple Naïve Bayes algorithm because they mimic the world as a sequence of causes and effects based on probability. Bayesian networks are so effective that you can use them to represent any situation. They have varied applications, such as medical diagnoses, the fusing of uncertain data arriving from multiple sensors, economic modeling, and the monitoring of complex systems such as a car. For instance, because driving in highway traffic may involve complex situations with many vehicles, the Analysis of MassIve Data STreams (AMIDST) consortium, in collaboration with the automaker Daimler, devised a Bayesian network that can recognize maneuvers by other vehicles and increase driving safety.

View Article
YouTube How to Download YouTube Videos

Article / Updated 10-28-2024

YouTube is a video-sharing website where users post all kinds of media. YouTube is so popular that it has one billion unique visits every single month. From how-tos to educational cartoons, YouTube has a large selection of videos from every genre. You’ve likely watched videos on YouTube and seen something that you might want to watch when you don’t have access to the internet. Need a cartoon for your child who watch while on an airplane? Or, maybe an instructional video to review while actually doing the task later? Downloading YouTube videos is quite simple. How to download YouTube videos with Keepvid You can use keepvid.com to download YouTube videos. Follow these steps to use Keepvid: Go to YouTube and find the video you’d like to download. Click the Share button underneath the video on YouTube to copy the link. Open a new window and navigate to keepvid.com. Paste the link into the download text box. Click download and save the video.All done! Keepvid can also download videos from other websites, including videos posted to social media. Before you begin downloading videos from YouTube, you need to understand the legal issues that accompany your use of those videos. YouTube content is copyrighted. That means that you absolutely cannot download it for anything other than personal use. Also, Google (the owner of YouTube) includes terms of service for users. These terms specifically state: “You shall not download any Content unless you see a 'download' or similar link displayed by YouTube on the Service for that Content” (Section 5 – B). The following is provided for informational purposes only. There are several methods for downloading YouTube videos. The instructions above discuss one popular way to complete the task, but other options exist. There are numerous software suites available to download these videos. If you prefer this method, you can easily find choices by searching the internet for “YouTube downloading software.” The directions you find here discuss the use of websites that are specifically created to download YouTube videos.

View Article
Java The Atoms: Java’s Primitive Types

Article / Updated 10-28-2024

The words int and double are examples of primitive types (also known as simple types) in Java. The Java language has exactly eight primitive types. As a newcomer to Java, you can pretty much ignore all but four of these types. (As programming languages go, Java is nice and compact that way.) The types that you shouldn’t ignore are int, double, char, and boolean. The char type Several decades ago, people thought computers existed only for doing big number-crunching calculations. Nowadays, nobody thinks that way. So, if you haven’t been in a cryogenic freezing chamber for the past 20 years, you know that computers store letters, punctuation symbols, and other characters. The Java type that’s used to store characters is called char. The code below has a simple program that uses the char type. This image shows the output of the program in the code below. public class CharDemo { public static void main(String args[]) { char myLittleChar = 'b'; char myBigChar = Character.toUpperCase(myLittleChar); System.out.println(myBigChar); } } In this code, the first initialization stores the letter b in the variable myLittleChar. In the initialization, notice how b is surrounded by single quote marks. In Java, every char literally starts and ends with a single quote mark. In a Java program, single quote marks surround the letter in a char literal. Character.toUpperCase. The Character.toUpperCase method does just what its name suggests — the method produces the uppercase equivalent of the letter b. This uppercase equivalent (the letter B) is assigned to the myBigChar variable, and the B that’s in myBigChar prints onscreen. If you’re tempted to write the following statement, char myLittleChars = 'barry'; //Don't do this please resist the temptation. You can’t store more than one letter at a time in a char variable, and you can’t put more than one letter between a pair of single quotes. If you’re trying to store words or sentences (not just single letters), you need to use something called a String. If you’re used to writing programs in other languages, you may be aware of something called ASCII character encoding. Most languages use ASCII; Java uses Unicode. In the old ASCII representation, each character takes up only 8 bits, but in Unicode, each character takes up 8, 16, or 32 bits. Whereas ASCII stores the letters of the Roman (English) alphabet, Unicode has room for characters from most of the world’s commonly spoken languages. The only problem is that some of the Java API methods are geared specially toward 16-bit Unicode. Occasionally, this bites you in the back (or it bytes you in the back, as the case may be). If you’re using a method to write Hello on the screen and H e l l o shows up instead, check the method’s documentation for mention of Unicode characters. It’s worth noticing that the two methods, Character.toUpperCase and System.out.println, are used quite differently in the code above. The method Character.toUpperCase is called as part of an initialization or an assignment statement, but the method System.out.println is called on its own. The boolean type A variable of type boolean stores one of two values: true or false. The code below demonstrates the use of a boolean variable. public class ElevatorFitter2 { public static void main(String args[]) { System.out.println("True or False?"); System.out.println("You can fit all ten of the"); System.out.println("Brickenchicker dectuplets"); System.out.println("on the elevator:"); System.out.println(); int weightOfAPerson = 150; int elevatorWeightLimit = 1400; int numberOfPeople = elevatorWeightLimit / weightOfAPerson; <strong> boolean allTenOkay = numberOfPeople >= 10;</strong> System.out.println(allTenOkay); } } In this code, the allTenOkay variable is of type boolean. To find a value for the allTenOkay variable, the program checks to see whether numberOfPeople is greater than or equal to ten. (The symbols >= stand for greater than or equal to.) At this point, it pays to be fussy about terminology. Any part of a Java program that has a value is an expression. If you write weightOfAPerson = 150; then 150 ,is an expression (an expression whose value is the quantity 150). If you write numberOfEggs = 2 + 2; then 2 + 2 is an expression (because 2 + 2 has the value 4). If you write int numberOfPeople = elevatorWeightLimit / weightOfAPerson; then elevatorWeightLimit / weightOfAPerson is an expression. (The value of the expression elevatorWeightLimit / weightOfAPerson depends on whatever values the variables elevatorWeightLimit and weightOfAPerson have when the code containing the expression is executed.) Any part of a Java program that has a value is an expression. In the second set of code, numberOfPeople >= 10 is an expression. The expression’s value depends on the value stored in the numberOfPeople variable. But, as you know from seeing the strawberry shortcake at the Brickenchicker family’s catered lunch, the value of numberOfPeople isn’t greater than or equal to ten. As a result, the value of numberOfPeople >= 10 is false. So, in the statement in the second set of code, in which allTenOkay is assigned a value, the allTenOkay variable is assigned a false value. In the second set of code, System.out.println() is called with nothing inside the parentheses. When you do this, Java adds a line break to the program’s output. In the second set of code, System.out.println() tells the program to display a blank line.

View Article
Coding Tips for Debugging the Code in Your Mobile App

Article / Updated 10-28-2024

When coding your app, you will almost inevitably write code that does not behave as you intended. HTML and CSS are relatively forgiving, with the browser even going so far as to insert tags so the page renders properly. However, JavaScript isn’t so forgiving, and the smallest error, such as a missing quotation mark, can cause the page to not render properly. Errors in web applications can consist of syntax errors, logic errors, and display errors. Often, the most likely culprit causing errors in your code will be syntax related. Here are some common errors to check when debugging your code: Opening and closing tags: In HTML, every opening tag has a closing tag, and you always close the most recently opened tag first. Right and left angle brackets: In HTML, every left angle bracket < has a right angle bracket >. Right and left curly brackets: In CSS and JavaScript, every left curly bracket must have a right curly bracket. It can be easy to accidentally delete it or forget to include it. Indentation: Indent your code and use plenty of tabs and returns to make your code as readable as possible. Proper indentation will make it easier for you to identify missing tags, angle brackets, and curly brackets. Misspelled statements: Tags in any language can be misspelled, or spelled correctly but not part of the specification. For example, in HTML, <img scr="image.jpg"> is incorrect because scr should really be src for the image to render properly. Similarly, in CSS font-color looks like it is spelled correctly but no such property exists. The correct property to set font color is just color. Keep these errors in mind when debugging — they may not solve all your problems, but they should solve many of them. If you have tried the steps above and still cannot debug your code, tweet @nikhilgabraham and include the #codingFD hashtag and your codepen.io URL in your tweet.

View Article
eBay How to Add a Video to Your eBay Listing

Article / Updated 10-28-2024

When a demonstration of the product you are selling on eBay would benefit from more graphic illustration, consider adding a video. The easiest way to add a video to your eBay listing is to use eBay's new listing tool when you are creating or revising your listing. Follow these steps Click on the Add video button. Select a file on your device or drag and drop the video to the web page. You can also use the Import from mobile and Import from web buttons. When you type your description, you have the option of jazzing things up with a bit of HTML coding, or you can use eBay’s HTML text editor. If you know how to use a word processor, you’ll have no trouble touching up your text with this tool. Here are a few additional codes if you’d like to manually insert the code in the HTML view. HTML Code How to Use It What It Does cool collectible cool collectible (bold type) cool collectible cool collectible (italic type) cool collectible cool collectible (bold and italic type) cool collectible Selected text appears in red. cool collectible cool collectible (font size normal +1 through 4, increases size x times) coolcollectible cool collectible (inserts line break) coolcollectible cool collectible (inserts paragraph space) cool collectiblecheap cool collectible_____________cheap (inserts horizontal rule) cool collectible cool collectible (converts text to headline size) You can go back and forth from the HTML text editor to regular input and add additional codes here and there by clicking from the Standard form to the HTML entry form tabs. You can prepare your listings ahead of time and save them in My eBay folder as plain HTML files — that way they’re always retrievable for use (you can just copy and paste) — no matter what program or form you’re using to list. To insert additional photos in your description, use the following code. (Just insert the URL of your hosted picture, along with the photo’s file name.) The example above used the following code: <img scr=##http://www.collierad.com/catbed.jpg##> Occasionally, sellers offer an item as a presale, or an item that the seller doesn’t yet have in stock but expects to. If you’re offering this kind of item, make sure that you spell out all the details in the description. eBay policy states that you must ship a presale item within 30 days of the auction’s end, so be sure that you will have the item within that time span and include the actual shipping date. Putting an item up for sale without having it in hand is a practice fraught with risk. The item you’re expecting may not arrive in time or may arrive damaged. There are many sellers who have had to go out and purchase an item at retail for a buyer to preserve their feedback when caught in this situation.

View Article
General Microsoft How to Search and Filter an Access 2019 Database

Article / Updated 10-28-2024

A paper database is useful for storing information, but not so useful for finding it again. With Access 2019, searching and finding information is easy. If you have a thousand business cards stored in a Rolodex file, how much time do you want to waste trying to find the phone number of a single person? With Access 2019, that is no longer a concern. Searching a database is crucial to make your data useful, so Access provides two ways to search a database: Search for a specific record. Use a filter to show one or more records that meet a specific criterion. Searching MS Access for a specific record The simplest type of search looks for a specific record. To search for a record, you need to know the data stored in at least one of its fields, such as a phone number or an email address. The more information you already know, the more likely Access will find the one record you want. If you search for all records that contain the first name Bill, Access could find dozens of records. If you just search for all records that contain the first name Bill, the last name Johnson, and a state address of Alaska, Access will likely find just the record you want. To search for a specific record in an Access database table, follow these steps: In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to search. Access displays the Datasheet view of your database. Click the Home tab. In the Find group, click the Find icon. The Find and Replace dialog box appears. Click in the Find What text box and type the data you know is stored in the record you want to find. For example, if you want to find the phone number of a person but you know only the person’s last name, type the last name in the Find What text box. Click the Look In list box and choose Current field or Current document (searches in all fields). (Optional) Click in the Match list box and choose one of the following: Any Part of Field: The Find What text can appear in any part of a field. Whole Field: The Find What text is the only text stored in a field. Start of Field: The Find What text can be only at the beginning of a field. (Optional) Click in the Search list box and choose one of the following: Up: Searches from the record where the cursor appears, up to the beginning of the database table Down: Searches from the record where the cursor appears, down to the end of the database table All: Searches the entire database table Click Find Next. Access highlights the field where it finds the text you typed in Step 4. Repeat Step 8 to search for more records that may contain the text you typed in Step 4. Click Cancel or the Close button. Filtering an Access database Searching a database is easy but somewhat limited because you can retrieve only a single record at a time that matches any text that you want to find. If you want to find multiple records, you can use a filter. A filter lets you tell Access to display only those records that meet certain criteria, such all records that contain people who earn more than $200,000 a year, are currently married, live in Las Vegas, Nevada, and own two or more cats. To filter a database table, you must tell Access which field or fields to use as a filter, and then you must define the criteria for that filter. For example, if you want to filter your database table to see only records listing the names of people who are at least 65, you filter the Age field and set the criterion to Greater than or equal to 65. Filtering simply hides all records in a database table that don’t match your criteria. Filtering doesn’t delete or erase any records. Using an exact match for a filter in Access 2019 The simplest filtering criterion searches for an exact match. When you filter a field by an exact match, you’re telling Access, “I want to see only those records that contain this specific chunk of data in this particular field.” By using an exact match filter, you can display, for example, only the records that contain CA in the State field. To filter a database table, follow these steps: In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database. Click the Home tab. Click in the field (column) that you want to use as a filter. In the Sort & Filter group, click the Filter icon.A pop-up menu appears. You can either Select or clear check boxes from this menu. Continue with Steps 5 through 7 for more flexibility. Choose Text Filters. A submenu appears. Choose a filter option, such as Equals, Begins With, or Contains. A Custom Filter dialog box appears. Type the data you want to find and click OK. Access displays your filtered data, and a filter icon appears in the column heading. Access remembers your filter settings. If you want to clear the filter, click the filter icon in the column heading; when a pop-up menu appears, choose Clear Filter. To view all the data in your database table, click the Home tab. Then in the Sort & Filter group, click the Toggle Filter icon. Filtering Access databases by form One problem with defining filters in Datasheet view is that you have all your database table records cluttering the screen. To avoid this problem, Access lets you define filters by using a form, which basically displays an empty record so you can click the fields that you want to use to filter your database table. To define a filter by form, follow these steps: In the All Access Objects pane on the left of the screen, double-click the name of the database table that you want to filter. Access displays the Datasheet view of your database. Click the Home tab. In the Sort & Filter group, click the Advanced icon. A pull-down menu appears. Choose Filter by Form. Access displays a blank record. Click in any field, then type the data you want to filter such as a last name. In the Sort & Filter group, click the Advanced icon and then click Apply Filter/Sort. Access displays a filtered view of your database table. You can click the Toggle Filter icon again to view all the data in your database table. Using a filter criteria in Access 2019 Searching for an exact match in a field can be handy, but sometimes you may want to see records that meet certain criteria, such as finding the names of everyone whose salary is greater than $50,000 a year. Instead of filtering by an exact match, you have to define the filter criteria. The type of data stored in each field determines the type of criteria you can create. Three common types of data stored in fields are text, numbers, and dates, which you can filter in different ways. Common Criteria for Filtering Text Data Filtering Criteria Description Equals Field must match filter text exactly. Does Not Equal Field must not match filter text. Begins With Field must start with the filter text. Does Not Begin With Field must not begin with the filter text. Contains Field must contain the filter text. Does Not Contain Field must not contain any part of the filter text. Ends With Field ends with the filter text. Does Not End With Field does not end with the filter text. Common Criteria for Filtering Numeric Data Filtering Criteria Description Equals Field must equal filter number. Does Not Equal Field must not equal filter number. Less Than or Equal To Field must contain a number less than or equal to the filter number. Greater Than or Equal To Field must contain a number greater than or equal to the filter number. Between Field must contain a number that falls between two filter numbers. Common Criteria for Filtering Dates Filtering Criteria Description Equals Field must equal the filter date. Does Not Equal Field must not equal the filter date. On or Before Field date must be equal or earlier than the filter date. On or After Field date must be equal or later than the filter date. To create the filter criteria, follow these steps: In the All Access Objects pane on the left of the screen, double-click the name of the database table you want to filter. Access displays the Datasheet view of your database. Click the Home tab. Click in the field (column) that you want to use as a filter. In the Sort & Filter group, click the Filter icon. A pop-up menu appears. Select the Filters option, such as Text Filters or Number Filters. A submenu of filter options appears. Click a filter option, such as Between or Less Than. The Custom Filter dialog box appears. The Custom Filter dialog box contains the name of your filter option, such as Between Numbers or Less Than. Type one or more values in each text box in the Custom Filter dialog box, and then click OK. Access filters your database table according to your criteria. Repeat Steps 5 through 7 for each additional filter you want to add. You can click the Toggle Filter icon again to view all the data in your database table. Clearing a filter in Access 2019 When you apply a filter to a database table, you see only those records that match that filter. Access displays a Filtered message at the bottom of the screen to let you know when you’re looking at a filtered database table. To remove a filter so you can see all the records, choose one of the following: Click the Toggle Filter icon in the Sort & Filter group. Click the Filtered or Unfiltered button on the status bar near the bottom of the screen. Access temporarily turns off any filters so you can see all the information stored in your database table. When you choose the Save command (Ctrl+S) to save a database table, Access also saves your last filter. The next time you open that database table, you’ll be able to use the last filter you created. If you want to save multiple filters, you’ll have to save them as a query. See these handy Access keyboard shortcuts for further information.

View Article
General Networking Configuring Network Connections for Windows 10

Step by Step / Updated 10-28-2024

Windows usually detects the presence of a network adapter automatically; typically, you don’t have to install device drivers manually for the adapter. When Windows detects a network adapter, Windows automatically creates a network connection and configures it to support basic networking protocols. You may need to change the configuration of a network connection manually, however. The following steps show you how to configure your network adapter on a Windows 10 system:

View Step by Step
Generative AI Generative AI For Dummies Cheat Sheet

Cheat Sheet / Updated 10-17-2024

The first public release of ChatGPT ignited the world’s demand for increasingly sophisticated Generative AI (GenAI) models and tools, and the market was quick to deliver. But what’s the use of having so many GenAI tools if you get stuck using them? And make no mistake, everyone gets stuck quite often! This cheat sheet helps you get the very best results by introducing you to advanced (but pretty easy) prompting techniques and giving you useful tips on how to choose models or applications that are right for the task.

View Cheat Sheet
General Data Science Linear Regression vs. Logistic Regression

Article / Updated 09-24-2024

Both linear and logistic regression see a lot of use in data science but are commonly used for different kinds of problems. You need to know and understand both types of regression to perform a full range of data science tasks. Of the two, logistic regression is harder to understand in many respects because it necessarily uses a more complex equation model. The following information gives you a basic overview of how linear and logistic regression differ. The equation model Any discussion of the difference between linear and logistic regression must start with the underlying equation model. The equation for linear regression is straightforward. y = a + bx You may see this equation in other forms and you may see it called ordinary least squares regression, but the essential concept is always the same. Depending on the source you use, some of the equations used to express logistic regression can become downright terrifying unless you’re a math major. However, the start of this discussion can use one of the simplest views of logistic regression: p = f(a + bx) >p, is equal to the logistic function, f, applied to two model parameters, a and b, and one explanatory variable, x. When you look at this particular model, you see that it really isn’t all that different from the linear regression model, except that you now feed the result of the linear regression through the logistic function to obtain the required curve. The output (dependent variable) is a probability ranging from 0 (not going to happen) to 1 (definitely will happen), or a categorization that says something is either part of the category or not part of the category. (You can also perform multiclass categorization, but focus on the binary response for now.) The best way to view the difference between linear regression output and logistic regression output is to say that the following: Linear regression is continuous. A continuous value can take any value within a specified interval (range) of values. For example, no matter how closely the height of two individuals matches, you can always find someone whose height fits between those two individuals. Examples of continuous values include: Height Weight Waist size Logistic regression is discrete. A discrete value has specific values that it can assume. For example, a hospital can admit only a specific number of patients in a given day. You can’t admit half a patient (at least, not alive). Examples of discrete values include: Number of people at the fair Number of jellybeans in the jar Colors of automobiles produced by a vendor The logistic function Of course, now you need to know about the logistic function. You can find a variety of forms of this function as well, but here’s the easiest one to understand: f(x) = e<sup>x</sup> / e<sup>x</sup> + 1 You already know about f, which is the logistic function, and x equals the algorithm you want to use, which is a + bx in this case. That leaves e, which is the natural logarithm and has an irrational value of 2.718, for the sake of discussion (check out a better approximation of the whole value). Another way you see this function expressed is f(x) = 1 / (1 + e<sup>-x</sup>) Both forms are correct, but the first form is easier to use. Consider a simple problem in which a, the y-intercept, is 0, and ">b, the slope, is 1. The example uses x values from –6 to 6. Consequently, the first f(x) value would look like this when calculated (all values are rounded): (1) e<sup>-6</sup> / (1 + e<sup>-6</sup>) (2) 0.00248 / 1 + 0.00248 (3) 0.002474 As you might expect, an xvalue of 0 would result in an f(x) value of 0.5, and an x value of 6 would result in an f(x) value of 0.9975. Obviously, a linear regression would show different results for precisely the same x values. If you calculate and plot all the results from both logistic and linear regression using the following code, you receive a plot like the one below. import matplotlib.pyplot as plt %matplotlib inline from math import exp x_values = range(-6, 7) lin_values = [(0 + 1*x) / 13 for x in range(0, 13)] log_values = [exp(0 + 1*x) / (1 + exp(0 + 1*x)) for x in x_values] plt.plot(x_values, lin_values, 'b-^') plt.plot(x_values, log_values, 'g-*') plt.legend(['Linear', 'Logistic']) plt.show() This example relies on list comprehension to calculate the values because it makes the calculations clearer. The linear regression uses a different numeric range because you must normalize the values to appear in the 0 to 1 range for comparison. This is also why you divide the calculated values by 13. The exp(x) call used for the logistic regression raises e to the power of x, e<sup>x</sup>, as needed for the logistic function. The model discussed here is simplified, and some math majors out there are probably throwing a temper tantrum of the most profound proportions right now. The Python or R package you use will actually take care of the math in the background, so really, what you need to know is how the math works at a basic level so that you can understand how to use the packages. This section provides what you need to use the packages. However, if you insist on carrying out the calculations the old way, chalk to chalkboard, you’ll likely need a lot more information. The problems that logistic regression solves You can separate logistic regression into several categories. The first is simple logistic regression, in which you have one dependent variable and one independent variable, much as you see in simple linear regression. However, because of how you calculate the logistic regression, you can expect only two kinds of output: Classification: Decides between two available outcomes, such as male or female, yes or no, or high or low. The outcome is dependent on which side of the line a particular data point falls. Probability: Determines the probability that something is true or false. The values true and false can have specific meanings. For example, you might want to know the probability that a particular apple will be yellow or red based on the presence of yellow and red apples in a bin. Fit the curve As part of understanding the difference between linear and logistic regression, consider this grade prediction problem, which lends itself well to linear regression. In the following code, you see the effect of trying to use logistic regression with that data: x1 = range(0,9) y1 = (0.25, 0.33, 0.41, 0.53, 0.59, 0.70, 0.78, 0.86, 0.98) plt.scatter(x1, y1, c='r') lin_values = [0.242 + 0.0933*x for x in x1] log_values = [exp(0.242 + .9033*x) / (1 + exp(0.242 + .9033*x)) for x in range(-4, 5)] plt.plot(x1, lin_values, 'b-^') plt.plot(x1, log_values, 'g-*') plt.legend(['Linear', 'Logistic', 'Org Data']) plt.show() The example has undergone a few changes to make it easier to see precisely what is happening. It relies on the same data that was converted from questions answered correctly on the exam to a percentage. If you have 100 questions and you answer 25 of them correctly, you have answered 25 percent (0.25) of them correctly. The values are normalized to produce values between 0 and 1 percent. As you can see from the image above, the linear regression follows the data points closely. The logistic regression doesn’t. However, logistic regression often is the correct choice when the data points naturally follow the logistic curve, which happens far more often than you might think. You must use the technique that fits your data best, which means using linear regression in this case. A pass/fail example An essential point to remember is that logistic regression works best for probability and classification. Consider that points on an exam ultimately predict passing or failing the course. If you get a certain percentage of the answers correct, you pass, but you fail otherwise. The following code considers the same data used for the example above, but converts it to a pass/fail list. When a student gets at least 70 percent of the questions correct, success is assured. y2 = [0 if x < 0.70 else 1 for x in y1] plt.scatter(x1, y2, c='r') lin_values = [0.242 + 0.0933*x for x in x1] log_values = [exp(0.242 + .9033*x) / (1 + exp(0.242 + .9033*x)) for x in range(-4, 5)] plt.plot(x1, lin_values, 'b-^') plt.plot(x1, log_values, 'g-*') plt.legend(['Linear', 'Logistic', 'Org Data']) plt.show() This is an example of how you can use list comprehensions in Python to obtain a required dataset or data transformation. The list comprehension for y2 starts with the continuous data in y1 and turns it into discrete data. Note that the example uses precisely the same equations as before. All that has changed is the manner in which you view the data, as you can see below. Because of the change in the data, linear regression is no longer the option to choose. Instead, you use logistic regression to fit the data. Take into account that this example really hasn’t done any sort of analysis to optimize the results. The logistic regression fits the data even better if you do so.

View Article
page 1
page 2
page 3
page 4
page 5
page 6
page 7
page 8
page 9
page 10
page 11
page 12
page 13
page 14
page 15
page 16
page 17
page 18
page 19
page 20
page 21
page 22
page 23
page 24
page 25
page 26
page 27
page 28
page 29
page 30
page 31
page 32
page 33
page 34
page 35
page 36
page 37
page 38
page 39
page 40
page 41
page 42
page 43
page 44
page 45
page 46
page 47
page 48
page 49
page 50
page 51
page 52
page 53
page 54
page 55
page 56
page 57
page 58
page 59
page 60
page 61
page 62
page 63
page 64
page 65
page 66
page 67
page 68
page 69
page 70
page 71
page 72
page 73
page 74
page 75
page 76
page 77
page 78
page 79
page 80
page 81
page 82
page 83
page 84
page 85
page 86
page 87
page 88
page 89
page 90
page 91
page 92
page 93
page 94
page 95
page 96
page 97
page 98
page 99
page 100
page 101
page 102
page 103
page 104
page 105
page 106
page 107
page 108
page 109
page 110
page 111
page 112
page 113
page 114
page 115
page 116
page 117
page 118
page 119
page 120
page 121
page 122
page 123
page 124
page 125
page 126
page 127
page 128
page 129
page 130
page 131
page 132
page 133
page 134
page 135
page 136
page 137
page 138
page 139
page 140
page 141
page 142
page 143
page 144
page 145
page 146
page 147
page 148
page 149
page 150
page 151
page 152
page 153
page 154
page 155
page 156
page 157
page 158
page 159
page 160
page 161
page 162
page 163
page 164
page 165
page 166
page 167
page 168
page 169
page 170
page 171
page 172
page 173
page 174
page 175
page 176
page 177
page 178
page 179
page 180
page 181
page 182
page 183
page 184
page 185
page 186
page 187
page 188
page 189
page 190
page 191
page 192
page 193
page 194
page 195
page 196
page 197
page 198
page 199
page 200
page 201
page 202
page 203
page 204
page 205
page 206
page 207
page 208
page 209
page 210
page 211
page 212
page 213
page 214
page 215
page 216
page 217
page 218
page 219
page 220
page 221
page 222
page 223
page 224
page 225
page 226
page 227
page 228
page 229
page 230
page 231
page 232
page 233
page 234
page 235
page 236
page 237
page 238
page 239
page 240
page 241
page 242
page 243
page 244
page 245
page 246
page 247
page 248
page 249
page 250
page 251
page 252
page 253
page 254
page 255
page 256
page 257
page 258
page 259
page 260
page 261
page 262
page 263
page 264
page 265
page 266
page 267
page 268
page 269
page 270
page 271
page 272
page 273
page 274
page 275
page 276
page 277
page 278
page 279
page 280
page 281
page 282
page 283
page 284
page 285
page 286
page 287
page 288
page 289
page 290
page 291
page 292
page 293
page 294
page 295
page 296
page 297
page 298
page 299
page 300
page 301
page 302
page 303
page 304
page 305
page 306
page 307
page 308
page 309
page 310
page 311
page 312
page 313
page 314
page 315
page 316
page 317
page 318
page 319
page 320
page 321
page 322
page 323
page 324
page 325
page 326
page 327
page 328
page 329
page 330
page 331
page 332
page 333
page 334
page 335
page 336
page 337
page 338
page 339
page 340
page 341
page 342
page 343
page 344
page 345
page 346
page 347
page 348
page 349
page 350
page 351
page 352
page 353
page 354
page 355
page 356
page 357
page 358
page 359
page 360
page 361
page 362
page 363
page 364
page 365
page 366
page 367
page 368
page 369
page 370
page 371
page 372
page 373
page 374
page 375
page 376
page 377
page 378
page 379
page 380
page 381
page 382
page 383
page 384
page 385
page 386
page 387
page 388
page 389
page 390
page 391
page 392
page 393
page 394
page 395
page 396
page 397
page 398
page 399
page 400
page 401
page 402
page 403
page 404
page 405
page 406
page 407
page 408
page 409
page 410
page 411
page 412
page 413
page 414
page 415
page 416
page 417
page 418
page 419
page 420
page 421
page 422
page 423
page 424
page 425
page 426
page 427
page 428
page 429
page 430
page 431
page 432
page 433
page 434
page 435
page 436
page 437
page 438
page 439
page 440
page 441
page 442
page 443
page 444
page 445
page 446
page 447
page 448
page 449
page 450
page 451
page 452
page 453
page 454
page 455
page 456
page 457
page 458
page 459
page 460
page 461
page 462
page 463
page 464
page 465
page 466
page 467
page 468
page 469
page 470
page 471
page 472
page 473
page 474
page 475
page 476
page 477
page 478
page 479
page 480
page 481
page 482
page 483
page 484
page 485
page 486
page 487
page 488
page 489
page 490
page 491
page 492
page 493
page 494
page 495
page 496
page 497
page 498
page 499
page 500
page 501
page 502
page 503
page 504
page 505
page 506
page 507
page 508
page 509
page 510
page 511
page 512
page 513
page 514
page 515
page 516
page 517
page 518
page 519
page 520
page 521
page 522
page 523
page 524
page 525
page 526
page 527
page 528
page 529
page 530
page 531
page 532
page 533
page 534
page 535
page 536
page 537
page 538
page 539
page 540
page 541
page 542
page 543
page 544
page 545
page 546
page 547
page 548
page 549
page 550
page 551
page 552
page 553
page 554
page 555
page 556
page 557
page 558
page 559
page 560
page 561
page 562
page 563
page 564
page 565
page 566
page 567
page 568
page 569
page 570
page 571
page 572
page 573
page 574
page 575
page 576
page 577
page 578
page 579
page 580
page 581
page 582
page 583
page 584
page 585
page 586
page 587
page 588
page 589
page 590
page 591
page 592
page 593
page 594
page 595
page 596
page 597
page 598
page 599
page 600
page 601
page 602
page 603
page 604
page 605
page 606
page 607
page 608
page 609
page 610
page 611
page 612
page 613
page 614
page 615
page 616
page 617
page 618
page 619
page 620
page 621
page 622
page 623
page 624
page 625
page 626
page 627
page 628
page 629
page 630
page 631
page 632
page 633
page 634
page 635
page 636
page 637
page 638
page 639
page 640
page 641
page 642
page 643
page 644
page 645
page 646
page 647
page 648
page 649
page 650
page 651
page 652
page 653
page 654
page 655
page 656
page 657
page 658
page 659
page 660
page 661
page 662
page 663
page 664
page 665
page 666
page 667
page 668
page 669
page 670
page 671
page 672
page 673
page 674
page 675
page 676
page 677
page 678
page 679
page 680
page 681
page 682
page 683
page 684
page 685
page 686
page 687
page 688
page 689
page 690
page 691
page 692
page 693
page 694
page 695
page 696
page 697
page 698
page 699
page 700
page 701
page 702
page 703
page 704
page 705
page 706
page 707
page 708
page 709
page 710
page 711
page 712
page 713
page 714
page 715
page 716
page 717
page 718
page 719
page 720
page 721
page 722
page 723
page 724
page 725
page 726
page 727
page 728
page 729
page 730
page 731
page 732
page 733
page 734
page 735
page 736
page 737
page 738
page 739
page 740
page 741
page 742
page 743
page 744
page 745
page 746
page 747
page 748
page 749
page 750
page 751
page 752
page 753
page 754
page 755
page 756
page 757
page 758
page 759
page 760
page 761
page 762
page 763
page 764
page 765
page 766
page 767
page 768
page 769
page 770
page 771
page 772
page 773
page 774
page 775
page 776
page 777
page 778
page 779
page 780
page 781
page 782
page 783
page 784
page 785
page 786
page 787
page 788
page 789
page 790
page 791
page 792
page 793
page 794
page 795
page 796
page 797
page 798
page 799
page 800
page 801
page 802
page 803
page 804
page 805
page 806
page 807
page 808
page 809
page 810
page 811
page 812
page 813
page 814
page 815
page 816
page 817
page 818
page 819
page 820
page 821
page 822
page 823
page 824
page 825
page 826
page 827
page 828
page 829
page 830
page 831
page 832
page 833
page 834
page 835
page 836
page 837
page 838
page 839
page 840
page 841
page 842
page 843
page 844
page 845
page 846
page 847
page 848
page 849
page 850
page 851
page 852
page 853
page 854
page 855
page 856
page 857
page 858
page 859
page 860
page 861
page 862
page 863
page 864
page 865
page 866
page 867
page 868
page 869
page 870
page 871
page 872
page 873
page 874
page 875
page 876
page 877
page 878
page 879
page 880
page 881
page 882
page 883
page 884
page 885
page 886
page 887
page 888
page 889
page 890
page 891
page 892
page 893
page 894
page 895
page 896
page 897
page 898
page 899
page 900
page 901
page 902
page 903
page 904
page 905
page 906
page 907
page 908
page 909
page 910
page 911
page 912
page 913
page 914
page 915
page 916
page 917
page 918
page 919
page 920
page 921
page 922
page 923
page 924
page 925
page 926
page 927
page 928
page 929
page 930
page 931
page 932
page 933
page 934
page 935
page 936
page 937
page 938
page 939
page 940
page 941
page 942
page 943

Quick Links

  • About For Dummies
  • Contact Us
  • Activate a Book Pin

Connect

About Dummies

Dummies has always stood for taking on complex concepts and making them easy to understand. Dummies helps everyone be more knowledgeable and confident in applying what they know. Whether it's to pass that big test, qualify for that big promotion or even master that cooking technique; people who rely on dummies, rely on it to learn the critical skills and relevant information necessary for success.

Copyright @ 2000-2024 by John Wiley & Sons, Inc., or related companies. All rights reserved, including rights for text and data mining and training of artificial technologies or similar technologies.

Terms of Use
Privacy Policy
Cookies Settings
Do Not Sell My Personal Info - CA Only