<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Python Archives - Be on the Right Side of Change</title>
	<atom:link href="https://blog.finxter.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.finxter.com/category/python/</link>
	<description></description>
	<lastBuildDate>Tue, 09 Dec 2025 10:43:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.finxter.com/wp-content/uploads/2020/08/cropped-cropped-finxter_nobackground-32x32.png</url>
	<title>Python Archives - Be on the Right Side of Change</title>
	<link>https://blog.finxter.com/category/python/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Be a Reply Guy on X: The 80/20 Math of Growing Your Social Media Brand</title>
		<link>https://blog.finxter.com/be-a-reply-guy-on-x-the-80-20-math-of-growing-your-social-media-brand/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Tue, 09 Dec 2025 10:41:16 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1671549</guid>

					<description><![CDATA[<p>My very limited time on X has already shown that posts ranked by number of expression is highly non-linear. Maybe Zipf or Pareto distributed? The first plot shows each post sorted by impressions (rank 1 = most impressions). You’ll see a steep drop from the top few posts, then a long tail of low-impression posts. ... <a title="Be a Reply Guy on X: The 80/20 Math of Growing Your Social Media Brand" class="read-more" href="https://blog.finxter.com/be-a-reply-guy-on-x-the-80-20-math-of-growing-your-social-media-brand/" aria-label="Read more about Be a Reply Guy on X: The 80/20 Math of Growing Your Social Media Brand">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/be-a-reply-guy-on-x-the-80-20-math-of-growing-your-social-media-brand/">Be a Reply Guy on X: The 80/20 Math of Growing Your Social Media Brand</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>My very<a href="https://x.com/FinxterDotCom"> limited time on X</a> has already shown that posts ranked by number of expression is highly non-linear. Maybe Zipf or Pareto distributed? </strong></p>



<p>The <strong>first plot</strong> shows each post sorted by impressions (rank 1 = most impressions). You’ll see a <strong>steep drop</strong> from the top few posts, then a <strong>long tail</strong> of low-impression posts.</p>



<p>The point is: </p>



<ul class="wp-block-list">
<li>post more stuff </li>



<li>most posts will fail or get ~zero impressions </li>



<li>some posts make all the difference</li>
</ul>



<h2 class="wp-block-heading">~20% of Posts/Replies Generate ~80% of the Impressions</h2>



<p>Post ranked by impressions is not quite Pareto distributed (would be a straight line):</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="511" src="https://blog.finxter.com/wp-content/uploads/2025/12/image-22-1024x511.png" alt="" class="wp-image-1671551" srcset="https://blog.finxter.com/wp-content/uploads/2025/12/image-22-1024x511.png 1024w, https://blog.finxter.com/wp-content/uploads/2025/12/image-22-300x150.png 300w, https://blog.finxter.com/wp-content/uploads/2025/12/image-22-768x383.png 768w, https://blog.finxter.com/wp-content/uploads/2025/12/image-22.png 1026w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>The <strong>log–log plot</strong> shows rank and impressions on logarithmic axes. If the points roughly line up on a straight downward-sloping line, that’s a classic power-law–like pattern.</p>



<p>The distribution looks heavy-tailed &#8211; a small number of posts carry a large share of total impressions. </p>



<h2 class="wp-block-heading">Don&#8217;t Post &#8211; Be a Reply Guy</h2>



<p>Also, replies have a much higher number of average impressions as compared to original posts. Smaller accounts should prioritize replies over posts.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="631" height="132" src="https://blog.finxter.com/wp-content/uploads/2025/12/image-23.png" alt="" class="wp-image-1671552" srcset="https://blog.finxter.com/wp-content/uploads/2025/12/image-23.png 631w, https://blog.finxter.com/wp-content/uploads/2025/12/image-23-300x63.png 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<p>If you want to grow your X account quickly, the best approach seems to be to reply to larger accounts. What to reply? Everything that comes to your mind. Just your authentic quick commentary. Don&#8217;t bother using AI &#8211; you&#8217;ll be too slow. Just use whatever comes to mind and increase your volume.</p>



<p>If you want to learn more on how using AI can improve your life, <a href="https://blog.finxter.com/ai/">check out my free newsletter</a> with 130k subscribers! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f44d.png" alt="👍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p>The post <a href="https://blog.finxter.com/be-a-reply-guy-on-x-the-80-20-math-of-growing-your-social-media-brand/">Be a Reply Guy on X: The 80/20 Math of Growing Your Social Media Brand</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>This Finviz Screener Finds Recession-Proof Stocks &#8212; Four Variables Suggested by AI</title>
		<link>https://blog.finxter.com/this-finviz-screener-finds-recession-proof-stocks-four-variables-suggested-by-ai/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Wed, 03 Dec 2025 15:00:45 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Finviz]]></category>
		<category><![CDATA[Investment]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1671515</guid>

					<description><![CDATA[<p>Disclaimer: This is not investment advice &#8211; just financial entertainment. TLDR: These are the four variables to screen to find recession proof stocks according to financial research (e.g., Morningstar) Here&#8217;s the video I recorded: What is a Recession? A recession is simply a broad, painful slowdown in the economy: falling output, jobs, incomes, production, and ... <a title="This Finviz Screener Finds Recession-Proof Stocks &#8212; Four Variables Suggested by AI" class="read-more" href="https://blog.finxter.com/this-finviz-screener-finds-recession-proof-stocks-four-variables-suggested-by-ai/" aria-label="Read more about This Finviz Screener Finds Recession-Proof Stocks &#8212; Four Variables Suggested by AI">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/this-finviz-screener-finds-recession-proof-stocks-four-variables-suggested-by-ai/">This Finviz Screener Finds Recession-Proof Stocks &#8212; Four Variables Suggested by AI</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-base-2-background-color has-background"><strong>Disclaimer</strong>: This is not investment advice &#8211; just financial entertainment.</p>



<p><strong>TLDR:</strong> These are the four variables to screen to find recession proof stocks according to financial research (e.g., Morningstar)</p>



<ul class="wp-block-list">
<li>1. Dividend Yield  1% or more </li>



<li>2. Low Debt/Equity (preferably less than 1) </li>



<li>3. Low Beta (e.g., Beta less than  1) </li>



<li>4. High Return on Equity (ROE greater than 10%)</li>
</ul>



<p>Here&#8217;s the video I recorded:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="This Finviz Screener Finds Recession-Proof Stocks" width="937" height="527" src="https://www.youtube.com/embed/e8TgvqvUmA4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<h2 class="wp-block-heading">What is a Recession?</h2>



<p>A recession is simply a broad, painful slowdown in the economy: falling output, jobs, incomes, production, and sales (that’s how the NBER defines it). </p>



<p>Since 1945 the U.S. has seen 13 recessions, roughly one every six years, usually lasting around 10 months. </p>



<p>Consumer spending makes up about two-thirds of the U.S. economy, so when people cut back, companies tied to “nice-to-have” stuff get hit much harder than those selling necessities. </p>



<p>Interestingly, stocks have still been <em>up</em> on average during recessions, so the question isn’t “stocks or no stocks?” but “<strong>which</strong> stocks?”.</p>



<h2 class="wp-block-heading">The Finviz Recession Filter Suggested by State-of-the-Art AI Agents</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="831" src="https://blog.finxter.com/wp-content/uploads/2025/12/image-13-1024x831.png" alt="" class="wp-image-1671519" srcset="https://blog.finxter.com/wp-content/uploads/2025/12/image-13-1024x831.png 1024w, https://blog.finxter.com/wp-content/uploads/2025/12/image-13-300x244.png 300w, https://blog.finxter.com/wp-content/uploads/2025/12/image-13-768x624.png 768w, https://blog.finxter.com/wp-content/uploads/2025/12/image-13.png 1319w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong>Filter 1 – Dividend yield ≥ 1%</strong><br>Dividends matter because over long periods a big chunk of stock returns comes from reinvested dividends, not just price moves. Hartford Funds found that since 1960, reinvested dividends made up the majority of the S&amp;P 500’s total return. But chasing super-high yields is dangerous: in 2020, a popular high-dividend index actually fell <em>more</em> than the market because some companies couldn’t keep paying. So in the screener we just ask for a <strong>modest dividend (≥ 1%)</strong> to find companies that share cash with investors without diving into “desperate high-yield” land.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="906" src="https://blog.finxter.com/wp-content/uploads/2025/12/image-12-1024x906.png" alt="" class="wp-image-1671518" srcset="https://blog.finxter.com/wp-content/uploads/2025/12/image-12-1024x906.png 1024w, https://blog.finxter.com/wp-content/uploads/2025/12/image-12-300x266.png 300w, https://blog.finxter.com/wp-content/uploads/2025/12/image-12-768x680.png 768w, https://blog.finxter.com/wp-content/uploads/2025/12/image-12.png 1331w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Filter 2 – Debt-to-equity &lt; 1</strong><br>In a recession, too much debt can turn a slowdown into a crisis for a company. MIT Sloan research on the Great Recession showed that firms that loaded up on debt before 2008 were forced to cut jobs and close locations far more than low-debt firms. High interest costs plus falling sales is a brutal combo. So we add a simple filter: <strong>debt-to-equity below 1</strong>, which nudges us toward companies with healthier balance sheets and more breathing room when things get ugly.</p>



<p><strong>Filter 3 – Beta &lt; 1</strong><br>“Beta” measures how much a stock typically moves compared to the overall market. AllianceBernstein studied global stocks back to the 1970s and found that the <strong>least volatile 20% of stocks actually returned about one-third more than the market with roughly 20% less volatility</strong>, and they held up better in <strong>7 of the last 8 major downturns</strong>. That’s the “lose less in crashes, compound more over time” effect. So we tell the screener: <strong>beta under 1</strong>, focusing on stocks that historically swing less than the index.</p>



<p><strong>Filter 4 – Return on equity (ROE) &gt; 10%</strong><br>Return on equity is a simple profitability metric: how much profit a company generates per dollar of shareholder equity. WisdomTree cites research showing that, over almost 60 years, the highest-ROE companies beat the lowest-ROE companies by about <strong>4 percentage points per year</strong> on average. High-ROE businesses tend to have strong competitive positions and more resilient earnings. So we add one last filter: <strong>ROE above 10%</strong> to favor consistently profitable companies that are more likely to sustain dividends and survive downturns.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Also check out my related article:</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/make-money-ai/">12 Ways to Make Money with AI</a></p>



<h2 class="wp-block-heading">References</h2>



<p>NBER recession basics: <a href="https://www.nber.org/research/business-cycle-dating">https://www.nber.org/research/business-cycle-dating</a><br>Hartford Funds – 10 Things You Should Know About Recessions: <a href="https://www.hartfordfunds.com/dam/en/docs/pub/whitepapers/CCWP079.pdf">https://www.hartfordfunds.com/dam/en/docs/pub/whitepapers/CCWP079.pdf</a><br>Hartford Funds dividends/total return (via InvestorPlace summary): <a href="https://investorplace.com/2024/01/3-reasons-to-rely-on-dividend-stocks/">https://investorplace.com/2024/01/3-reasons-to-rely-on-dividend-stocks/</a><br>MIT Sloan – Corporate debt and layoffs in the Great Recession: <a href="https://mitsloan.mit.edu/press/companies-took-more-debt-run-to-great-recession-later-cut-employment-more-sharply-says-new-research-mit-sloans-xavier-giroud">https://mitsloan.mit.edu/press/companies-took-more-debt-run-to-great-recession-later-cut-employment-more-sharply-says-new-research-mit-sloans-xavier-giroud</a><br>AllianceBernstein – The Paradox of Low-Risk Stocks: <a href="https://www.alliancebernstein.com/apac/en/institutions/insights/investment-insights/the-paradox-of-low-risk-stocks-gaining-more-by-losing-less.html">https://www.alliancebernstein.com/apac/en/institutions/insights/investment-insights/the-paradox-of-low-risk-stocks-gaining-more-by-losing-less.html</a><br>WisdomTree – Why Quality for the Long Run (ROE spread): <a href="https://www.wisdomtree.com/investments/blog/2021/08/24/why-quality-for-the-long-run">https://www.wisdomtree.com/investments/blog/2021/08/24/why-quality-for-the-long-run</a></p>
<p>The post <a href="https://blog.finxter.com/this-finviz-screener-finds-recession-proof-stocks-four-variables-suggested-by-ai/">This Finviz Screener Finds Recession-Proof Stocks &#8212; Four Variables Suggested by AI</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &#038; Marketplaces)</title>
		<link>https://blog.finxter.com/gpu-hosting-profit-calculator-earn-from-your-mini-data-center-vast-ai-marketplaces/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Wed, 29 Oct 2025 13:45:14 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1671360</guid>

					<description><![CDATA[<p>Estimate monthly revenue, costs, and profit for renting out GPUs on centralized marketplaces (e.g., Vast.ai, TensorDock) or for your own inference services. Adjust assumptions and see break-even utilization and profit curves instantly. GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &#038; Marketplaces) Inputs High‑End 24GB — On‑Demand 24GB — Power‑Capped Prosumer ... <a title="GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &#38; Marketplaces)" class="read-more" href="https://blog.finxter.com/gpu-hosting-profit-calculator-earn-from-your-mini-data-center-vast-ai-marketplaces/" aria-label="Read more about GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &#38; Marketplaces)">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/gpu-hosting-profit-calculator-earn-from-your-mini-data-center-vast-ai-marketplaces/">GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &amp; Marketplaces)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Estimate monthly revenue, costs, and profit for renting out GPUs on centralized marketplaces (e.g., Vast.ai, TensorDock) or for your own inference services. Adjust assumptions and see break-even utilization and profit curves instantly.</p>



<div id="gpu-economics-widget" class="gpucalc">
  <style>
    /* ===== Scoped styles: only affect elements inside #gpu-economics-widget ===== */
    #gpu-economics-widget {font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color: #0f172a; background: linear-gradient(180deg,#ffffff 0%, #f8fafc 100%); border: 1px solid #e2e8f0; border-radius: 16px; padding: 24px; box-shadow: 0 10px 30px rgba(2,6,23,.08); max-width: 980px; margin: 0 auto; }
    @media (prefers-color-scheme: dark){
      #gpu-economics-widget { color: #e5e7eb; background: linear-gradient(180deg,#0b1220 0%, #0f172a 100%); border-color:#1f2937; box-shadow: 0 10px 30px rgba(0,0,0,.35);} 
      #gpu-economics-widget .card{background:#0b1220;border-color:#1f2937}
      #gpu-economics-widget input, #gpu-economics-widget select{background:#0b1220;color:#e5e7eb;border-color:#334155}
      #gpu-economics-widget .muted{color:#9ca3af}
      #gpu-economics-widget .progress-bar{background:#0b1220}
    }

    .title {display:flex; align-items:center; gap:12px;}
    .title h1 {font-size: 1.4rem; line-height:1.2; margin: 0; font-weight: 800; letter-spacing: -0.01em;}
    .title .badge {font-size: .75rem; background: #eef2ff; color:#3730a3; border:1px solid #c7d2fe; padding:4px 8px; border-radius: 999px; font-weight:700}

    .muted{color:#475569}
    .row{display:grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-top: 16px}
    @media (max-width: 860px){.row{grid-template-columns: 1fr}}

    .card{border:1px solid #e2e8f0; background:#ffffff; border-radius: 14px; padding:16px}
    .card h3{margin:0 0 10px 0; font-size: 1rem}
    .grid-2{display:grid; grid-template-columns: 1fr 1fr; gap:12px}
    .grid-3{display:grid; grid-template-columns: 1fr 1fr 1fr; gap:12px}

    label{display:block; font-size:.85rem; margin-bottom:6px; color:#334155}
    input[type="number"], select{width:100%; padding:10px 12px; border:1px solid #cbd5e1; border-radius:10px; font-size:.95rem; outline: none; transition: box-shadow .2s, border-color .2s}
    input[type="number"]:focus, select:focus{border-color:#6366f1; box-shadow: 0 0 0 4px rgba(99,102,241,.12)}

    .presets{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px}
    .chip{padding:8px 10px; border:1px solid #cbd5e1; border-radius:999px; cursor:pointer; font-size:.85rem; user-select:none}
    .chip:hover{border-color:#6366f1}

    .kpi{display:grid; grid-template-columns: repeat(4,1fr); gap:12px}
    @media (max-width: 640px){.kpi{grid-template-columns: repeat(2,1fr)}}
    .kpi .item{border:1px dashed #cbd5e1; border-radius:12px; padding:12px 12px}
    .kpi .item .label{font-size:.8rem; color:#64748b}
    .kpi .item .value{font-size:1.15rem; font-weight:800; letter-spacing:-0.01em}

    .progress{height: 10px; border-radius: 999px; background: #e2e8f0; overflow:hidden}
    .progress .progress-bar{height:100%; width:0; transition: width .6s ease; background: linear-gradient(90deg, #22c55e, #16a34a)}
    .progress .danger{background: linear-gradient(90deg,#ef4444,#b91c1c)}

    .chart-card{position:relative; height: 260px; border:1px solid #e2e8f0; border-radius:14px; padding: 12px}
    canvas{width:100%; height: 220px}

    .accordion{margin-top: 18px}
    .accordion summary{cursor:pointer; list-style:none; padding:10px 12px; border:1px solid #cbd5e1; border-radius:10px; font-weight:700}
    .accordion summary::-webkit-details-marker{display:none}
    .accordion .content{padding:12px 2px; color:#475569}
    .pill{display:inline-block; padding:4px 8px; border-radius:999px; background:#ecfeff; color:#155e75; border:1px solid #a5f3fc; font-size:.75rem; margin-right:6px}

    .footer-note{font-size:.75rem; color:#64748b; margin-top: 8px}
  </style>

  <div class="title">
    <h1>GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &#038; Marketplaces)</h1>
    
  </div>

  <div class="row">
    <div class="card">
      <h3>Inputs</h3>
      <div class="presets">
        <span class="chip" data-preset='{"gpu":"High‑End 24GB (4090‑class)","price":0.35,"util":55,"power":285,"kwh":0.25,"other":0.02,"fee":0,"fx":0.93}'>High‑End 24GB — On‑Demand</span>
        <span class="chip" data-preset='{"gpu":"High‑End 24GB (Power‑Capped)","price":0.30,"util":60,"power":230,"kwh":0.25,"other":0.02,"fee":0,"fx":0.93}'>24GB — Power‑Capped</span>
        <span class="chip" data-preset='{"gpu":"Prosumer 24GB (3090‑class)","price":0.18,"util":60,"power":320,"kwh":0.25,"other":0.02,"fee":0,"fx":0.93}'>Prosumer 24GB</span>
        <span class="chip" data-preset='{"gpu":"Datacenter 80GB (A100‑class)","price":1.20,"util":45,"power":400,"kwh":0.25,"other":0.03,"fee":0,"fx":0.93}'>Datacenter 80GB</span>
      </div>
      <div class="grid-2">
        <div>
          <label>GPU name / SKU</label>
          <input id="gpuName" type="text" value="High‑End 24GB (4090‑class)">
        </div>
        <div>
          <label>Hourly price ($/h)</label>
          <input id="price" type="number" step="0.01" min="0" value="0.35">
        </div>
        <div>
          <label>Utilization (% of hours rented)</label>
          <input id="util" type="number" step="1" min="0" max="100" value="55">
        </div>
        <div>
          <label>Power under load (W, incl. system)</label>
          <input id="power" type="number" step="1" min="0" value="285">
        </div>
        <div>
          <label>Energy price (€/kWh)</label>
          <input id="kwh" type="number" step="0.001" min="0" value="0.25">
        </div>
        <div>
          <label>Other opex (€/h) — IPs, wear, etc.</label>
          <input id="other" type="number" step="0.01" min="0" value="0.02">
        </div>
        <div>
          <label>Platform fees (%)</label>
          <input id="fee" type="number" step="0.5" min="0" value="0">
        </div>
        <div>
          <label>FX rate USD→EUR</label>
          <input id="fx" type="number" step="0.01" min="0" value="0.93">
        </div>
      </div>
    </div>

    <div class="card">
      <h3>KPIs</h3>
      <div class="kpi">
        <div class="item">
          <div class="label">Monthly revenue</div>
          <div class="value" id="rev">€0</div>
        </div>
        <div class="item">
          <div class="label">Energy cost</div>
          <div class="value" id="energy">€0</div>
        </div>
        <div class="item">
          <div class="label">Other opex</div>
          <div class="value" id="otherCost">€0</div>
        </div>
        <div class="item">
          <div class="label">Net profit</div>
          <div class="value" id="profit">€0</div>
        </div>
      </div>
      <div style="margin-top:10px">
        <div style="display:flex; justify-content:space-between; align-items:center; font-size:.85rem; margin-bottom:6px">
          <span>Break‑even utilization</span>
          <strong id="ube">—</strong>
        </div>
        <div class="progress"><div id="ubeBar" class="progress-bar danger"></div></div>
        <div class="footer-note">Keep your actual utilization comfortably above the break‑even.</div>
      </div>
    </div>
  </div>

  <div class="row" style="margin-top:12px">
    <div class="card chart-card">
      <h3 style="margin-bottom:4px">Profit vs Utilization</h3>
      <canvas id="lineChart" height="220"></canvas>
    </div>
    <div class="card chart-card">
      <h3 style="margin-bottom:4px">Revenue vs Costs (at current inputs)</h3>
      <canvas id="barChart" height="220"></canvas>
    </div>
  </div>

  <details class="accordion">
    <summary>Business model, platforms, and who this is for</summary>
    <div class="content">
      <p><strong>How you earn:</strong> List your GPUs on centralized marketplaces (e.g., Vast.ai, TensorDock) and rent them by the hour. Your revenue equals <em>utilized hours × hourly price</em>. Main costs: electricity (kWh), minor opex (IPs, storage), and any platform fees. Higher margin comes from layering your <em>own</em> services (managed inference, fine-tunes, rendering) on top.</p>
      <p><strong>Suitable platforms:</strong> <span class="pill">Vast.ai</span> <span class="pill">TensorDock</span> <span class="pill">Paperspace Core (BYO)</span> <span class="pill">RunPod Pro</span> (compare terms/fees).</p>
      <p><strong>Who this is for:</strong> Indie operators, studios, small data‑center owners, and educators who want to monetize idle GPUs sustainably. Especially compelling if you can secure a competitive energy rate, maintain high uptime, and attract steady workloads (ML inference, training bursts, or rendering).</p>
    </div>
  </details>

  <script>
    (function(){
      const $ = (id)=>document.getElementById(id);
      const inputs = ['gpuName','price','util','power','kwh','other','fee','fx'].map($);
      const state = {hours: 24*30}; // ~720h

      const fmtE = (x)=>`€${x.toFixed(2)}`;

      function calc(){
        const price = parseFloat($('price').value||0); // USD/h
        const util = Math.min(100, Math.max(0, parseFloat($('util').value||0)))/100; // 0-1
        const powerW = parseFloat($('power').value||0);
        const kwh = parseFloat($('kwh').value||0);
        const other = parseFloat($('other').value||0); // €/h
        const feePct = Math.min(100, Math.max(0, parseFloat($('fee').value||0)))/100;
        const fx = parseFloat($('fx').value||0);

        const hoursUsed = state.hours * util;
        const rev = hoursUsed * price * fx * (1 - feePct);
        const energy = hoursUsed * (powerW/1000) * kwh;
        const otherCost = hoursUsed * other;
        const profit = rev - energy - otherCost;

        $('rev').textContent = fmtE(rev);
        $('energy').textContent = fmtE(energy);
        $('otherCost').textContent = fmtE(otherCost);
        $('profit').textContent = fmtE(profit);

        // Break-even utilization U* = (power*kwh + other)/ (price*fx*(1-fee)) per hour
        const denom = price * fx * (1 - feePct);
        const be = denom > 0 ? (( (powerW/1000) * kwh + other) / denom) : 0;
        const bePct = Math.max(0, Math.min(1, be));
        $('ube').textContent = (be*100).toFixed(1) + '%';
        const bar = $('ubeBar');
        bar.style.width = (Math.min(1, util / Math.max(0.001, be)) * 100).toFixed(1) + '%';
        bar.className = 'progress-bar ' + (util >= be ? '' : 'danger');

        drawLine(price, fx, feePct, powerW, kwh, other);
        drawBars(rev, energy, otherCost, profit);
      }

      // Simple canvas helpers (no external libs)
      const lineCanvas = $('lineChart');
      const barCanvas = $('barChart');

      function clearCanvas(ctx){
        ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
      }

      function devicePx(c){
        const r = window.devicePixelRatio || 1;
        const displayWidth = c.clientWidth;
        const displayHeight = c.clientHeight;
        if (c.width !== displayWidth * r || c.height !== displayHeight * r){
          c.width = displayWidth * r; c.height = displayHeight * r;
        }
        return r;
      }

      function drawLine(price, fx, fee, powerW, kwh, other){
        const ctx = lineCanvas.getContext('2d');
        const r = devicePx(lineCanvas);
        clearCanvas(ctx);
        const w = ctx.canvas.width, h = ctx.canvas.height;
        const pad = 40*r;

        // Build data points: profit vs utilization 0..100
        const points = [];
        let minY = Infinity, maxY = -Infinity;
        for (let u=0; u<=100; u+=5){
          const util = u/100;
          const hours = 720*util;
          const rev = hours * price * fx * (1-fee);
          const energy = hours * (powerW/1000) * kwh;
          const otherCost = hours * other;
          const prof = rev - energy - otherCost;
          points.push({u, prof});
          minY = Math.min(minY, prof); maxY = Math.max(maxY, prof);
        }
        if (minY === maxY){ maxY = minY + 1; }

        // Axes
        ctx.lineWidth = 1*r; ctx.globalAlpha = 0.8; ctx.strokeStyle = 'rgba(100,116,139,.6)';
        ctx.beginPath();
        ctx.moveTo(pad, h-pad); ctx.lineTo(w-pad, h-pad); // x
        ctx.moveTo(pad, h-pad); ctx.lineTo(pad, pad); // y
        ctx.stroke();

        // Y ticks
        ctx.fillStyle = 'rgba(100,116,139,.9)'; ctx.font = `${12*r}px ui-sans-serif`;
        for(let i=0;i<=4;i++){
          const yv = minY + (i*(maxY-minY)/4);
          const y = h - pad - ((yv-minY)/(maxY-minY))*(h-2*pad);
          ctx.beginPath(); ctx.moveTo(pad, y); ctx.lineTo(w-pad, y); ctx.strokeStyle='rgba(100,116,139,.2)'; ctx.stroke();
          ctx.fillText('€'+yv.toFixed(0), 6*r, y+4*r);
        }

        // Line
        ctx.beginPath();
        points.forEach((p,i)=>{
          const x = pad + (p.u/100)*(w-2*pad);
          const y = h - pad - ((p.prof-minY)/(maxY-minY))*(h-2*pad);
          if(i===0) ctx.moveTo(x,y); else ctx.lineTo(x,y);
        });
        ctx.strokeStyle = 'rgba(34,197,94,1)'; ctx.lineWidth = 2*r; ctx.globalAlpha = 1; ctx.stroke();

        // Fill under line (gradient)
        const grad = ctx.createLinearGradient(0,pad,0,h-pad);
        grad.addColorStop(0,'rgba(34,197,94,0.3)');
        grad.addColorStop(1,'rgba(34,197,94,0)');
        ctx.fillStyle = grad; ctx.beginPath();
        points.forEach((p,i)=>{
          const x = pad + (p.u/100)*(w-2*pad);
          const y = h - pad - ((p.prof-minY)/(maxY-minY))*(h-2*pad);
          if(i===0) ctx.moveTo(x,y); else ctx.lineTo(x,y);
        });
        ctx.lineTo(w-pad, h-pad); ctx.lineTo(pad, h-pad); ctx.closePath(); ctx.fill();

        // Labels
        ctx.fillStyle = 'rgba(71,85,105,1)';
        ctx.fillText('Utilization %', w/2 - 30*r, h - 8*r);
        ctx.save(); ctx.rotate(-Math.PI/2); ctx.fillText('Profit (€ / month)', -h/2 - 30*r, 16*r); ctx.restore();
      }

      function drawBars(rev, energy, otherCost, profit){
        const ctx = barCanvas.getContext('2d');
        const r = devicePx(barCanvas);
        clearCanvas(ctx);
        const w = ctx.canvas.width, h = ctx.canvas.height; const pad = 35*r;
        const items = [rev, energy, otherCost, profit];
        const labels = ['Revenue','Energy','Other','Profit'];
        const maxV = Math.max(10, ...items.map(v=>Math.abs(v)));
        const barW = (w - 2*pad) / items.length * 0.6;

        // axis
        ctx.lineWidth = 1*r; ctx.strokeStyle='rgba(100,116,139,.6)';
        ctx.beginPath(); ctx.moveTo(pad, h - pad); ctx.lineTo(w-pad, h - pad); ctx.stroke();

        // bars
        items.forEach((v, i)=>{
          const x = pad + (i+0.5)*((w-2*pad)/items.length) - barW/2;
          const bh = (Math.abs(v)/maxV) * (h - 2*pad);
          const y = h - pad - bh;
          ctx.fillStyle = i===0 ? 'rgba(59,130,246,0.9)' : (i===3 ? 'rgba(34,197,94,0.9)' : 'rgba(148,163,184,0.9)');
          ctx.fillRect(x, y, barW, bh);
          ctx.fillStyle = 'rgba(71,85,105,1)'; ctx.font = `${12*r}px ui-sans-serif`;
          ctx.fillText(labels[i], x, h - pad + 14*r);
          ctx.fillText('€'+v.toFixed(0), x, y - 6*r);
        });
      }

      function attachPresets(){
        document.querySelectorAll('#gpu-economics-widget .chip').forEach(chip=>{
          chip.addEventListener('click', ()=>{
            const p = JSON.parse(chip.dataset.preset);
            $('gpuName').value = p.gpu; $('price').value = p.price; $('util').value = p.util; $('power').value = p.power; $('kwh').value = p.kwh; $('other').value = p.other; $('fee').value = p.fee; $('fx').value = p.fx; calc();
          });
        });
      }

      inputs.forEach(el=>el.addEventListener('input', calc));
      attachPresets();
      window.addEventListener('resize', calc);
      calc();
    })();
  </script>
</div>

<p>The post <a href="https://blog.finxter.com/gpu-hosting-profit-calculator-earn-from-your-mini-data-center-vast-ai-marketplaces/">GPU Hosting Profit Calculator — Earn from Your Mini Data Center (Vast.ai &amp; Marketplaces)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know</title>
		<link>https://blog.finxter.com/python-cheat-sheet/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Thu, 26 Sep 2024 05:02:47 +0000</pubDate>
				<category><![CDATA[Cheat Sheets]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=305</guid>

					<description><![CDATA[<p>Python cheat sheets are the 80/20 principle applied to coding: 80% of the learning in 20% of the time.</p>
<p>The post <a href="https://blog.finxter.com/python-cheat-sheet/">Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-embed-aspect-4-3 wp-has-aspect-ratio"><strong>Why this?</strong> I remember when I first stumbled upon the Python wiki years ago, searching for a straightforward way to learn Python. Most of what I found felt either too complicated or just impractical &#8212; especially with a busy life, work, family, and other things to learn. You’re in the right place. This is the resource I wish I had back then.</p>



<p class="wp-embed-aspect-4-3 wp-has-aspect-ratio has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2b50.png" alt="⭐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>My Goal</strong>: I created these simple cheat sheets to help you reduced time and effort to go from zero Python skills to creating your first cool app.</p>



<p class="wp-embed-aspect-4-3 wp-has-aspect-ratio">More than 200,000 absolute Python beginners have already downloaded our <a href="https://blog.finxter.com/subscribe/" data-type="page" data-id="1414">free cheat sheets</a> &#8212; and grown to a coding level that empowered them to build cool apps!</p>



<p class="wp-embed-aspect-4-3 wp-has-aspect-ratio"><strong>Can we get the basics done in 10 minutes?</strong> You be the judge! Let&#8217;s go! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading">Python Keywords Cheat Sheet</h2>



<p>This cheat sheet is for beginners in the Python programming language. It explains everything you need to know about <strong>Python keywords</strong>. </p>



<p>Download and pin it to your wall until you feel confident using all these keywords! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="791" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-15.jpeg" alt="" class="wp-image-1671050" style="width:593px;height:768px" title="Python Cheat Sheet Keywords" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-15.jpeg 791w, https://blog.finxter.com/wp-content/uploads/2024/09/image-15-232x300.jpeg 232w, https://blog.finxter.com/wp-content/uploads/2024/09/image-15-768x994.jpeg 768w" sizes="auto, (max-width: 791px) 100vw, 791px" /></figure>
</div>


<div class="wp-block-buttons is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-499968f5 wp-block-buttons-is-layout-flex">
<div class="wp-block-button has-custom-font-size is-style-fill has-medium-font-size"><a class="wp-block-button__link has-accent-background-color has-text-color has-background wp-element-button" href="https://blog.finxter.com/subscribe/" style="border-radius:5px;color:#ffffff" target="_blank" rel="noreferrer noopener">Grab All 5 Python Cheat Sheets (Free)</a></div>
</div>



<p class="has-text-align-center"><a href="https://blog.finxter.com/wp-content/uploads/2019/02/CheatSheet-Python-1_-Keywords1.pdf" data-type="URL" data-id="https://blog.finxter.com/wp-content/uploads/2019/02/CheatSheet-Python-1_-Keywords1.pdf" target="_blank" rel="noreferrer noopener">Download only this one PDF</a></p>



<p>Over time, this page has turned into a full-fledged Python tutorial with many additional resources, puzzles, tips, and videos. Go ahead and have some fun, learn a thing or two &#8212; and become a better coder in the process!</p>



<p></p>



<h2 class="wp-block-heading">Interactive Python Puzzle</h2>



<p>Test your skills and cement your knowledge! I&#8217;ve created an interactive puzzle that will make sure you truly understand all Python keywords discussed in the cheat sheet. Can you solve it for fun and learning?</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f525.png" alt="🔥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Interactive Puzzle Link</strong>: <a href="https://app.finxter.com/learn/computer/science/653">https://app.finxter.com/learn/computer/science/653</a></p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter size-large is-resized"><a href="https://app.finxter.com/learn/computer/science/653" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="840" height="1024" src="https://blog.finxter.com/wp-content/uploads/2022/02/image-244-840x1024.png" alt="" class="wp-image-1670995" style="width:641px;height:auto" srcset="https://blog.finxter.com/wp-content/uploads/2022/02/image-244-840x1024.png 840w, https://blog.finxter.com/wp-content/uploads/2022/02/image-244-246x300.png 246w, https://blog.finxter.com/wp-content/uploads/2022/02/image-244-768x937.png 768w, https://blog.finxter.com/wp-content/uploads/2022/02/image-244.png 915w" sizes="auto, (max-width: 840px) 100vw, 840px" /></a></figure>
</div>


<p><em><strong>Exercise</strong>: Think about this puzzle and <a href="https://app.finxter.com/learn/computer/science/653" data-type="link" data-id="https://app.finxter.com/learn/computer/science/653">guess the output</a>. Then, check whether you were right!</em></p>



<p>Did you struggle with the puzzle? No problem &#8212; Let&#8217;s dive into all of these keywords to gain a better understanding of each.</p>



<h2 class="wp-block-heading">Python Keywords</h2>



<p>Learn 80% of the keywords in 20% of the time: these are the most important Python keywords.</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Python Keywords [A Helpful 16-Minute Primer]" width="937" height="527" src="https://www.youtube.com/embed/KjM5CkjPy78?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Here’s a rewrite of each section of your blog with easy-to-understand and fun explanations:</p>



<h3 class="wp-block-heading">Keywords False, True</h3>



<p>These are the stars of the Boolean world. <code>True</code> means &#8220;Yes, this is correct!&#8221; and <code>False</code> means &#8220;Nope, that&#8217;s not right.&#8221;</p>



<p>Examples:</p>



<ul class="wp-block-list">
<li><code>False == (1 &gt; 2)</code> → 1 is not greater than 2, so this is False.</li>



<li><code>True == (2 &gt; 1)</code> → 2 is definitely greater than 1, so this is True!</li>
</ul>



<h3 class="wp-block-heading">Keywords and, or, not</h3>



<p>These are the logic superheroes that help you make decisions in code!</p>



<ul class="wp-block-list">
<li><strong>and</strong>: Both sides must be True for the whole thing to be True. Like saying, &#8220;I&#8217;ll go to the beach if it&#8217;s sunny <em>and</em> I have ice cream!&#8221;</li>



<li><strong>or</strong>: Only one needs to be True. It&#8217;s like saying, &#8220;I&#8217;ll eat cake <em>or</em> cookies, I don&#8217;t care!&#8221;</li>



<li><strong>not</strong>: This flips the truth! If something is True, &#8220;not&#8221; makes it False, and vice versa.</li>
</ul>



<p>Examples:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">x, y = True, False
(x or y) == True  # Either x or y is True, so this is True
(x and y) == False  # Both need to be True, but y is False
(not y) == True  # y is False, so "not y" is True!</pre>



<h3 class="wp-block-heading">Keyword break</h3>



<p>This one just says &#8220;I&#8217;m done here!&#8221; It stops a loop in its tracks.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">while(True):
    break  # Breaks out of the loop immediately
print("hello world")  # This will print because the loop ends right away</pre>



<h3 class="wp-block-heading">Keyword continue</h3>



<p>&#8220;continue&#8221; is like saying, &#8220;Skip this part, let&#8217;s keep going!&#8221; It jumps to the next round of the loop.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">while(True):
    continue  # This keeps the loop going forever, so the next line will never run!
    print("43")  # Dead code! It’ll never get here.</pre>



<h3 class="wp-block-heading">Keyword class</h3>



<p>Think of a class as a blueprint for creating objects, like how a recipe is the blueprint for a cake. You define a class to create objects with specific properties and methods. </p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Download our <a href="https://blog.finxter.com/object-oriented-programming-terminology-cheat-sheet/" data-type="post" data-id="2129" target="_blank" rel="noreferrer noopener">object-oriented programming Cheat Sheet here</a></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">class Beer:
    def __init__(self):
        self.content = 1.0  # Full beer!
    def drink(self):
        self.content = 0.0  # Now it's empty!
becks = Beer()  # You’ve made a beer!
becks.drink()  # You drank it! It's empty now.</pre>



<h3 class="wp-block-heading">Keyword def</h3>



<p>&#8220;def&#8221; is short for &#8220;define.&#8221; It lets you create your own function, a little program inside your program!</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def say_hello():
    print("Hello!")
say_hello()  # This will print "Hello!"</pre>



<p>In other words, it defines a new function or class method. For the latter, the first parameter (“<a title="Python Self — An Interactive Guide with Video" href="https://blog.finxter.com/self-in-python/" target="_blank" rel="noreferrer noopener"><code>self</code></a>”) points to the class object. When calling the class method, the first parameter is implicit.</p>



<h3 class="wp-block-heading">Keywords if, elif, else</h3>



<p>These are your program’s decision-makers. They choose which path to take based on conditions.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">x = int(input("your value: "))
if x > 3:
    print("Big")  # If x is bigger than 3, say it's "Big"
elif x == 3:
    print("Medium")  # If x equals 3, say it's "Medium"
else:
    print("Small")  # Otherwise, say it's "Small"</pre>



<h3 class="wp-block-heading">Keywords for, while</h3>



<p>These are loops that repeat stuff for you!</p>



<ul class="wp-block-list">
<li><strong>for</strong>: Loops a set number of times.</li>



<li><strong>while</strong>: Keeps looping as long as a condition is True.</li>
</ul>



<p>Examples:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">for i in [0,1,2]:
    print(i)  # Prints 0, 1, 2</pre>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">j = 0
while j &lt; 3:
    print(j)  # Prints 0, 1, 2
    j += 1</pre>



<h3 class="wp-block-heading">Keyword in</h3>



<p>This checks if something exists in a list or other sequence (<a href="https://blog.finxter.com/python-membership-in-operator/" data-type="post" data-id="34005" target="_blank" rel="noreferrer noopener">membership</a>). It’s like asking, <em>&#8220;Is this ingredient in the recipe?&#8221;</em></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">42 in [2, 39, 42]  # True! 42 is in the list.</pre>



<h3 class="wp-block-heading">Keyword is</h3>



<p>This checks if two things are literally the same object in memory (<a href="https://blog.finxter.com/python-is-operator/" data-type="post" data-id="33954" target="_blank" rel="noreferrer noopener">object identity or <em>equality</em></a>). Like asking, <em>&#8220;Are we talking about the exact same cake?&#8221;</em></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">x = y = 3
x is y  # True, they are the same object.
[3] is [3]  # False, they’re different lists, even if they look the same.</pre>



<h3 class="wp-block-heading">Keyword None</h3>



<p>&#8220;None&#8221; is just Python’s way of saying, &#8220;There’s nothing here.&#8221;</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def f():
    x = 2
f() is None  # True, because the function doesn’t return anything.</pre>



<h3 class="wp-block-heading">Keyword lambda</h3>



<p>This is a quick, <a href="https://blog.finxter.com/a-simple-introduction-of-the-lambda-function-in-python/" data-type="post" data-id="2701" target="_blank" rel="noreferrer noopener">anonymous function</a> with no name—just a quick helper!</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">(lambda x: x + 3)(3)  # Adds 3 to the number and returns 6</pre>



<h3 class="wp-block-heading">Keyword return</h3>



<p>&#8220;return&#8221; sends a value back from a function and ends the function. It’s like handing someone the answer to a math problem.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">def incrementor(x):
    return x + 1  # Adds 1 and returns the result
incrementor(4)  # Returns 5</pre>



<p>Voilà, this was a quick rundown of the most important Python keywords. Let&#8217;s keep going! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>



<p><strong>Put yourself on the road to mastery and download your free Python cheat sheets now, print them, and post them to your office wall!</strong></p>






<p></p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f525.png" alt="🔥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Go to the Next Level</strong>: If you really want to advance your career, even if you&#8217;re an absolute beginner, check out the <a href="https://academy.finxter.com/" target="_blank" rel="noreferrer noopener">Finxter Academy</a>! You&#8217;ll learn the most important skill of our decade: <em><strong>using AI to create value</strong></em>. Each of our courses comes with a course certificate to get your dream job!</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<p>In the following, I&#8217;ll present you a compilation of the best Python cheat sheets on the web. So, keep reading!</p>



<h2 class="wp-block-heading">12 Best Python Cheat Sheets</h2>



<p>But these are not all&#8212;the following Python cheat sheets will greatly improve your learning efficiency! Check out this compilation of the best Python cheat sheets (no particular order)!</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="5 Python Cheat Sheets Every Python Coder Must Own" width="937" height="703" src="https://www.youtube.com/embed/aqLDzpFc7T0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>So let’s dive into the best Python cheat sheets recommended by us.</p>



<h3 class="wp-block-heading">Cheat Sheet #1 &#8211; Python 3 Cheat Sheet</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://perso.limsi.fr/pointal/_media/python:cours:mementopython3-english.pdf" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="588" height="832" src="https://blog.finxter.com/wp-content/uploads/2019/03/grafik.png" alt="" class="wp-image-2329" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/grafik.png 588w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-212x300.png 212w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-100x141.png 100w" sizes="auto, (max-width: 588px) 100vw, 588px" /></a></figure>
</div>


<p>This is the best single cheat sheet. It uses every inch of the page to deliver value and covers everything you need to know to go from beginner to intermediate. Topics covered include container types, conversions, modules, <a href="https://blog.finxter.com/python-math-module/" title="Python Math Module [Ultimate Guide]" target="_blank" rel="noreferrer noopener">math</a>, conditionals, and formatting to name a few. A highly recommended 2-page sheet! </p>



<h3 class="wp-block-heading">Cheat Sheet #2 &#8211; Python Beginner Cheat Sheet</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://github.com/ehmatthes/pcc/releases/download/v1.0.0/beginners_python_cheat_sheet_pcc_all.pdf" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="811" height="625" src="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-1.png" alt="" class="wp-image-2330" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-1.png 811w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-1-300x231.png 300w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-1-768x592.png 768w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-1-100x77.png 100w" sizes="auto, (max-width: 811px) 100vw, 811px" /></a></figure>
</div>


<p>Some might think this cheat sheet is a bit lengthy. At 26 pages, it is the most comprehensive cheat sheets out there. It explains variables, data structures, exceptions, and classes &#8211; to name just a few. If you want the most thorough cheat sheet, pick this one.  </p>



<h3 class="wp-block-heading">Cheat Sheet #3 &#8211; Python for Data Science</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/assets.datacamp.com/blog_assets/PythonForDataScience.pdf" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1180" height="823" src="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2.png" alt="" class="wp-image-2331" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2.png 1180w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2-300x209.png 300w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2-768x536.png 768w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2-1024x714.png 1024w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2-100x70.png 100w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-2-864x603.png 864w" sizes="auto, (max-width: 1180px) 100vw, 1180px" /></a></figure>
</div>


<p>Some of the most popular things to do with Python are <a href="https://blog.finxter.com/artificial-intelligence-machine-learning-deep-learning-and-data-science-whats-the-difference/">Data Science and Machine Learning</a>. </p>



<p>In this cheat sheet, you will learn the basics of Python and the most important scientific library:<a href="https://blog.finxter.com/numpy-tutorial/"> NumPy</a> (Numerical Python). You’ll learn the basics plus the most important NumPy functions. </p>



<p>If you are using Python for Data Science, download this cheat sheet. </p>



<h3 class="wp-block-heading">Cheat Sheet #4 &#8211; Python for Data Science (Importing Data)</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/assets.datacamp.com/blog_assets/Cheat+Sheets/Importing_Data_Python_Cheat_Sheet.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="1210" height="856" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-2.png" alt="" class="wp-image-9346" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-2.png 1210w, https://blog.finxter.com/wp-content/uploads/2020/06/image-2-300x212.png 300w, https://blog.finxter.com/wp-content/uploads/2020/06/image-2-1024x724.png 1024w, https://blog.finxter.com/wp-content/uploads/2020/06/image-2-768x543.png 768w" sizes="auto, (max-width: 1210px) 100vw, 1210px" /></a></figure>
</div>


<p>This Python data science cheat sheet from DataCamp is all about getting data into your code. </p>



<p>Think about it: importing data is one of the most important tasks when working with data. Increasing your skills in this area will make you a better data scientist&#8212;and a better coder overall!</p>



<h3 class="wp-block-heading">Cheat Sheet #5 &#8211; Python Cheatography Cheat Sheet</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://www.cheatography.com/davechild/cheat-sheets/python/pdf/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="568" height="816" src="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-3.png" alt="" class="wp-image-2332" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/grafik-3.png 568w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-3-209x300.png 209w, https://blog.finxter.com/wp-content/uploads/2019/03/grafik-3-100x144.png 100w" sizes="auto, (max-width: 568px) 100vw, 568px" /></a></figure>
</div>


<p>This cheat sheet is for more advanced learners. It covers class, string, and <a title="Python List Methods" rel="noreferrer noopener" href="https://blog.finxter.com/python-list-methods/" target="_blank">list methods</a> as well as system calls from the <code>sys</code> module.&nbsp; </p>



<p>Once you’re comfortable defining basic classes and command-line interfaces (CLIs), get this cheat sheet. It will take you to another level. </p>



<h3 class="wp-block-heading">Cheat Sheet #6 &#8211; <a aria-label=" (opens in a new tab)" href="https://blog.finxter.com/subscribe/" target="_blank" rel="noreferrer noopener">The Ultimative Python Cheat Sheet Course (5x Email Series)</a></h3>



<figure class="wp-block-gallery has-nested-images columns-5 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><a href="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1.jpg"><img loading="lazy" decoding="async" width="791" height="1024" data-id="2333" src="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-791x1024.jpg" alt="" class="wp-image-2333" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1.jpg 791w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-232x300.jpg 232w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-768x994.jpg 768w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-100x129.jpg 100w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-864x1118.jpg 864w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-1-Keywords-1-1200x1553.jpg 1200w" sizes="auto, (max-width: 791px) 100vw, 791px" /></a></figure>



<figure class="wp-block-image size-large"><a href="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1.jpg"><img loading="lazy" decoding="async" width="791" height="1024" data-id="2334" src="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-791x1024.jpg" alt="" class="wp-image-2334" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1.jpg 791w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-232x300.jpg 232w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-768x994.jpg 768w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-100x129.jpg 100w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-864x1118.jpg 864w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-2-Data-Structures.docx-1-1200x1553.jpg 1200w" sizes="auto, (max-width: 791px) 100vw, 791px" /></a></figure>



<figure class="wp-block-image size-large"><a href="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1.jpg"><img loading="lazy" decoding="async" width="791" height="1024" data-id="2335" src="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-791x1024.jpg" alt="" class="wp-image-2335" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1.jpg 791w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-232x300.jpg 232w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-768x994.jpg 768w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-100x129.jpg 100w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-864x1118.jpg 864w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-3-Complex-Data-Types-1-1200x1553.jpg 1200w" sizes="auto, (max-width: 791px) 100vw, 791px" /></a></figure>



<figure class="wp-block-image size-large"><a href="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes.png"><img loading="lazy" decoding="async" width="791" height="1024" data-id="2336" src="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-791x1024.png" alt="" class="wp-image-2336" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-791x1024.png 791w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-232x300.png 232w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-768x994.png 768w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-100x129.png 100w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-864x1118.png 864w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes-1200x1553.png 1200w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-4-Classes.png 1700w" sizes="auto, (max-width: 791px) 100vw, 791px" /></a></figure>



<figure class="wp-block-image size-large"><a href="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks.jpg"><img loading="lazy" decoding="async" width="791" height="1024" data-id="2337" src="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-791x1024.jpg" alt="" class="wp-image-2337" srcset="https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks.jpg 791w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-232x300.jpg 232w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-768x994.jpg 768w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-100x129.jpg 100w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-864x1118.jpg 864w, https://blog.finxter.com/wp-content/uploads/2019/03/CheatSheet-Python-5-Functions-and-Tricks-1200x1553.jpg 1200w" sizes="auto, (max-width: 791px) 100vw, 791px" /></a></figure>
</figure>



<p>Want to learn Python well, but don’t have much time? </p>



<p>Then this course is for you. It contains 5 carefully designed PDF cheat sheets. Each cheat sheet takes you one step further into the rabbit hole. </p>



<p>You will learn practical Python concepts from the hand-picked examples and code snippets. The topics include basic keywords, simple and complex data types, crucial string and list methods, and powerful Python one-liners. </p>



<p>If you lead a busy life and do not want to compromise on quality, this is the cheat sheet course for you! </p>



<h3 class="wp-block-heading">Cheat Sheet #7 &#8211; Dataquest Data Science Cheat Sheet &#8211; Python Basics</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/dq-blog-files/python-cheat-sheet-basic.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="612" height="793" src="https://blog.finxter.com/wp-content/uploads/2019/11/grafik-1.png" alt="" class="wp-image-5341" srcset="https://blog.finxter.com/wp-content/uploads/2019/11/grafik-1.png 612w, https://blog.finxter.com/wp-content/uploads/2019/11/grafik-1-232x300.png 232w" sizes="auto, (max-width: 612px) 100vw, 612px" /></a></figure>
</div>


<p>The wonderful team at Dataquest has put together this comprehensive beginner-level Python cheat sheet. </p>



<p>It covers all the basic data types, <a title="Python Loops" rel="noreferrer noopener" href="https://blog.finxter.com/python-loops/" target="_blank">looping, </a>and <a rel="noreferrer noopener" title="How to Read a File Line-By-Line and Store Into a List?" href="https://blog.finxter.com/how-to-read-a-file-line-by-line-and-store-into-a-list/" target="_blank">reading files</a>. It’s beautifully designed and is the first of a series. </p>



<h3 class="wp-block-heading">Cheat Sheet #8 &#8211; Dataquest Data Science Cheat Sheet &#8211; Intermediate</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/dq-blog-files/python-cheat-sheet-intermediate.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="611" height="791" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-1.png" alt="" class="wp-image-9344" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-1.png 611w, https://blog.finxter.com/wp-content/uploads/2020/06/image-1-232x300.png 232w" sizes="auto, (max-width: 611px) 100vw, 611px" /></a></figure>
</div>


<p>This intermediate-level cheat sheet is a follow-up of the other Dataquest cheat sheet. It contains intermediate <code>dtype</code> methods, looping, and handling errors. </p>



<h3 class="wp-block-heading">Cheat Sheet #9 &#8211; Dataquest NumPy</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/dq-blog-files/numpy-cheat-sheet.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="611" height="791" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-3.png" alt="" class="wp-image-9349" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-3.png 611w, https://blog.finxter.com/wp-content/uploads/2020/06/image-3-232x300.png 232w" sizes="auto, (max-width: 611px) 100vw, 611px" /></a></figure>
</div>


<p><a rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>is at the heart of data science. Advanced libraries like <a rel="noreferrer noopener" title="[Collection] 10 Scikit-Learn Cheat Sheets Every Machine Learning Engineer Must Have" href="https://blog.finxter.com/scikit-learn-cheat-sheets/" target="_blank">scikit-learn</a>, <a rel="noreferrer noopener" title="TensorFlow — A Helpful Illustrated Guide" href="https://blog.finxter.com/tensorflow-overview/" target="_blank">Tensorflow</a>, <a rel="noreferrer noopener" title="10 Minutes to Pandas (in 5 Minutes)" href="https://blog.finxter.com/pandas-quickstart/" target="_blank">Pandas</a>, and <a rel="noreferrer noopener" title="Best Matplotlib Cheat Sheet" href="https://blog.finxter.com/best-matplotlib-cheat-sheet/" target="_blank">Matplotlib </a>are built on NumPy arrays. </p>



<p>You need to understand NumPy before you can thrive in data science and machine learning. The topics of this cheat sheet are creating arrays, combining arrays, scalar math, vector math, and statistics. </p>



<p>This is only one great NumPy cheat sheet&#8212;if you want to get more, <a rel="noreferrer noopener" href="https://blog.finxter.com/collection-10-best-numpy-cheat-sheets-every-python-coder-must-own/" target="_blank">check out our article on the 10 best NumPy cheat sheets</a>!</p>



<h3 class="wp-block-heading">Cheat Sheet #10 &#8211; Python For Data Science (Bokeh)</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://s3.amazonaws.com/assets.datacamp.com/blog_assets/Python_Bokeh_Cheat_Sheet.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="1210" height="856" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-4.png" alt="" class="wp-image-9352" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-4.png 1210w, https://blog.finxter.com/wp-content/uploads/2020/06/image-4-300x212.png 300w, https://blog.finxter.com/wp-content/uploads/2020/06/image-4-1024x724.png 1024w, https://blog.finxter.com/wp-content/uploads/2020/06/image-4-768x543.png 768w" sizes="auto, (max-width: 1210px) 100vw, 1210px" /></a></figure>
</div>


<p>Want to master the visualization library <a rel="noreferrer noopener" href="https://docs.bokeh.org/en/latest/index.html" target="_blank">Bokeh</a>? This cheat sheet is for you! It contains all the basic Bokeh commands to get your beautiful visualizations going fast!</p>



<h3 class="wp-block-heading">Cheat Sheet #11 &#8211; Pandas Cheat Sheet for Data Science</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://drive.google.com/file/d/1UHK8wtWbADvHKXFC937IS6MTnlSZC_zB/view" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="666" height="862" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-5.png" alt="" class="wp-image-9356" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-5.png 666w, https://blog.finxter.com/wp-content/uploads/2020/06/image-5-232x300.png 232w" sizes="auto, (max-width: 666px) 100vw, 666px" /></a></figure>
</div>


<p><a rel="noreferrer noopener" href="https://pandas.pydata.org/" target="_blank">Pandas </a>is everywhere. If you want to master <em>&#8220;the Excel library for Python coders&#8221;</em>, why not start with this cheat sheet? It&#8217;ll get you started fast and introduces the most important Pandas functions to you.</p>



<p><a rel="noreferrer noopener" href="https://blog.finxter.com/pandas-cheat-sheets/" target="_blank">You can find a best-of article about the </a><a href="https://blog.finxter.com/pandas-cheat-sheets/" target="_blank" rel="noreferrer noopener">7</a><a rel="noreferrer noopener" href="https://blog.finxter.com/pandas-cheat-sheets/" target="_blank"> best Pandas Cheat Sheets here.</a></p>



<h3 class="wp-block-heading">Cheat Sheet #12 &#8211; Regular Expressions Cheat Sheet</h3>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://www.dataquest.io/wp-content/uploads/2019/03/python-regular-expressions-cheat-sheet.pdf" target="_blank" rel="noopener noreferrer"><img loading="lazy" decoding="async" width="611" height="791" src="https://blog.finxter.com/wp-content/uploads/2020/06/image-6.png" alt="" class="wp-image-9359" srcset="https://blog.finxter.com/wp-content/uploads/2020/06/image-6.png 611w, https://blog.finxter.com/wp-content/uploads/2020/06/image-6-232x300.png 232w" sizes="auto, (max-width: 611px) 100vw, 611px" /></a></figure>
</div>


<p>Regex to the rescue! <a rel="noreferrer noopener" href="https://blog.finxter.com/python-regex/" target="_blank">Regular expressions</a> are wildly important for anyone who handles large amounts of text programmatically (ask Google). </p>



<p>This cheat sheet introduces the most important Regex commands for quick reference. Download &amp; master these regular expressions!</p>



<p><em>If you love cheat sheets, here are some interesting references for you (lots of more PDF downloads):</em></p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<p><strong>Related Articles:</strong></p>



<ul class="wp-block-list"><li><a href="https://blog.finxter.com/collection-5-cheat-sheets-every-python-coder-must-own/" target="_blank" rel="noreferrer noopener" title="[Collection] 11 Python Cheat Sheets Every Python Coder Must Own">[Collection] 11 Python Cheat Sheets Every Python Coder Must Own</a></li><li><a href="https://blog.finxter.com/object-oriented-programming-terminology-cheat-sheet/" target="_blank" rel="noreferrer noopener" title="https://blog.finxter.com/object-oriented-programming-terminology-cheat-sheet/">[Python OOP Cheat Sheet] A Simple Overview of Object-Oriented Programming</a></li><li><a href="https://blog.finxter.com/machine-learning-cheat-sheets/" title="[Collection] 15 Mind-Blowing Machine Learning Cheat Sheets to Pin to Your Toilet Wall" target="_blank" rel="noreferrer noopener">[Collection] 15 Mind-Blowing Machine Learning Cheat Sheets to Pin to Your Toilet Wall</a></li><li><a href="https://blog.finxter.com/python-cheat-sheets/" title="https://blog.finxter.com/python-cheat-sheets/" target="_blank" rel="noreferrer noopener">Your 8+ Free Python Cheat Sheet [Course]</a></li><li><a href="https://blog.finxter.com/python-cheat-sheet/" target="_blank" rel="noreferrer noopener" title="Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know">Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know</a></li><li><a href="https://blog.finxter.com/python-cheat-sheet-functions-and-tricks/" title="Python Functions and Tricks Cheat Sheet" target="_blank" rel="noreferrer noopener">Python Functions and Tricks Cheat Sheet</a></li><li><a href="https://blog.finxter.com/python-interview-questions/" target="_blank" rel="noreferrer noopener" title="https://blog.finxter.com/python-interview-questions/">Python Cheat Sheet: 14 Interview Questions</a></li><li><a href="https://blog.finxter.com/pandas-cheat-sheets/" title="[PDF Collection] 7 Beautiful Pandas Cheat Sheets — Post Them to Your Wall" target="_blank" rel="noreferrer noopener">Beautiful Pandas Cheat Sheets</a></li><li><a href="https://blog.finxter.com/collection-10-best-numpy-cheat-sheets-every-python-coder-must-own/" title="[Collection] 10 Best NumPy Cheat Sheets Every Python Coder Must Own" target="_blank" rel="noreferrer noopener">10 Best NumPy Cheat Sheets</a></li><li><a href="https://blog.finxter.com/python-list-methods-cheat-sheet-instant-pdf-download/" title="Python List Methods Cheat Sheet [Instant PDF Download]" target="_blank" rel="noreferrer noopener">Python List Methods Cheat Sheet [Instant PDF Download]</a></li><li><a href="https://blog.finxter.com/cheat-sheet-6-pillar-machine-learning-algorithms/" target="_blank" rel="noreferrer noopener" title="[Cheat Sheet] 6 Pillar Machine Learning Algorithms">[Cheat Sheet] 6 Pillar Machine Learning Algorithms</a></li></ul>
</div></div>



<p>To master the most important skill in the next decade, AI engineering, check out the following course. It&#8217;s free and easy to learn but a dangerous skill to have in the age of AI! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><a href="https://academy.finxter.com/university/an-introduction-to-ai-engineering/"><img loading="lazy" decoding="async" width="1024" height="786" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-12-1024x786.png" alt="" class="wp-image-1671030" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-12-1024x786.png 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-12-300x230.png 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-12-768x589.png 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-12.png 1190w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>
</div>


<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Free Course:</strong> <a href="https://academy.finxter.com/university/an-introduction-to-ai-engineering/" data-type="link" data-id="https://academy.finxter.com/university/an-introduction-to-ai-engineering/">A Beginner&#8217;s Guide to AI Engineering (Full Course)</a></p>



<p></p>
<p>The post <a href="https://blog.finxter.com/python-cheat-sheet/">Python Beginner Cheat Sheet: 19 Keywords Every Coder Must Know</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python vs Golang &#8211; What&#8217;s Best for AI Engineering?</title>
		<link>https://blog.finxter.com/python-vs-golang-whats-best-for-ai-engineering/</link>
		
		<dc:creator><![CDATA[Koala]]></dc:creator>
		<pubDate>Tue, 10 Sep 2024 09:50:55 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670947</guid>

					<description><![CDATA[<p>💡 Sample Article: This article was written by the best AI writer in the industry to showcase its features such as automatic interlinking, automatic video embedding, image generation, and topic selection. Want to build your own AI website? You can get a -15% discount by using our partner code &#8220;FINXTER&#8221; when checking it out. Language ... <a title="Python vs Golang &#8211; What&#8217;s Best for AI Engineering?" class="read-more" href="https://blog.finxter.com/python-vs-golang-whats-best-for-ai-engineering/" aria-label="Read more about Python vs Golang &#8211; What&#8217;s Best for AI Engineering?">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-vs-golang-whats-best-for-ai-engineering/">Python vs Golang &#8211; What&#8217;s Best for AI Engineering?</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Sample Article:</strong> This article was written by the <a href="https://blog.finxter.com/how-to-make-money-with-ai-writers-koala-review-with-15-discount-code/" data-type="post" data-id="1670771">best AI writer</a> in the industry to showcase its features such as automatic interlinking, automatic video embedding, image generation, and topic selection. </p>



<p><strong>Want to build your own AI website?</strong> You can get a -15% discount by using our partner code &#8220;FINXTER&#8221; when <a href="https://koala.sh/?via=finxter" data-type="link" data-id="https://koala.sh/?via=finxter">checking it out</a>.</p>



<h2 class="wp-block-heading">Language Origins and Evolution</h2>



<figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Why I Switched from Python to Go Lang for AI Deployment" width="937" height="527" src="https://www.youtube.com/embed/WEVO_KJtZys?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>Python and Golang have different roots but share a focus on simplicity and readability. Both languages emerged to solve specific programming challenges of their time.</p>



<h3 class="wp-block-heading">Python: Creation and Growth</h3>



<p>Python was born in 1991, thanks to <a href="https://medium.com/mqos-technologies/golang-vs-python-which-language-is-best-for-ai-app-development-6de8d468debf">Guido van Rossum</a>. He wanted to create a language that was easy to read and write. Python&#8217;s design philosophy emphasizes code readability with its use of whitespace.</p>



<p>You&#8217;ll find Python&#8217;s syntax is clear and expressive. It&#8217;s often said that Python reads like English. This makes it a great choice for beginners and experts alike.</p>



<p>Over the years, Python has grown into a versatile language. It&#8217;s used in web development, data science, and AI. Its large community has created many libraries and frameworks.</p>



<h3 class="wp-block-heading">Golang: A Modern Contender</h3>



<p>Golang, or Go, is a newer kid on the block. <a href="https://www.monterail.com/blog/go-vs-python">Google developed it in 2009</a> to address issues they faced with other languages. The creators wanted a language that was fast, reliable, and easy to use.</p>



<p>You&#8217;ll notice Go&#8217;s syntax is inspired by C, but it&#8217;s simpler. It&#8217;s designed for efficiency and ease of use in large-scale projects.</p>



<p>Go shines in concurrent programming. It has built-in support for goroutines and channels. These features make it great for writing efficient, scalable programs.</p>



<p>Since its release, Go has gained popularity in system programming and web development. It&#8217;s also making waves in AI development due to its speed and simplicity.</p>



<h2 class="wp-block-heading">Core Language Features and Syntax</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-6-1024x702.jpeg" alt="" class="wp-image-1670959" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-6-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-6-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-6-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-6.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Golang have <a href="https://blog.finxter.com/python-vs-go-which-language-you-should-choose/">distinct approaches</a> to syntax and language design. Each offers unique features that can impact AI engineering tasks.</p>



<h3 class="wp-block-heading">Python&#8217;s Elegant Syntax</h3>



<p>Python is known for its <a href="https://medium.com/mqos-technologies/golang-vs-python-which-language-is-best-for-ai-app-development-6de8d468debf">readable and expressive code</a>. You&#8217;ll find its syntax easy to learn and use. It uses indentation to define code blocks, making your AI projects visually clean.</p>



<p>Python supports <a href="https://blog.finxter.com/understanding-python-as-a-scripting-language/">dynamic typing</a>. This means you don&#8217;t need to declare variable types. It can speed up your development process for AI prototypes.</p>



<p>The language offers a wide range of <a href="https://blog.finxter.com/python-lists/">built-in data structures</a>. Lists, dictionaries, and sets are powerful tools for handling complex AI data.</p>



<p>Python&#8217;s <a href="https://blog.finxter.com/python-list/">list comprehensions</a> let you create new lists based on existing ones in a single line. This feature is handy for data processing in AI tasks.</p>



<h3 class="wp-block-heading">Golang&#8217;s Simplicity and Clarity</h3>



<p>Golang takes a different approach with its <a href="https://www.interviewkickstart.com/blogs/learn/golang-vs-python-comparison">straightforward syntax</a>. You&#8217;ll notice it uses curly braces to define code blocks, similar to C or Java.</p>



<p>Go is statically typed, which can help catch errors early in your AI projects. It also has a fast compile time, letting you quickly test and iterate your code.</p>



<p>The language emphasizes simplicity. It has fewer keywords and constructs compared to many other languages. This can make your AI codebase more manageable.</p>



<p>Go&#8217;s built-in concurrency support through goroutines and channels is a standout feature. It allows you to efficiently handle parallel processing in AI applications.</p>



<h2 class="wp-block-heading">Performance and Speed Advantages</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-5-1024x702.jpeg" alt="" class="wp-image-1670958" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-5-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-5-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-5-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-5.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Go have different strengths when it comes to speed and performance. Let&#8217;s look at how each language stacks up for AI engineering tasks.</p>



<h3 class="wp-block-heading">Python&#8217;s Execution Time</h3>



<p>Python is known for its ease of use, but it can be slower than compiled languages. As an <a href="https://exaloop.io/blog/go-vs-python-performance/">interpreted language</a>, Python code is read and executed line by line. This can lead to longer run times for complex AI algorithms.</p>



<p>You might notice Python&#8217;s <a href="https://blog.finxter.com/understanding-why-python-is-slower-than-other-languages/">speed limitations</a> when working with large datasets or running intensive machine learning models. The Global Interpreter Lock (GIL) in CPython can also limit true parallel processing.</p>



<p>But Python has ways to <a href="https://blog.finxter.com/unveiling-the-fastest-implementations-of-python/">boost speed</a>. You can use libraries like NumPy and Pandas that are <a href="https://blog.finxter.com/5-outstanding-advantages-of-using-the-python-pandas-library/">optimized for numerical operations</a>. There are also Just-In-Time (JIT) compilers like Numba that can speed up Python code.</p>



<h3 class="wp-block-heading">Golang&#8217;s Efficiency</h3>



<p>Go shines when it comes to <a href="https://exaloop.io/blog/go-vs-python-performance/">speed and performance</a>. As a compiled language, Go turns your code directly into machine code. This means faster execution times, especially for CPU-intensive tasks.</p>



<p>You&#8217;ll find Go particularly useful for AI apps that need to handle lots of data quickly. Its built-in concurrency features let you easily write programs that use multiple CPU cores.</p>



<p>Go&#8217;s efficiency extends to memory usage too. It has a garbage collector that manages memory automatically, but with less overhead than Python. This can be a big plus when you&#8217;re working with large AI models or datasets.</p>



<p>For tasks like high-performance networking or parallel processing, Go&#8217;s speed advantage over Python becomes clear.</p>



<h2 class="wp-block-heading">Concurrent Programming Capabilities</h2>



<p>Python and Go handle concurrency differently. This affects how each language performs when running multiple tasks at once.</p>



<h3 class="wp-block-heading">Python&#8217;s Threading and GIL</h3>



<p>Python uses threads for concurrent programming. But there&#8217;s a catch &#8211; the Global Interpreter Lock (GIL). This lock makes sure only one thread runs Python code at a time.</p>



<p>The GIL helps keep Python&#8217;s memory safe. But it can slow things down when you&#8217;re trying to do lots of tasks at once. It&#8217;s like having many workers, but only one can work at a time.</p>



<p>For CPU-heavy tasks, the GIL can be a real problem. It stops Python from using multiple cores fully. But for I/O tasks like web scraping, it&#8217;s not as big a deal.</p>



<p>There are ways around the GIL. You can use <a href="https://blog.finxter.com/5-best-ways-to-implement-multiprocessing-in-python/">multiprocessing</a> instead of threading. Or you can use async programming with libraries like asyncio.</p>



<h3 class="wp-block-heading">Golang&#8217;s Concurrency Model</h3>



<p>Go takes a different approach with goroutines and channels. Goroutines are like super lightweight threads. You can start thousands of them without slowing your system down.</p>



<p>Here&#8217;s how easy it is to start a goroutine:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">go myFunction()
</pre>



<p>Channels let goroutines talk to each other safely. They help you avoid common bugs in concurrent code.</p>



<p>Go&#8217;s concurrency model makes it great for <a href="https://kitrum.com/blog/best-programming-language-for-ai-which-is-better-python-or-golang/">parallel processing</a>. You can easily use all your computer&#8217;s cores. This is super helpful for AI tasks that need lots of number crunching.</p>



<p>Go also handles I/O tasks well. You can have many goroutines waiting for network responses without blocking your whole program.</p>



<h2 class="wp-block-heading">Applications in AI and Machine Learning</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-4-1024x702.jpeg" alt="" class="wp-image-1670956" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-4-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-4-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-4-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-4.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Go offer unique strengths for AI and machine learning tasks. Each language has found its niche in different aspects of AI development and deployment.</p>



<h3 class="wp-block-heading">Python&#8217;s Data Science Dominance</h3>



<p>You&#8217;ll find Python at the heart of most data science and AI projects. Its rich ecosystem of libraries makes it a go-to choice. With <a href="https://multiqos.com/blogs/go-vs-python-for-machine-learning/">NumPy and Pandas</a>, you can easily manipulate and <a href="https://blog.finxter.com/how-to-use-python-to-analyze-data/">analyze large datasets</a>.</p>



<p>For machine learning, Python shines bright. You&#8217;ve got <a href="https://blog.finxter.com/5-best-open-source-python-libraries-for-machine-learning/">powerful tools</a> like:</p>



<ul class="wp-block-list">
<li>TensorFlow</li>



<li>PyTorch</li>



<li>scikit-learn</li>



<li>Keras</li>
</ul>



<p>These libraries let you <a href="https://blog.finxter.com/5-best-ways-to-train-your-model-using-tensorflow-and-python/">build and train</a> complex models with ease. Want to create a neural network? Python&#8217;s got you covered. Need to run a random forest algorithm? It&#8217;s just a few lines of code away.</p>



<p>Python&#8217;s simplicity also makes it great for prototyping AI algorithms. You can quickly test ideas and iterate on your models.</p>



<h3 class="wp-block-heading">Golang&#8217;s Role in AI Engineering</h3>



<p>While Python dominates in data science, Go is making waves in AI engineering. You&#8217;ll appreciate Go&#8217;s speed and efficiency when deploying AI models at scale.</p>



<p>Go&#8217;s strong performance makes it ideal for:</p>



<ul class="wp-block-list">
<li>Building high-performance web apps with AI features</li>



<li>Handling large workloads and traffic for AI services</li>



<li>Creating efficient microservices for AI systems</li>
</ul>



<p>Go&#8217;s <a href="https://multiqos.com/blogs/go-vs-python-for-machine-learning/">compiled nature and optimized garbage collector</a> give it an edge in runtime efficiency. This means your AI apps can handle more requests with less hardware.</p>



<p>You might use Go to build the backend infrastructure that supports your AI models. It&#8217;s great for tasks like data preprocessing and API development for machine learning services.</p>



<h2 class="wp-block-heading">Library Ecosystem and Frameworks</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-3-1024x702.jpeg" alt="" class="wp-image-1670955" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-3-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-3-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-3-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-3.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Go offer different libraries and tools for AI engineering. Each language has its strengths when it comes to resources for developers.</p>



<h3 class="wp-block-heading">Expansive Python Libraries</h3>



<p>Python shines with its <a href="https://medium.com/mqos-technologies/golang-vs-python-which-language-is-best-for-ai-app-development-6de8d468debf">vast ecosystem of libraries</a> for AI and machine learning. You&#8217;ll find popular frameworks like TensorFlow and PyTorch that make complex AI tasks easier.</p>



<p>These libraries let you quickly prototype and develop AI models. With scikit-learn, you can easily <a href="https://blog.finxter.com/add-machine-learning-to-your-python-project-in-30-lines-of-code/">implement machine learning</a> algorithms. NumPy and Pandas help with data manipulation and analysis.</p>



<p>For web development, you have options like Flask and Django. These frameworks integrate well with AI libraries, allowing you to build full-stack AI applications.</p>



<h3 class="wp-block-heading">Growing Golang Resources</h3>



<p>While not as extensive as Python&#8217;s, Go&#8217;s AI ecosystem is expanding. You&#8217;ll find libraries like GoLearn for machine learning and Gorgonia for neural networks.</p>



<p>Go&#8217;s <a href="https://multiqos.com/blogs/go-vs-python-for-machine-learning/">standard library</a> is robust, providing strong support for web development and data processing. This can be helpful when building AI-powered applications.</p>



<p>Third-party packages are emerging to fill gaps in AI capabilities. Libraries like gonum offer numerical computing tools similar to NumPy in Python.</p>



<p>Go&#8217;s performance makes it attractive for AI tasks requiring speed. You might find it useful for deploying models in production environments.</p>



<h2 class="wp-block-heading">Use Cases and Industry Adoption</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-2-1024x702.jpeg" alt="" class="wp-image-1670954" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-2-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-2-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-2-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-2.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Golang have found their places in different industries. Each language shines in specific areas, with Python dominating some sectors while Golang makes inroads in others.</p>



<h3 class="wp-block-heading">Python in Various Industries</h3>



<p>Python is a go-to language in many fields. You&#8217;ll find it used widely in:</p>



<p>Data Science: Python&#8217;s libraries like NumPy and Pandas make it perfect for <a href="https://blog.finxter.com/python-comments/">data analysis</a>.</p>



<p>AI and Machine Learning: TensorFlow and PyTorch are popular Python frameworks for AI projects.</p>



<p>Web Development: Django and Flask help create robust web apps quickly.</p>



<p>Finance: Python&#8217;s data processing abilities make it ideal for financial modeling.</p>



<p>Education: Its simple syntax makes Python great for teaching coding basics.</p>



<p><a href="https://iglu.net/python-vs-go/">Healthcare applications</a> often use Python for data analysis and research. In manufacturing, Python helps with process automation and quality control.</p>



<h3 class="wp-block-heading">Golang&#8217;s Industry Presence</h3>



<p>Golang is gaining ground in several key areas:</p>



<p>Cloud Services: Google, the creator of Go, uses it extensively in their cloud offerings.</p>



<p>DevOps: Go&#8217;s speed makes it great for building DevOps tools and infrastructure.</p>



<p>Networking: Go&#8217;s concurrency model is perfect for handling multiple network connections.</p>



<p>Microservices: You can build efficient, scalable microservices with Go.</p>



<p><a href="https://www.33rdsquare.com/go-vs-python/">System Programming</a>: Go&#8217;s low-level capabilities make it suitable for system-level programming.</p>



<p>In e-commerce, Go powers backend systems for fast transaction processing. Real estate firms use Go for property management systems and data processing tools.</p>



<h2 class="wp-block-heading">Scalability and Cloud Integration</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-1-1024x702.jpeg" alt="" class="wp-image-1670953" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-1-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-1-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-1-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image-1.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Go both offer great options for building scalable <a href="https://blog.finxter.com/google-making-billions-of-ai-the-investment-case-for-alphabet/">AI systems</a> in the cloud. They each have strengths that suit different cloud architectures and deployment models.</p>



<h3 class="wp-block-heading">Python and Scalable Systems</h3>



<p>Python shines for data-heavy AI workloads that need to scale up. Its rich ecosystem of libraries like NumPy and Pandas make it easy to process large datasets. You can use Python with big data tools like Apache Spark to crunch massive amounts of data across clusters.</p>



<p>For web-based AI apps, Python frameworks like Django and Flask let you quickly build scalable backends. These integrate well with <a href="https://blog.finxter.com/category/cloud-computing/">cloud platforms</a> for easy deployment and scaling.</p>



<p>Python works great with container tech too. You can package your Python AI apps in Docker containers and deploy them to Kubernetes clusters. This gives you a flexible, scalable infrastructure for your AI systems.</p>



<h3 class="wp-block-heading">Golang for Cloud-Native Applications</h3>



<p>Go excels at building cloud-native microservices. Its fast compile times and small binaries make it ideal for containerized apps. You can package Go services in tiny Docker images for quick deployment.</p>



<p>Go&#8217;s built-in concurrency makes it great for high-throughput AI systems. You can easily spin up thousands of goroutines to handle parallel processing tasks. This <a href="https://multiqos.com/blogs/go-vs-python-for-machine-learning/">efficient runtime lets Go handle huge workloads</a>.</p>



<p>Go integrates smoothly with cloud platforms and tools. Major cloud providers offer Go SDKs for their services. You&#8217;ll find it easy to work with cloud storage, messaging, and other key components.</p>



<p>Google&#8217;s new <a href="https://developers.googleblog.com/en/introducing-genkit-for-go-build-scalable-ai-powered-apps-in-go/">Genkit framework</a> makes Go even more powerful for AI. It helps you build scalable AI apps that leverage Go&#8217;s performance advantages.</p>



<h2 class="wp-block-heading">Frequently Asked Questions</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.finxter.com/wp-content/uploads/2024/09/image-1024x702.jpeg" alt="" class="wp-image-1670952" srcset="https://blog.finxter.com/wp-content/uploads/2024/09/image-1024x702.jpeg 1024w, https://blog.finxter.com/wp-content/uploads/2024/09/image-300x206.jpeg 300w, https://blog.finxter.com/wp-content/uploads/2024/09/image-768x527.jpeg 768w, https://blog.finxter.com/wp-content/uploads/2024/09/image.jpeg 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Python and Go both have strengths for AI engineering. Let&#8217;s explore some common questions about using these languages for <a href="https://blog.finxter.com/artificial-intelligence-machine-learning-deep-learning-and-data-science-whats-the-difference/">machine learning</a> and deep learning projects.</p>



<h3 class="wp-block-heading">Which language do AI engineers prefer, Python or Go?</h3>



<p>Most AI engineers still prefer Python. It has a huge ecosystem of libraries like TensorFlow and PyTorch. You&#8217;ll find tons of tutorials and resources for <a href="https://blog.finxter.com/start-learning-python/">Python AI development</a>.</p>



<h3 class="wp-block-heading">Is Go gaining popularity in the machine learning field?</h3>



<p>Go is <a href="https://codeburst.io/which-language-is-perfect-for-ai-why-golang-and-not-python-ebf51651cc74">growing in popularity for AI</a>. More developers are using it for machine learning projects. Its speed and concurrency make it appealing for certain AI tasks.</p>



<h3 class="wp-block-heading">What are the advantages of Python over Go for AI development?</h3>



<p>Python has way more AI libraries and frameworks. It&#8217;s easier to prototype quickly. The syntax is simpler, so you can focus on algorithms instead of language quirks.</p>



<h3 class="wp-block-heading">Can you use Golang for deep learning projects?</h3>



<p>Yes, you can use Go for deep learning. There are some libraries available. But <a href="https://blog.finxter.com/python-greater-than/">Python still dominates</a> this area. You might need to write more code yourself in Go.</p>



<h3 class="wp-block-heading">How does the performance of Go compare to Python in AI applications?</h3>



<p>Go is generally faster than Python. It&#8217;s great for <a href="https://medium.com/mqos-technologies/golang-vs-python-which-language-is-best-for-ai-app-development-6de8d468debf">high-performance AI apps</a>. Go&#8217;s speed shines in tasks like data processing or serving models.</p>



<h3 class="wp-block-heading">What&#8217;s the learning curve like for Go if I&#8217;m already experienced in Python for AI?</h3>



<p>You&#8217;ll find Go&#8217;s syntax different from Python. It&#8217;s statically typed and compiled. The concepts are similar, but you&#8217;ll need to learn new ways to structure your code. Expect a moderate learning curve.</p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Do you want to create your own AI-based blog and monetize with ads? <a href="https://koala.sh/?via=finxter">Check out the best AI writer</a> in the industry and get -15% off forever with our discount code &#8220;FINXTER&#8221;.</p>



<p></p>
<p>The post <a href="https://blog.finxter.com/python-vs-golang-whats-best-for-ai-engineering/">Python vs Golang &#8211; What&#8217;s Best for AI Engineering?</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ChatGPT-4o Understands My Dissertation Better Than I Do 🤯</title>
		<link>https://blog.finxter.com/chatgpt-4o-understands-my-dissertation-better-than-i-do-%f0%9f%a4%af/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Wed, 22 May 2024 08:52:43 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670520</guid>

					<description><![CDATA[<p>In this post, you&#8217;ll learn about the insane skills of ChatGPT-4o, in particular its MASSIVE MIND-BOGGLING CONTEXT WINDOW that can, with a little help of retrieval augmented generation (RAG), process and understand my dissertation in computer science better than 99.99% of humans. 🤯🤯🤯 Watch my video to see how beautiful ChatGPT-4o solved all my ten ... <a title="ChatGPT-4o Understands My Dissertation Better Than I Do 🤯" class="read-more" href="https://blog.finxter.com/chatgpt-4o-understands-my-dissertation-better-than-i-do-%f0%9f%a4%af/" aria-label="Read more about ChatGPT-4o Understands My Dissertation Better Than I Do 🤯">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/chatgpt-4o-understands-my-dissertation-better-than-i-do-%f0%9f%a4%af/">ChatGPT-4o Understands My Dissertation Better Than I Do 🤯</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this post, you&#8217;ll learn about the insane skills of ChatGPT-4o, in particular its MASSIVE MIND-BOGGLING CONTEXT WINDOW that can, with a little help of <a href="https://blog.finxter.com/google-making-billions-of-ai-the-investment-case-for-alphabet/" data-type="post" data-id="1670147">retrieval augmented generation (RAG)</a>, process and understand my dissertation in computer science better than 99.99% of humans. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f92f.png" alt="🤯" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f92f.png" alt="🤯" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f92f.png" alt="🤯" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>Watch my video to see how beautiful ChatGPT-4o solved all my ten test questions on my own <a href="https://blog.finxter.com/computer-science-phd-a-simple-formula-for-massive-success-%f0%9f%8c%9f/" data-type="post" data-id="3919">dissertation</a>:</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="ChatGPT-4o Understands My Dissertation Better Than I Do &#x1f92f;" width="937" height="527" src="https://www.youtube.com/embed/JWcZlSkPXC0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<h2 class="wp-block-heading">Test 1: Give Me All GitHub Repositories Mentioned in the Thesis</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="795" height="811" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-93.png" alt="" class="wp-image-1670535" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-93.png 795w, https://blog.finxter.com/wp-content/uploads/2024/05/image-93-294x300.png 294w, https://blog.finxter.com/wp-content/uploads/2024/05/image-93-768x783.png 768w" sizes="auto, (max-width: 795px) 100vw, 795px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="648" height="529" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-85.png" alt="" class="wp-image-1670523" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-85.png 648w, https://blog.finxter.com/wp-content/uploads/2024/05/image-85-300x245.png 300w" sizes="auto, (max-width: 648px) 100vw, 648px" /></figure>
</div>


<h2 class="wp-block-heading">Test 2: Write a 1-sentence Research Statement Based on the Thesis</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="823" height="223" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-94.png" alt="" class="wp-image-1670536" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-94.png 823w, https://blog.finxter.com/wp-content/uploads/2024/05/image-94-300x81.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-94-768x208.png 768w" sizes="auto, (max-width: 823px) 100vw, 823px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="696" height="600" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-84.png" alt="" class="wp-image-1670522" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-84.png 696w, https://blog.finxter.com/wp-content/uploads/2024/05/image-84-300x259.png 300w" sizes="auto, (max-width: 696px) 100vw, 696px" /></figure>
</div>


<h2 class="wp-block-heading">Test 3: What Are the Names of My Kids</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="778" height="155" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-95.png" alt="" class="wp-image-1670537" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-95.png 778w, https://blog.finxter.com/wp-content/uploads/2024/05/image-95-300x60.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-95-768x153.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="529" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-83-529x1024.png" alt="" class="wp-image-1670521" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-83-529x1024.png 529w, https://blog.finxter.com/wp-content/uploads/2024/05/image-83-155x300.png 155w, https://blog.finxter.com/wp-content/uploads/2024/05/image-83.png 571w" sizes="auto, (max-width: 529px) 100vw, 529px" /></figure>
</div>


<h2 class="wp-block-heading">Test 4: What is the Name of the Hypergraph Partitioning Algorithm and What&#8217;s Its Main Idea?</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="780" height="256" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-96.png" alt="" class="wp-image-1670538" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-96.png 780w, https://blog.finxter.com/wp-content/uploads/2024/05/image-96-300x98.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-96-768x252.png 768w" sizes="auto, (max-width: 780px) 100vw, 780px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="638" height="400" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-86.png" alt="" class="wp-image-1670524" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-86.png 638w, https://blog.finxter.com/wp-content/uploads/2024/05/image-86-300x188.png 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></figure>
</div>


<h2 class="wp-block-heading">Test 5: What Are Two Types of Vertex-Centric Programming Models?</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="808" height="542" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-97.png" alt="" class="wp-image-1670539" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-97.png 808w, https://blog.finxter.com/wp-content/uploads/2024/05/image-97-300x201.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-97-768x515.png 768w" sizes="auto, (max-width: 808px) 100vw, 808px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="634" height="339" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-87.png" alt="" class="wp-image-1670525" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-87.png 634w, https://blog.finxter.com/wp-content/uploads/2024/05/image-87-300x160.png 300w" sizes="auto, (max-width: 634px) 100vw, 634px" /></figure>
</div>


<h2 class="wp-block-heading">Test 6: Explain the Four Main Concepts of ADWISE</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="776" height="850" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-98.png" alt="" class="wp-image-1670540" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-98.png 776w, https://blog.finxter.com/wp-content/uploads/2024/05/image-98-274x300.png 274w, https://blog.finxter.com/wp-content/uploads/2024/05/image-98-768x841.png 768w" sizes="auto, (max-width: 776px) 100vw, 776px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="574" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-88-574x1024.png" alt="" class="wp-image-1670526" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-88-574x1024.png 574w, https://blog.finxter.com/wp-content/uploads/2024/05/image-88-168x300.png 168w, https://blog.finxter.com/wp-content/uploads/2024/05/image-88.png 686w" sizes="auto, (max-width: 574px) 100vw, 574px" /></figure>
</div>


<h2 class="wp-block-heading">Test 7: Give Me the TLDR on ADWISE Evaluation Results</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="758" height="269" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-99.png" alt="" class="wp-image-1670541" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-99.png 758w, https://blog.finxter.com/wp-content/uploads/2024/05/image-99-300x106.png 300w" sizes="auto, (max-width: 758px) 100vw, 758px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="791" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-100-791x1024.png" alt="" class="wp-image-1670542" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-100-791x1024.png 791w, https://blog.finxter.com/wp-content/uploads/2024/05/image-100-232x300.png 232w, https://blog.finxter.com/wp-content/uploads/2024/05/image-100-768x995.png 768w, https://blog.finxter.com/wp-content/uploads/2024/05/image-100.png 799w" sizes="auto, (max-width: 791px) 100vw, 791px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="663" height="295" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-89.png" alt="" class="wp-image-1670527" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-89.png 663w, https://blog.finxter.com/wp-content/uploads/2024/05/image-89-300x133.png 300w" sizes="auto, (max-width: 663px) 100vw, 663px" /></figure>
</div>


<h2 class="wp-block-heading">Test 8: Identify the Research Gap Addressed by Q-Graph</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="823" height="318" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-101.png" alt="" class="wp-image-1670543" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-101.png 823w, https://blog.finxter.com/wp-content/uploads/2024/05/image-101-300x116.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-101-768x297.png 768w" sizes="auto, (max-width: 823px) 100vw, 823px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="713" height="960" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-90.png" alt="" class="wp-image-1670528" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-90.png 713w, https://blog.finxter.com/wp-content/uploads/2024/05/image-90-223x300.png 223w" sizes="auto, (max-width: 713px) 100vw, 713px" /></figure>
</div>


<h2 class="wp-block-heading">Test 9: State the Problem Formulation of HYPE in Mathematical Terms</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="803" height="626" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-102.png" alt="" class="wp-image-1670544" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-102.png 803w, https://blog.finxter.com/wp-content/uploads/2024/05/image-102-300x234.png 300w, https://blog.finxter.com/wp-content/uploads/2024/05/image-102-768x599.png 768w" sizes="auto, (max-width: 803px) 100vw, 803px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="691" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-91-691x1024.png" alt="" class="wp-image-1670529" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-91-691x1024.png 691w, https://blog.finxter.com/wp-content/uploads/2024/05/image-91-203x300.png 203w, https://blog.finxter.com/wp-content/uploads/2024/05/image-91.png 765w" sizes="auto, (max-width: 691px) 100vw, 691px" /></figure>
</div>


<h2 class="wp-block-heading">Test 10: Provide Research Gaps Not Addressed in the Dissertation, Future Work, and Add Your Own Ideas As Well</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="745" height="1024" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-103-745x1024.png" alt="" class="wp-image-1670545" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-103-745x1024.png 745w, https://blog.finxter.com/wp-content/uploads/2024/05/image-103-218x300.png 218w, https://blog.finxter.com/wp-content/uploads/2024/05/image-103-768x1056.png 768w, https://blog.finxter.com/wp-content/uploads/2024/05/image-103.png 808w" sizes="auto, (max-width: 745px) 100vw, 745px" /></figure>



<p>Here&#8217;s the sample part from my <a href="https://blog.finxter.com/scalable-graph-partitioning-for-distributed-graph-processing/" data-type="post" data-id="1651299">dissertation</a> that&#8217;s relevant to the question:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="666" height="595" src="https://blog.finxter.com/wp-content/uploads/2024/05/image-92.png" alt="" class="wp-image-1670530" srcset="https://blog.finxter.com/wp-content/uploads/2024/05/image-92.png 666w, https://blog.finxter.com/wp-content/uploads/2024/05/image-92-300x268.png 300w" sizes="auto, (max-width: 666px) 100vw, 666px" /></figure>
</div><p>The post <a href="https://blog.finxter.com/chatgpt-4o-understands-my-dissertation-better-than-i-do-%f0%9f%a4%af/">ChatGPT-4o Understands My Dissertation Better Than I Do 🤯</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Organisms Eat (Online Game)</title>
		<link>https://blog.finxter.com/organisms-eat-online-game/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Tue, 14 May 2024 12:18:39 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670395</guid>

					<description><![CDATA[<p>Legend: Player A: Red Player B: Blue Player C: Green Player D: Yellow Food: Orange Navigation: Move Up: &#8216;u&#8217; Move Down: &#8216;d&#8217; Move Left: &#8216;l&#8217; Move Right: &#8216;r&#8217;</p>
<p>The post <a href="https://blog.finxter.com/organisms-eat-online-game/">Organisms Eat (Online Game)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin: 0;
        }
        #legend {
            margin-bottom: 20px;
        }
        #game {
            display: grid;
            grid-template-columns: repeat(20, 20px);
            grid-template-rows: repeat(20, 20px);
            gap: 1px;
        }
        .cell {
            width: 20px;
            height: 20px;
            background-color: #ddd;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 12px;
            font-weight: bold;
        }
        .A { background-color: red; }
        .B { background-color: blue; }
        .C { background-color: green; }
        .D { background-color: yellow; }
        .food { background-color: orange; }
    </style>
    <div id="legend">
        <p><strong>Legend:</strong></p>
        <ul>
            <li>Player A: <span style="color: red;">Red</span></li>
            <li>Player B: <span style="color: blue;">Blue</span></li>
            <li>Player C: <span style="color: green;">Green</span></li>
            <li>Player D: <span style="color: yellow;">Yellow</span></li>
            <li>Food: <span style="color: orange;">Orange</span></li>
        </ul>
        <p><strong>Navigation:</strong></p>
        <ul>
            <li>Move Up: &#8216;u&#8217;</li>
            <li>Move Down: &#8216;d&#8217;</li>
            <li>Move Left: &#8216;l&#8217;</li>
            <li>Move Right: &#8216;r&#8217;</li>
        </ul>
    </div>
    <div id="game"></div>
    <script>
        const gameSize = 20;
        const players = ['A', 'B', 'C', 'D'];
        const grid = [];
        const game = document.getElementById('game');

        // Initialize the grid
        for (let i = 0; i < gameSize; i++) {
            grid[i] = [];
            for (let j = 0; j < gameSize; j++) {
                grid[i][j] = '.';
                const cell = document.createElement('div');
                cell.className = 'cell';
                cell.id = `cell-${i}-${j}`;
                game.appendChild(cell);
            }
        }

        // Place players and food randomly
        function placeItems() {
            // Place player A at the center
            grid[10][10] = 'A';
            document.getElementById('cell-10-10').classList.add('A');

            // Place players B, C, D randomly
            for (let player of ['B', 'C', 'D']) {
                let placed = false;
                while (!placed) {
                    const x = Math.floor(Math.random() * gameSize);
                    const y = Math.floor(Math.random() * gameSize);
                    if (grid[x][y] === '.') {
                        grid[x][y] = player;
                        document.getElementById(`cell-${x}-${y}`).classList.add(player);
                        placed = true;
                    }
                }
            }

            // Place food randomly
            for (let i = 0; i < 50; i++) {
                let placed = false;
                while (!placed) {
                    const x = Math.floor(Math.random() * gameSize);
                    const y = Math.floor(Math.random() * gameSize);
                    if (grid[x][y] === '.') {
                        grid[x][y] = '*';
                        document.getElementById(`cell-${x}-${y}`).classList.add('food');
                        placed = true;
                    }
                }
            }
        }

        function movePlayer(player, direction) {
            const positions = [];
            for (let i = 0; i < gameSize; i++) {
                for (let j = 0; j < gameSize; j++) {
                    if (grid[i][j] === player) {
                        positions.push({ x: i, y: j });
                        grid[i][j] = '.';
                        document.getElementById(`cell-${i}-${j}`).className = 'cell';
                    }
                }
            }

            const newPositions = positions.map(pos => {
                switch (direction) {
                    case 'u': return { x: (pos.x - 1 + gameSize) % gameSize, y: pos.y };
                    case 'd': return { x: (pos.x + 1) % gameSize, y: pos.y };
                    case 'l': return { x: pos.x, y: (pos.y - 1 + gameSize) % gameSize };
                    case 'r': return { x: pos.x, y: (pos.y + 1) % gameSize };
                }
            });

            newPositions.forEach(pos => {
                if (grid[pos.x][pos.y] === '*') {
                    growPlayer(player, pos.x, pos.y);
                } else if (players.includes(grid[pos.x][pos.y])) {
                    fightPlayer(player, grid[pos.x][pos.y], pos.x, pos.y);
                } else {
                    grid[pos.x][pos.y] = player;
                    document.getElementById(`cell-${pos.x}-${pos.y}`).classList.add(player);
                }
            });
        }

        function growPlayer(player, x, y) {
            grid[x][y] = player;
            document.getElementById(`cell-${x}-${y}`).classList.add(player);

            const directions = [
                { x: -1, y: 0 }, { x: 1, y: 0 }, 
                { x: 0, y: -1 }, { x: 0, y: 1 }
            ];
            let grown = false;
            while (!grown) {
                const dir = directions[Math.floor(Math.random() * directions.length)];
                const newX = (x + dir.x + gameSize) % gameSize;
                const newY = (y + dir.y + gameSize) % gameSize;
                if (grid[newX][newY] === '.') {
                    grid[newX][newY] = player;
                    document.getElementById(`cell-${newX}-${newY}`).classList.add(player);
                    grown = true;
                }
            }
        }

        function fightPlayer(attacker, defender, x, y) {
            const attackerCells = countCells(attacker);
            const defenderCells = countCells(defender);
            const totalCells = attackerCells + defenderCells;
            const fightOutcome = Math.random() * totalCells;
            if (fightOutcome < attackerCells) {
                grid[x][y] = attacker;
                document.getElementById(`cell-${x}-${y}`).classList.add(attacker);
                growPlayer(attacker, x, y);
            } else {
                grid[x][y] = defender;
                document.getElementById(`cell-${x}-${y}`).classList.add(defender);
            }
        }

        function countCells(player) {
            let count = 0;
            for (let i = 0; i < gameSize; i++) {
                for (let j = 0; j < gameSize; j++) {
                    if (grid[i][j] === player) {
                        count++;
                    }
                }
            }
            return count;
        }

        function randomMove() {
            return ['u', 'd', 'l', 'r'][Math.floor(Math.random() * 4)];
        }

        function moveComputerPlayers() {
            for (let player of ['B', 'C', 'D']) {
                movePlayer(player, randomMove());
            }
        }

        function handleKey(event) {
            const direction = event.key;
            if (['u', 'd', 'l', 'r'].includes(direction)) {
                movePlayer('A', direction);
                moveComputerPlayers();
                checkGameOver();
            }
        }

        function checkGameOver() {
            const playerCells = countCells('A');
            const otherPlayersCells = players.filter(p => p !== 'A').reduce((acc, player) => acc + countCells(player), 0);
            if (playerCells === 0 || otherPlayersCells === 0) {
                alert(playerCells === 0 ? "You lost!" : "You won!");
                document.removeEventListener('keydown', handleKey);
            }
        }

        placeItems();
        document.addEventListener('keydown', handleKey);
    </script>
</div>
<p>The post <a href="https://blog.finxter.com/organisms-eat-online-game/">Organisms Eat (Online Game)</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python Object Creation: __new__ vs __init__</title>
		<link>https://blog.finxter.com/python-object-creation-__new__-vs-__init__/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Thu, 25 Apr 2024 14:49:58 +0000</pubDate>
				<category><![CDATA[Object Orientation]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Python Built-in Functions]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670130</guid>

					<description><![CDATA[<p>Python&#8217;s magic methods __new__ and __init__ play complementary roles in the lifecycle of an object: 👉 __new__ is a static method, primarily concerned with creating and returning a new instance of a class; it acts before the object is fully instantiated in memory. 👉 Following this, __init__ functions as an instance method, tasked with configuring ... <a title="Python Object Creation: __new__ vs __init__" class="read-more" href="https://blog.finxter.com/python-object-creation-__new__-vs-__init__/" aria-label="Read more about Python Object Creation: __new__ vs __init__">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-object-creation-__new__-vs-__init__/">Python Object Creation: __new__ vs __init__</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-global-color-8-background-color has-background">Python&#8217;s magic methods <code><a href="https://blog.finxter.com/python-__new__-magic-method/" data-type="post" data-id="114351">__new__</a></code> and <code><a href="https://blog.finxter.com/python-init/" data-type="post" data-id="5133">__init__</a></code> play complementary roles in the lifecycle of an object:<br><br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <code>__new__</code> is a static method, primarily concerned with creating and returning a new instance of a class; it acts before the object is fully instantiated in memory. <br><br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Following this, <code>__init__</code> functions as an instance method, tasked with configuring the specific attributes of the newly minted object, thus defining its initial state. </p>



<p>This orchestrated sequence ensures that the structural foundation established by <code>__new__</code> precedes the customization of the object&#8217;s properties through <code>__init__</code>. </p>



<p>This design provides a clear and methodical approach to object creation and initialization in Python.</p>



<h2 class="wp-block-heading">Minimal Example</h2>



<p>Here&#8217;s a simple example that demonstrates the difference between <code>__new__</code> and <code>__init__</code> in Python:</p>



<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="">class MyClass:
    def __new__(cls):
        print("Creating instance")
        return super(MyClass, cls).__new__(cls)

    def __init__(self):
        print("Initializing instance")

# Creating an object of MyClass
obj = MyClass()</pre>



<p>In this example:</p>



<ul class="wp-block-list">
<li>When <code>MyClass()</code> is invoked, <code>__new__</code> is called first. It is responsible for creating and returning a new instance of the class. Here, it prints &#8220;Creating instance&#8221; and uses <code>super()</code> to call the <code>__new__</code> method of the superclass to allocate the memory for the new object.</li>



<li>Once the new instance is created and returned by <code>__new__</code>, <code>__init__</code> is called to initialize the new object. In this case, it prints &#8220;Initializing instance&#8221;.</li>
</ul>



<p>This output illustrates the order and roles of <code>__new__</code> and <code>__init__</code> in Python&#8217;s object creation process.</p>



<h2 class="wp-block-heading">FAQ: Understanding <code>__new__</code> and <code>__init__</code> in Python</h2>



<h3 class="wp-block-heading"><strong>1. What is the purpose of <code>__new__</code> in Python?</strong></h3>



<p><code>__new__</code> is a static method responsible for creating a new instance of a class. It is the first step in the instance creation process, handling memory allocation before any attributes are initialized.</p>



<h3 class="wp-block-heading"><strong>2. How does <code>__init__</code> differ from <code>__new__</code>?</strong></h3>



<p>While <code>__new__</code> creates the instance, <code>__init__</code> is tasked with initializing the newly created object&#8217;s attributes. It sets up the initial state of the object after <code>__new__</code> has already created it.</p>



<h3 class="wp-block-heading"><strong>3. When would you need to override <code>__new__</code> instead of <code>__init__</code>?</strong></h3>



<p>Overriding <code>__new__</code> is less common but is necessary when you need to control the creation of a new instance, such as enforcing certain patterns (like singletons), modifying immutable types, or extending immutable types like tuples and strings.</p>



<h3 class="wp-block-heading"><strong>4. Can <code>__init__</code> return a value?</strong></h3>



<p>No, <code>__init__</code> should not return anything except <code>None</code>. It is designed purely for initialization and not for creating new instances, which is the role of <code>__new__</code>.</p>



<h3 class="wp-block-heading"><strong>5. What happens if <code>__new__</code> does not return an instance of the class?</strong></h3>



<p>If <code>__new__</code> returns something that isn&#8217;t an instance of the class in which it&#8217;s defined, then <code>__init__</code> will not be called. This can be used intentionally to control the type of objects your class creates or returns.</p>



<h3 class="wp-block-heading"><strong>6. Is it mandatory to call the base class’s <code>__new__</code> when overriding it?</strong></h3>



<p>Yes, generally you should call the base class’s <code>__new__</code> using <code>super()</code> to ensure that the object gets properly created before you attempt to initialize it in <code>__init__</code>.</p>



<h3 class="wp-block-heading"><strong>7. Can <code>__init__</code> be called multiple times on the same instance?</strong></h3>



<p>Yes, <code>__init__</code> can technically be called multiple times for the same instance, allowing reinitialization of the object. However, <code>__new__</code> is typically called only once per object creation.</p>



<h3 class="wp-block-heading"><strong>8. Are <code>__new__</code> and <code>__init__</code> only relevant to classes defined in Python code?</strong></h3>



<p><code>__new__</code> and <code>__init__</code> are relevant for any class, including those from Python’s standard library or third-party libraries that follow the object-oriented paradigm.</p>



<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/understanding-the-differences-between-self-and-__init__-methods-in-python-classes/">Understanding the Differences Between self and init Methods in Python Classes</a></p>
<p>The post <a href="https://blog.finxter.com/python-object-creation-__new__-vs-__init__/">Python Object Creation: __new__ vs __init__</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python Check If an Integer is in Range</title>
		<link>https://blog.finxter.com/python-check-if-an-integer-is-in-range/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Wed, 24 Apr 2024 11:30:45 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Python Built-in Functions]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670127</guid>

					<description><![CDATA[<p>Problem Formulation You&#8217;re given a number. How do you check if the number lies between two numbers, i.e., a numeric range? When you check if a number lies between two other numbers it returns a boolean that determines if the number is greater than or equal to the minimum number and also less than or ... <a title="Python Check If an Integer is in Range" class="read-more" href="https://blog.finxter.com/python-check-if-an-integer-is-in-range/" aria-label="Read more about Python Check If an Integer is in Range">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-check-if-an-integer-is-in-range/">Python Check If an Integer is in Range</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading"><strong>Problem Formulation</strong></h2>



<p><strong>You&#8217;re given a number. How do you check if the number lies between two numbers, i.e., a numeric <em>range</em>?</strong></p>



<p>When you check if a number lies between two other numbers it returns a boolean that determines if the number is greater than or equal to the minimum number and also less than or equal to the maximum number. </p>



<p>Here&#8217;s an example that demonstrates the problem:</p>



<pre class="wp-block-preformatted"><strong>Example 1:</strong> Is 25 between 15 and 35?<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Output: </strong><code>True</code><br><br><strong>Example 2</strong>: Is 0.5 between 1 and 5?<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Output: </strong><code>False</code><br><br><strong>Example 3</strong>: Is 10 between 10 and 20?<br><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Output: </strong><code>True</code></pre>



<p>Let&#8217;s dive into the trivial solution next &#8212; can you figure out why this is not optimal? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading">Method 1: Using Python&#8217;s <a href="https://blog.finxter.com/python-membership-in-operator/" target="_blank" rel="noreferrer noopener"><code>in</code></a> Keyword with the <code>range()</code> Function</h2>



<p class="has-global-color-8-background-color has-background">You can use the <code><a href="https://blog.finxter.com/python-range-function/" data-type="post" data-id="18290">range()</a></code> function to determine the upper and lower limits/numbers by feeding in the start and stop values within it. Now, to check if the number lies between the two numbers you can simply use the <strong><code>in</code></strong> keyword to check it. So, if the number lies in the specified range then the output will be &#8220;<em><code>True</code></em>&#8221; else &#8220;<em><code>False</code></em>&#8220;.</p>



<p>Here&#8217;s a simple example:</p>



<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="">print(25 in range(15, 36))  # True
print(0.5 in range(0, 2))  # False
print(10 in range(10, 20))  # True</pre>



<p>Note that the stop value within the <code>range()</code> function should always be one greater than the given maximum number/upper limit since the range of values taken into account by the <code>range</code> function always lies between start to stop-1. Read more about the <code>range()</code> function here:</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong><a href="https://blog.finxter.com/python-range-function/" target="_blank" rel="noreferrer noopener">Python <code>range()</code> Function — A Helpful Illustrated Guide</a></strong></p>



<p class="has-base-2-background-color has-background"><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Info:</strong> Python’s “<code>in</code>” operator is a reserved <a href="https://blog.finxter.com/python-cheat-sheet/" target="_blank" rel="noreferrer noopener">keyword </a>to test <a href="https://blog.finxter.com/python-membership-in-operator/" data-type="post" data-id="34005">membership</a> of the left operand in the right operand. The right operand, therefore, needs to be a collection type.<br><br>For example, the expression <code>x in my_list checks</code> if object <code>x</code> exists in the <code>my_list</code> collection, so that at least one element <code>y</code> exists in <code>my_list</code> for that <code>x == y</code> holds. <br><br>You can check membership using the “<code>in</code>” operator in collections such as <a href="https://blog.finxter.com/python-lists/" target="_blank" rel="noreferrer noopener">lists</a>, <a href="https://blog.finxter.com/sets-in-python/" target="_blank" rel="noreferrer noopener">sets</a>, <a href="https://blog.finxter.com/python-string-methods/" target="_blank" rel="noreferrer noopener">strings</a>, and <a href="https://blog.finxter.com/the-ultimate-guide-to-python-tuples/" target="_blank" rel="noreferrer noopener">tuples</a>.</p>



<figure class="wp-block-image size-full is-style-default"><a href="https://blog.finxter.com/python-membership-in-operator/"><img loading="lazy" decoding="async" width="1024" height="576" src="https://blog.finxter.com/wp-content/uploads/2022/09/image-71.png" alt="" class="wp-image-699814" srcset="https://blog.finxter.com/wp-content/uploads/2022/09/image-71.png 1024w, https://blog.finxter.com/wp-content/uploads/2022/09/image-71-300x169.png 300w, https://blog.finxter.com/wp-content/uploads/2022/09/image-71-768x432.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>This is not the optimal method because you need to create a whole range of values. Its runtime complexity depends on the size of the range which is really bad when compared to the better alternative: </p>



<h2 class="wp-block-heading">Method 2: Use Comparison Operators</h2>



<p>Python <a href="https://blog.finxter.com/python-comparison-operators/" data-type="post" data-id="33245">comparison operators</a> can compare numerical values such as integers and floats in Python. The operators are: </p>



<ul class="wp-block-list">
<li>equal to ( == ), </li>



<li>not equal to ( != ), </li>



<li>greater than ( > ), </li>



<li>less than ( &lt; ), </li>



<li>less than or equal to ( &lt;= ), and </li>



<li>greater than or equal to ( >= ).</li>
</ul>



<p class="has-global-color-8-background-color has-background">You can use the &lt;= and the >= operators to check if a number lies between the upper limit (maximum number) and lower limit(minimum number).</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">print(15 &lt;= 25 &lt; 35)  # True
print(1 &lt;= 0.5 &lt; 5)  # False
print(10 &lt;= 10 &lt; 20)  # True</pre>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/check-if-a-number-is-between-two-numbers-in-python/">Check If a Number is Between Two Numbers in Python</a></p>



<h2 class="wp-block-heading">Method 3: Using &#8220;and&#8221; Keyword with Comparison Operators</h2>



<p>An alternative way of checking whether a value lies in a range of values is quite similar to the one used above. The only difference, in this case, is to use the <code>and</code> keyword in between the two comparison operators as shown in the solution below.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">print(15 &lt;= 25 and 25 &lt;= 35)  # True
print(1 &lt;= 0.5 and 0.5 &lt;= 5)  # False
print(10 &lt;= 10 and 10 &lt;= 20)  # True</pre>



<p>Some of you might be thinking why use an extra keyword when the solution given before is more readable than this one! Well! That&#8217;s true. The first syntax is more readable but this solution runs faster. Let&#8217;s compare the two solutions using <strong><a rel="noreferrer noopener" href="https://blog.finxter.com/how-to-measure-elapsed-time-in-python/#Method_4_Using_timeit_Module" target="_blank">timeit</a></strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="atomic" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">~$ python3 -m timeit "10 &lt;= 20 and 20 &lt;= 30"
10000000 loops, best of 3: 0.0366 usec per loop

~$ python3 -m timeit "10 &lt;= 20 &lt;= 30"
10000000 loops, best of 3: 0.0396 usec per loop</pre>



<h2 class="wp-block-heading">Quick Overview</h2>



<p>Here are various ways to check if a Python integer, <code>x</code>, falls within a specific range:</p>



<ul class="wp-block-list">
<li><strong>Direct Comparison</strong>: <code>if low &lt;= x &lt;= high</code> for inclusive or <code>if low &lt; x &lt; high</code> for exclusive.</li>



<li><strong>Using <code>range()</code></strong>: <code>if x in range(low, high+1)</code> for inclusive or <code>if x in range(low, high)</code> for exclusive.</li>



<li><strong>Boolean Operators</strong>: <code>if x >= low and x &lt;= high</code> for inclusive or <code>if x > low and x &lt; high</code> for exclusive.</li>



<li><strong>Custom Function</strong>: Define a function like <code>def in_range(x, low, high): return low &lt;= x &lt;= high</code> for easy reuse.</li>



<li><strong>Using <code>math</code> module</strong>: <code>import math; if math.isclose(x, low, abs_tol=1e-9) or low &lt; x &lt; high</code> for near lower bound inclusivity.</li>



<li><strong>List Comprehension</strong>: <code>if x in [i for i in range(low, high+1)]</code> offers explicit control over range elements.</li>
</ul>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/list-comprehension/">List Comprehension in Python — A Helpful Illustrated Guide</a></p>
<p>The post <a href="https://blog.finxter.com/python-check-if-an-integer-is-in-range/">Python Check If an Integer is in Range</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python Create List From 1 to N with Step Size</title>
		<link>https://blog.finxter.com/python-create-list-from-1-to-n-with-step-size/</link>
		
		<dc:creator><![CDATA[Chris]]></dc:creator>
		<pubDate>Mon, 22 Apr 2024 11:54:54 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Python List]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=1670109</guid>

					<description><![CDATA[<p>🎯 Problem Formulation: How to create a list from 1 to n with a specified step in Python? Let&#8217;s start with one of the easiest ways: 👇 Method 0. Using list() and range() The Python expression list(range(1, n + 1, step)) generates a list of integers starting from 1 up to and including (n), incrementing ... <a title="Python Create List From 1 to N with Step Size" class="read-more" href="https://blog.finxter.com/python-create-list-from-1-to-n-with-step-size/" aria-label="Read more about Python Create List From 1 to N with Step Size">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-create-list-from-1-to-n-with-step-size/">Python Create List From 1 to N with Step Size</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-base-2-background-color has-background"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3af.png" alt="🎯" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Problem Formulation:</strong> How to create a list from 1 to n with a specified step in Python?</p>



<p>Let&#8217;s start with one of the easiest ways: <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>



<h2 class="wp-block-heading">Method 0. Using list() and range()</h2>



<p>The Python expression <code>list(range(1, n + 1, step))</code> generates a list of integers starting from 1 up to and including (n), incrementing by a specified value <code>step</code>. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list(range(1, n + 1, step))</pre>



<p>Here, <code><a href="https://blog.finxter.com/python-range-function/" data-type="post" data-id="18290">range()</a></code> is a built-in function that creates a sequence of numbers from its first argument (1) to one less than its second argument ((n+1), making (n) the last number in the range), with the sequence progressing by the value of the third argument (<code>step</code>). </p>



<p>Wrapping <code>range()</code> with <code><a href="https://blog.finxter.com/python-list/" data-type="post" data-id="21502">list()</a></code> converts the sequence into a list, which can be used in Python for further operations like iterations, calculations, and more.</p>



<p>I also like the following alternative way: <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>



<h2 class="wp-block-heading">Method 1. Using <code>range()</code> in List Comprehension</h2>



<p class="has-global-color-8-background-color has-background">Using <code>[i for i in range(1, n+1, step)]</code> is the most straightforward method using built-in Python functions: <a href="https://blog.finxter.com/5-best-ways-to-use-list-comprehension-with-dictionaries-in-python/" data-type="post" data-id="1656775">list comprehension</a> and <code><a href="https://blog.finxter.com/python-range-function/" data-type="post" data-id="18290">range()</a></code>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = [i for i in range(1, n + 1, step)]</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="542" height="229" src="https://blog.finxter.com/wp-content/uploads/2024/04/image-23.png" alt="" class="wp-image-1670113" srcset="https://blog.finxter.com/wp-content/uploads/2024/04/image-23.png 542w, https://blog.finxter.com/wp-content/uploads/2024/04/image-23-300x127.png 300w" sizes="auto, (max-width: 542px) 100vw, 542px" /></figure>



<p></p>



<h2 class="wp-block-heading">Method 2. Using <code>numpy.arange()</code></h2>



<p>For those using the NumPy library, particularly effective for large data sets due to its optimized performance.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy as np
list_with_step = np.arange(1, n + 1, step).tolist()</pre>



<h2 class="wp-block-heading">Method 3. Using List Slicing</h2>



<p>Generate a full list first and then use <a href="https://blog.finxter.com/5-best-ways-to-use-the-slicing-operator-in-python/" data-type="post" data-id="1659228">slicing</a> to select every <code>step</code>th element.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = list(range(1, n + 1))[::step]</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="471" height="128" src="https://blog.finxter.com/wp-content/uploads/2024/04/image-24.png" alt="" class="wp-image-1670115" srcset="https://blog.finxter.com/wp-content/uploads/2024/04/image-24.png 471w, https://blog.finxter.com/wp-content/uploads/2024/04/image-24-300x82.png 300w" sizes="auto, (max-width: 471px) 100vw, 471px" /></figure>



<p>The expression <code>list(range(1, n + 1))[::step]</code> first creates a list of integers from 1 to ( n ) using <code>range()</code> and <code>list()</code>. It then uses slicing <code>[::-step]</code> to return every <code>step</code>th element from the generated list. This approach is efficient for selecting spaced elements from an already defined sequence.</p>



<h2 class="wp-block-heading">Method 4. Using <code>itertools.islice</code> with <code>itertools.count</code></h2>



<p>Utilizes lazy evaluation, ideal for very large ranges.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from itertools import islice, count
list_with_step = list(islice(count(1, step), (n - 1) // step + 1))</pre>



<h2 class="wp-block-heading">Method 5. Using a <code>for</code> loop with Index Management</h2>



<p>Explicitly controls the index, providing clarity at the cost of more verbose code.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = []
for i in range(1, n + 1):
    if (i - 1) % step == 0:
        list_with_step.append(i)</pre>



<p>For example:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="410" height="163" src="https://blog.finxter.com/wp-content/uploads/2024/04/image-25.png" alt="" class="wp-image-1670116" srcset="https://blog.finxter.com/wp-content/uploads/2024/04/image-25.png 410w, https://blog.finxter.com/wp-content/uploads/2024/04/image-25-300x119.png 300w" sizes="auto, (max-width: 410px) 100vw, 410px" /></figure>
</div>


<h2 class="wp-block-heading">Method 6. Using <code>filter</code> with <code>range</code></h2>



<p>Applies a filter function to a range, extracting elements based on a condition.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = list(filter(lambda x: (x - 1) % step == 0, range(1, n + 1)))</pre>



<h2 class="wp-block-heading">Method 7. Using a <code>while</code> loop</h2>



<p>This method manually controls the addition of elements to the list.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = []
i = 1
while i &lt;= n:
    list_with_step.append(i)
    i += step</pre>



<h2 class="wp-block-heading">Method 8. Using <code>itertools.takewhile</code> with <code>itertools.count</code></h2>



<p>Combines two itertools functions to generate a controlled sequence that stops when a condition is met.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from itertools import takewhile, count
list_with_step = list(takewhile(lambda x: x &lt;= n, count(1, step)))</pre>



<h2 class="wp-block-heading">Method 9. Using <code>map</code> and <code>range</code></h2>



<p>Incorporates a transformation directly within the map function for adjusting step intervals.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = list(map(lambda x: 1 + (x * step), range((n + step - 1) // step)))</pre>



<h2 class="wp-block-heading">Method 10. Advanced Conditional List Comprehension</h2>



<p>Incorporates condition checks directly within a list comprehension for greater control.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">list_with_step = [i for i in range(1, n + 1) if (i - 1) % step == 0]</pre>



<p>Also check out my related article:</p>



<p><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f449.png" alt="👉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <a href="https://blog.finxter.com/python-create-list-from-1-to-n/" data-type="post" data-id="1503259">Python Create List From 1 to N</a></p>
<p>The post <a href="https://blog.finxter.com/python-create-list-from-1-to-n-with-step-size/">Python Create List From 1 to N with Step Size</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.finxter.com @ 2026-04-19 10:09:43 by W3 Total Cache
-->