{"id":130902,"date":"2022-12-30T20:08:49","date_gmt":"2022-12-30T20:08:49","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=1026776"},"modified":"2022-12-30T20:08:49","modified_gmt":"2022-12-30T20:08:49","slug":"spectacular-titles-an-easy-python-project-generating-catchy-titles","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/12\/30\/spectacular-titles-an-easy-python-project-generating-catchy-titles\/","title":{"rendered":"Spectacular Titles: An Easy Python Project Generating Catchy Titles"},"content":{"rendered":"\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-top\" data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1026776&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;1&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n<div class=\"kksr-stars\">\n<div class=\"kksr-stars-inactive\">\n<div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\"> 5\/5 &#8211; (1 vote) <\/div>\n<\/p><\/div>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f4ac.png\" alt=\"\ud83d\udcac\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Project Goal<\/strong>: Create a small Python script that automatically creates catchy titles similar to the one you just read, given a certain topic.<\/p>\n<h2>A Story on Creating Catchy Titles with Python<\/h2>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/12\/image-334-1024x684.png\" alt=\"\" class=\"wp-image-1026797\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/12\/image-334-1024x684.png 1024w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/12\/image-334-300x200.png 300w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/12\/image-334-768x513.png 768w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/12\/image-334.png 1086w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n<p>Once upon a time, there lived a small business owner who was looking for a new way to make their business stand out from the competition. They had heard about the power of using titles to grab attention and draw in customers, but they weren&#8217;t sure how to create titles that were both effective and memorable. <\/p>\n<p>That&#8217;s when the small business owner heard about Python. They decided that using a Python script to generate titles would be the perfect solution. With a Python script, they could easily create titles with all the elements they wanted while still keeping their content fresh and unique. <\/p>\n<p class=\"has-base-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f449.png\" alt=\"\ud83d\udc49\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Recommended<\/strong>: <a href=\"https:\/\/blog.finxter.com\/3-easy-habits-that-can-make-you-rich-as-a-freelance-coder\/\" data-type=\"post\" data-id=\"929469\" target=\"_blank\" rel=\"noreferrer noopener\">3 Habits That Can Make You Rich as a Python Freelancer<\/a><\/p>\n<p>The small business owner was excited to try out Python and soon discovered that it was much easier and faster to generate titles than they ever thought possible. They were also able to customize their titles with different words, phrases, and symbols to make them even more eye-catching. <\/p>\n<p>The small business owner was so pleased with their new titles that they started to see a huge increase in their customer base. From then on, they used Python to generate titles for all their marketing materials and campaigns, and the results were impressive. <\/p>\n<p>And that&#8217;s the story of why the small business owner decided to create titles using a Python script.<\/p>\n<p><em>(Well, most likely I won&#8217;t use it a lot &#8212; but it was fun anyways.)<\/em><\/p>\n<h2>Python Random Title Generator<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">To create a function that generates titles randomly, you can start by defining the function with four parameters \u2013 topics, words, adjectives, and verbs. Inside the function, randomly select one item from each of the four provided lists and combine them into a title. Return the generated title &#8212; and voil\u00e0, your title generator is ready!<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># import relevant libraries\nimport random # create a list of topics\ntopics = ['Sports', 'Messi', 'Football', 'Soccer', 'Basketball', 'Tennis', 'Golf', 'Hockey'] # create a list of words\nwords = ['Incredible', 'Unbelievable', 'Spectacular', 'Mind-Blowing', 'Staggering', 'Incredulous', 'Astonishing', 'Breathtaking'] # create a list of adjectives\nadjectives = ['Amazing', 'Astounding', 'Extraordinary', 'Stunning', 'Remarkable', 'Fascinating', 'Stupendous', 'Striking'] # create a list of verbs\nverbs = ['Journey', 'Adventure', 'Voyage', 'Expedition', 'Journey', 'Quest', 'Pilgrimage', 'Quest'] # define a function to generate the titles\ndef generate_title(topics, words, adjectives, verbs): # choose a random topic topic = random.choice(topics) # choose a random word word = random.choice(words) # choose a random adjective adjective = random.choice(adjectives) # choose a random verb verb = random.choice(verbs) # generate the title title = '{} {} {}: A {} of {}'.format(adjective, word, topic, verb, topic) # return the title return title<\/pre>\n<p>This code snippet is used to generate random titles with a specific topic. It imports the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-random-module\/\" data-type=\"post\" data-id=\"5030\" target=\"_blank\">random library<\/a> which is used to choose words from the <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" data-type=\"post\" data-id=\"7332\" target=\"_blank\">lis<\/a>ts of topics, words, adjectives, and verbs. <\/p>\n<p>The <code>generate_title()<\/code> function takes the lists as parameters and <a href=\"https:\/\/blog.finxter.com\/how-to-randomly-sample-from-a-python-list\/\" data-type=\"post\" data-id=\"719846\" target=\"_blank\" rel=\"noreferrer noopener\">chooses<\/a> a random entry from each list. It then creates a title with the chosen words and returns it. <\/p>\n<p>Here&#8217;s an example output run:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for i in range(20): # call the function to generate a title title = generate_title(topics, words, adjectives, verbs) # print the title print(title)<\/pre>\n<p>The <code>for<\/code> <a href=\"https:\/\/blog.finxter.com\/python-loops\/\" data-type=\"post\" data-id=\"4596\" target=\"_blank\" rel=\"noreferrer noopener\">loop<\/a> calls the function 20 times and <a href=\"https:\/\/blog.finxter.com\/python-print\/\" data-type=\"post\" data-id=\"20731\" target=\"_blank\" rel=\"noreferrer noopener\">prints<\/a> the generated titles.<\/p>\n<p>Output:<\/p>\n<pre class=\"wp-block-preformatted\"><code>Amazing Spectacular Hockey: A Adventure of Hockey<\/code>\n<code>\nRemarkable Breathtaking Basketball: A Expedition of Basketball<\/code>\n<code>\nStupendous Mind-Blowing Golf: A Expedition of Golf<\/code>\n<code>\nStunning Mind-Blowing Football: A Quest of Football<\/code>\n<code>\nExtraordinary Spectacular Hockey: A Adventure of Hockey<\/code>\n<code>\nAmazing Unbelievable Hockey: A Journey of Hockey<\/code>\n<code>\nAstounding Staggering Hockey: A Adventure of Hockey<\/code>\n<code>\nAstounding Mind-Blowing Basketball: A Journey of Basketball<\/code>\n<code>\nRemarkable Incredible Tennis: A Voyage of Tennis<\/code>\n<code>\nAstounding Incredible Hockey: A Journey of Hockey<\/code>\n<code>\nAstounding Spectacular Messi: A Journey of Messi<\/code>\n<code>\nStupendous Breathtaking Sports: A Journey of Sports<\/code>\n<code>\nFascinating Mind-Blowing Tennis: A Quest of Tennis<\/code>\n<code>\nAmazing Astonishing Football: A Journey of Football<\/code>\n<code>\nAmazing Mind-Blowing Sports: A Journey of Sports<\/code>\n<code>\nExtraordinary Breathtaking Tennis: A Quest of Tennis<\/code>\n<code>\nExtraordinary Astonishing Football: A Journey of Football<\/code>\n<code>\nAstounding Spectacular Messi: A Expedition of Messi<\/code>\n<code>\nStupendous Mind-Blowing Messi: A Quest of Messi<\/code>\n<code>\nStriking Spectacular Soccer: A Voyage of Soccer<\/code><\/pre>\n<p>I would certainly click. Wouldn&#8217;t you? <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/1f609.png\" alt=\"\ud83d\ude09\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>5\/5 &#8211; (1 vote) Project Goal: Create a small Python script that automatically creates catchy titles similar to the one you just read, given a certain topic. A Story on Creating Catchy Titles with Python Once upon a time, there lived a small business owner who was looking for a new way to make their [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-130902","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/130902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=130902"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/130902\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=130902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=130902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=130902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}