<?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>Blog – Heaplevel AB</title>
	<atom:link href="https://heaplevel.com/category/blog/feed/" rel="self" type="application/rss+xml" />
	<link>https://heaplevel.com</link>
	<description>Software Development Partner</description>
	<lastBuildDate>Mon, 06 Apr 2026 07:54:07 +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://heaplevel.com/wp-content/uploads/2020/01/cropped-Heaplevel-1-32x32.png</url>
	<title>Blog – Heaplevel AB</title>
	<link>https://heaplevel.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Introducing a new Krita Plugin &#8211; Buttonz Booster</title>
		<link>https://heaplevel.com/news/introducing-a-new-krita-plugin-buttonz-booster/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Sun, 16 Feb 2025 13:54:26 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=435</guid>

					<description><![CDATA[<p>Krita has been my go-to application for digital drawing and editing. It&#8217;s a powerful open-source painting program, on par with professional software like Photoshop, and loved by artists worldwide Where does Buttonz Booster fit in? The purpose is to save you some clicks, and it allows you to create a new document with a predefined &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/news/introducing-a-new-krita-plugin-buttonz-booster/" class="more-link">Continue reading<span class="screen-reader-text"> "Introducing a new Krita Plugin &#8211; Buttonz Booster"</span></a></p>
<p>The post <a href="https://heaplevel.com/news/introducing-a-new-krita-plugin-buttonz-booster/">Introducing a new Krita Plugin – Buttonz Booster</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Krita has been my go-to application for digital drawing and editing. It&#8217;s a powerful open-source painting program, on par with professional software like Photoshop, and loved by artists worldwide</p>



<p>Where does <strong>Buttonz Booster</strong> fit in? </p>



<p>The purpose is to save you some clicks, and it allows you to create a new document with a predefined size, simple and easy.</p>



<p>You can install it directly from Krita, first download the ZIP file</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<div class="wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-8cf370e7 wp-block-group-is-layout-flex">
<details class="wp-block-details is-layout-flow wp-block-details-is-layout-flow"><summary>Buttonz Booster</summary>
<div class="wp-block-file"><a id="wp-block-file--media-a2f97732-85c0-46a1-8326-1c835edd9f21" href="https://heaplevel.com/wp-content/uploads/2025/02/buttonbooztplugin.zip">buttonbooztplugin</a><a href="https://heaplevel.com/wp-content/uploads/2025/02/buttonbooztplugin.zip" class="wp-block-file__button wp-element-button" download aria-describedby="wp-block-file--media-a2f97732-85c0-46a1-8326-1c835edd9f21">Download</a></div>
</details>
</div>
</div>
</div>
</div></div>



<p><strong>Alt. download link</strong><br><a href="https://www.dropbox.com/scl/fi/hp12hct3n3rgvhys00iwy/buttonbooztplugin.zip?rlkey=5c0wzkp8u5erjjx6pty9hs50v&amp;st=xm243ii2&amp;dl=0">Alternative download link</a></p>



<p></p>



<h2 class="wp-block-heading">How to Install</h2>



<ol class="wp-block-list">
<li>Go to menu Tools-&gt;Scripts-&gt;Import Python Plugin from File…¨</li>



<li>Locate the ZIP file you just downloaded. The install should prompt if everything went OK or not.</li>



<li>Restart Krita if all went fine.</li>



<li>Activate Settings-&gt;Docker-&gt;Buttonz Booster</li>
</ol>



<p>I’m happy to share it with you all, and are there any quick actions you’d like to add? Let me know!</p><p>The post <a href="https://heaplevel.com/news/introducing-a-new-krita-plugin-buttonz-booster/">Introducing a new Krita Plugin – Buttonz Booster</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python if-statements and loops &#8211; how to be lazy</title>
		<link>https://heaplevel.com/blog/python-if-statements-and-loops/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Mon, 13 Jan 2025 07:49:00 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=450</guid>

					<description><![CDATA[<p>Welcome to the beginning parts of Learn Python In A Normal Way. In this series we&#8217;re working on our own Training App. The series focuses on how to get up and running with logical thinking and programming with Python, and it should suit the beginner since doing assignments is what makes you learn quicker. In &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/python-if-statements-and-loops/" class="more-link">Continue reading<span class="screen-reader-text"> "Python if-statements and loops &#8211; how to be lazy"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/python-if-statements-and-loops/">Python if-statements and loops – how to be lazy</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p> Welcome to the beginning parts of Learn Python In A Normal Way. In this series we&#8217;re working on our own Training App. The series focuses on how to get up and running with logical thinking and programming with Python, and it should suit the beginner since doing assignments is what makes you learn quicker. </p>
<p> In this part we&#8217;re moving forward with our training app and learn Python if-statements, for-loop introduction and more! </p>
<p> Make sure you&#8217;ve read the previous part <a href="https://heaplevel.com/?p=416">Python data structures part 1 &#8211; a look at variables and lists</a> </p>
<div id="outline-container-orgd81ae79" class="outline-2">
<h2 id="orgd81ae79">Purpose</h2>
<div class="outline-text-2" id="text-orgd81ae79">
<p> The purpose of this post is to introduce the loops, if statement and conditional logic. Why? Because a lot of programming involves deciding between multiple paths and handling collection of data. </p>
</div>
</div>
<div id="outline-container-org68103b3" class="outline-2">
<h2 id="org68103b3">Goal</h2>
<div class="outline-text-2" id="text-org68103b3">
<p> By the end of this post you can </p>
<ul class="org-ul">
<li>understand how an if-statement is constructed</li>
<li>understand how to use a for loop in simple scenario</li>
<li>begin to develop boolean conditions in an if-statement</li>
</ul>
</div>
</div>
<div id="outline-container-org3533523" class="outline-2">
<h2 id="org3533523">Prerequisites</h2>
<div class="outline-text-2" id="text-org3533523">
<p> You must have Python installed and be able to start IDLE to follow along. You should be familiar with how to create modules/script and run a Python script, either from the terminal or the GUI window. </p>
<p> A good starting point is this link: <a href="https://heaplevel.com/?p=337">How To Install Python On Your Computer</a> </p>
<p> Additionally you should have finished <a href="https://heaplevel.com/?p=416">Python data structures part 1 &#8211; a look at variables and lists</a> </p>
<p> If you found anything difficult in that part, please let us know! <a href="https://heaplevel.com/?p=30">Contact Us</a> </p>
</div>
</div>
<div id="outline-container-orgac7c45f" class="outline-2">
<h2 id="orgac7c45f">Python If-statement &#8211; make a choice in your application</h2>
<div class="outline-text-2" id="text-orgac7c45f">
<p> A Python If-statement gives you more control over a program. With an <code>if</code>-statement, we use the information of a variable to make a choice in your program. For example, if you want to display all exercises when the user responds &#8220;Yes,&#8221; and show a different message if the user responds &#8220;No,&#8221; you can use an <code>if</code>-statement. </p>
<p> Let&#8217;s see what they look like! </p>
</div>
<div id="outline-container-org8ff53b5" class="outline-3">
<h3 id="org8ff53b5">Code Block to Copy</h3>
<div class="outline-text-3" id="text-org8ff53b5">
<p> Try the following code in a new script, which we’ll call <code>workout_v2.py</code>: </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: workout_v2.py.</em></label></p>
<pre class="src src-python" id="workout_v2.py"><span style="color: #BA36A5;">week</span> = 1
<span style="color: #BA36A5;">schedule</span> = <span style="color: #008000;">'Workout A'</span>
<span style="color: #BA36A5;">exercises</span> = (<span style="color: #008000;">'Bench press'</span>, <span style="color: #008000;">'Deadlift'</span>, <span style="color: #008000;">'Squat'</span>, <span style="color: #008000;">'Biceps curl'</span>)

<span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Would you like to see all exercises in the training schedule? (Yes/No) '</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> response == <span style="color: #008000;">'Yes'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Here are all the exercises:'</span>)
    <span style="color: #8D8D84;"># </span><span style="color: #8D8D84; font-style: italic;">more code here ...</span>
<span style="color: #0000FF; font-weight: bold;">elif</span> response == <span style="color: #008000;">'No'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Okay, we won&#8217;t show any exercises right now.'</span>)
<span style="color: #0000FF; font-weight: bold;">else</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Invalid response, please type "Yes" or "No".'</span>)
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orgab7597f" class="outline-2">
<h2 id="orgab7597f">Python If-statement Analysis</h2>
<div class="outline-text-2" id="text-orgab7597f">
<p> The if-statement in previous listing highlights three branches: </p>
<ol class="org-ol">
<li><b>Condition with <code>if</code></b>: If the user types &#8220;Yes,&#8221; the code block following the <code>if</code> statement is executed. We call this the first conditional block. The boolean expression (response == &#8216;Yes&#8217;) evaluates to either True or False, depending on what the user typed.</li>
<li><b>Alternative with <code>elif</code></b>: If the user types &#8220;No,&#8221; a different message is displayed.</li>
<li><b>Invalid response</b>: If the response is something other than &#8220;Yes&#8221; or &#8220;No,&#8221; the program shows a message explaining that only those answers are valid.</li>
</ol>
<p> It&#8217;s plain English, yet so important to get it right with Python syntax and indentation. Notice the colon, and the indentation for each block. Otherwise you will get a syntax error when you try to run the program. </p>
<p> Run the code and try typing &#8220;Yes,&#8221; &#8220;No,&#8221; and an invalid response (like &#8220;Maybe&#8221;) to see what happens. You’ll notice that the program becomes more interactive and adapts to the user’s input now. Pretty neat, right? </p>
</div>
</div>
<div id="outline-container-org042bbda" class="outline-2">
<h2 id="org042bbda">A note about conditional logic</h2>
<div class="outline-text-2" id="text-org042bbda">
<p> When we write an if-statement, the <i>code block or the branch</i> to enter is evaluated according to a <i>boolean expression</i>. It&#8217;s the same as asking a Yes/No question, but in the computer world we call this True/False result. </p>
<p> The if-statement anatomy consists of the conditional block and the boolean expression </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #0000FF; font-weight: bold;">if</span> <span style="color: #D0372D;">True</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"This will always be printed"</span>)
</pre>
</div>
<p> When we compared the user&#8217;s answer of &#8220;Yes&#8221; or &#8220;No&#8221;, the result of that comparison would either be True or False internally. </p>
<p> On the other hand, if we&#8217;d write </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #0000FF; font-weight: bold;">if</span> <span style="color: #D0372D;">False</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"This will never be printed"</span>)
</pre>
</div>
<p> Then we&#8217;d never enter that block. Why? </p>
<p> Here are more examples of <i>boolean expressions</i>, where we use the comparion operator <i>greater than &gt;</i>. The first evaluates whether 5 is greater than 10 (False obviously). The second checks if the length of the variable <code>some_list</code> exceeds 100. </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #0000FF; font-weight: bold;">if</span>  5 &gt; 10: <span style="color: #8D8D84;"># </span><span style="color: #8D8D84; font-style: italic;">Evaluate to False</span>
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"5 is greater than 10, is it really?"</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> <span style="color: #006FE0;">len</span>(some_list) &gt; 100: <span style="color: #8D8D84;"># </span><span style="color: #8D8D84; font-style: italic;">Test if the list has more than 100 elements</span>
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"You have more than 100 elements in the list"</span>)

</pre>
</div>
<p> The purpose is to only execute part of the code when the <i>boolean expression</i> is True. In the above example it&#8217;s simply just one <code>print</code> statement. This is something we will see more of and learn about as we move along. </p>
<p> This type of logic becomes important as you want develop the program, also when when you want to put constraints in your program. </p>
<p> Imagine a scenario to never allow more than 5 exercises per workout day, or where you can limit the number of sessions total per week. All these things require some kind of <i>conditional logic</i> to exist in your program. Therefore as you gain experience and  develop the program, it&#8217;s only you as the designer of the program that can decide what is valid in your program or not. </p>
<p> Finally, let&#8217;s look at how to combine multiple expressions, to check several conditions at the same time. </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #0000FF; font-weight: bold;">if</span> Expression1 <span style="color: #0000FF; font-weight: bold;">or</span> Expression2:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"we use the or-condition"</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> answer == <span style="color: #008000;">"Yes"</span> <span style="color: #0000FF; font-weight: bold;">or</span> answer == <span style="color: #008000;">"yes"</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"You entered Yes..."</span>)
</pre>
</div>
<p> The second example becomes handy when you want to let a user be more flexible, you will allow &#8220;Yes&#8221; and &#8220;yes&#8221; as an answer to a question, you&#8217;ll try to implement this in your program too with the exercises. </p>
</div>
</div>
<div id="outline-container-orgb8dbe0e" class="outline-2">
<h2 id="orgb8dbe0e">Python for-loop &#8211; loop through exercises with</h2>
<div class="outline-text-2" id="text-orgb8dbe0e">
<p> Now let&#8217;s get back to our program, and look at the first branch i.e. the boolean expression where the user type &#8220;Yes&#8221; &#8211; we&#8217;ll introduce the concept of loops now. Remember, the program should display all exercises, according to the question presented to the user </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: for loop.</em></label></p>
<pre class="src src-python" id="for loop"><span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Would you like to see all exercises in the training schedule? (Yes/No) '</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> response == <span style="color: #008000;">"Yes"</span>:
  <span style="color: #006FE0;">print</span>(<span style="color: #008000;">"Here are all the exercises:"</span>)
  <span style="color: #0000FF; font-weight: bold;">for</span> exercise <span style="color: #0000FF; font-weight: bold;">in</span> exercises:
    <span style="color: #006FE0;">print</span>(exercise)
</pre>
</div>
<p> Notice the construct: keyword <code>for</code> followed by a variable, followed by keyword <code>in</code> followed by a variable (a list or tuple). </p>
<p> <code>for variable1 in variable2</code> </p>
<p> This tells the program to <b>loop through each element</b> in a data structure (like a list or tuple) and execute the code in the loop for each individual element. For our program, it will print each exercise on a separate line, and the output should look like the following. Run the program and confirm you see the same. </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil">Bench press
Deadlift
Squat
Biceps curl
</pre>
</div>
<p> On each iteration <code>print(exercise)</code> works because <code>exercise</code> is <i>bound</i> or assigned the value from the tuple, one value at a time. </p>
<p> In this example: </p>
<ol class="org-ol">
<li><b>Starting the loop</b>: <code>for exercise in exercises</code> means that Python starts going through each element in <code>exercises</code>.</li>
<li><b>Assignment</b> of <code>exercise</code> : For each iteration (loop), <code>exercise</code> becomes the name of one exercise in turn, from &#8216;Bench press&#8217; to &#8216;Biceps curl.&#8217;</li>
<li><b>Executing instructions</b>: The code in the loop, <code>print(exercise)</code>, is executed each time the loop repeats. So each exercise is printed on its own line.</li>
</ol>
<p> Insert another statement inside the for-loop block, right above <code>print(exercises)</code> and see the result. Don&#8217;t forget to add same indentation. </p>
</div>
<div id="outline-container-org9ec53e4" class="outline-3">
<h3 id="org9ec53e4">How many iterations does the loop run?</h3>
<div class="outline-text-3" id="text-org9ec53e4">
<p> It depends on the number of elements in the list – the purpose of a <code>for</code> loop is to go through all the elements in the list. The answer is <code>len(exercises)</code>, try printing it after the loop. </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #006FE0;">print</span>(<span style="color: #008000;">"The length of exercises is "</span>, <span style="color: #006FE0;">len</span>(exercises))
</pre>
</div>
<p> Alternatively, imagine if you had a really long list, you&#8217;d have to print each exercise on its own line. Something that would become cumbersome quickly. </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: inefficient code.</em></label></p>
<pre class="src src-python" id="inefficient code"><span style="color: #0000FF; font-weight: bold;">if</span> response == <span style="color: #008000;">'Yes'</span>:
    <span style="color: #006FE0;">print</span>(exercises[0])
    <span style="color: #006FE0;">print</span>(exercises[1])
    <span style="color: #006FE0;">print</span>(exercises[2])
    <span style="color: #006FE0;">print</span>(exercises[3])
</pre>
</div>
<p> Now you see the purpose of the the for loop to handle the list (or tuple) efficiently. So, if we had 10 exercises, the for loop wouldn&#8217;t change at all. However, you&#8217;d have to add 6 more rows of <code>print</code>, which one is better? </p>
<p> <i>Remember</i> a <code>for</code>-loop in Python is a powerful tool for repeating instructions multiple times – perfect for lists and other collections. Using <code>for</code>-loops, we can work efficiently with collections of data and make the program more flexible. Feel free to add your own instructions inside the loop to experiment with how you can handle each element in a list. </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: complete for-loop.</em></label></p>
<pre class="src src-python" id="complete for-loop"><span style="color: #0000FF; font-weight: bold;">if</span> response == <span style="color: #008000;">'Yes'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Here are all the exercises:'</span>)
    <span style="color: #0000FF; font-weight: bold;">for</span> exercise <span style="color: #0000FF; font-weight: bold;">in</span> exercises:
        <span style="color: #006FE0;">print</span>(exercise)
<span style="color: #0000FF; font-weight: bold;">elif</span> response == <span style="color: #008000;">'No'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Okay, we won&#8217;t show any exercises right now.'</span>)
<span style="color: #0000FF; font-weight: bold;">else</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Invalid response, please type "Yes" or "No".'</span>)
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-orge45e977" class="outline-2">
<h2 id="orge45e977">Use the operator &#8220;in&#8221;</h2>
<div class="outline-text-2" id="text-orge45e977">
<p> Python has a neat operator we can use called <code>in</code>. Let&#8217;s demonstrate how to use it in our program. Extend the program by adding a new question asking the user which exercise details to display. In programming terms, we want to <i>search</i> the tuple <code>exercises</code> for a <i>value</i>, namely the exercise the user type into the program dialogue. </p>
<p> As a result, we’ll just print a generic message for each exercise. Add the following after the code above: </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #BA36A5;">selected_exercise</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Which exercise would you like to know more about? '</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> selected_exercise <span style="color: #0000FF; font-weight: bold;">in</span> exercises:
    <span style="color: #006FE0;">print</span>(f<span style="color: #008000;">'You chose </span>{selected_exercise}<span style="color: #008000;">. This is a fundamental exercise for building strength.'</span>)
<span style="color: #0000FF; font-weight: bold;">else</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'That exercise is not in the schedule.'</span>)
</pre>
</div>
<p> Here, we use <code>in</code> to check if the exercise entered by the user exists in <code>exercises</code>. If it does, we display information about the exercise; otherwise, we inform the user that the exercise isn’t in the schedule. </p>
</div>
</div>
<div id="outline-container-org1e02091" class="outline-2">
<h2 id="org1e02091">The complete program code</h2>
<div class="outline-text-2" id="text-org1e02091">
<div class="org-src-container">
<label class="org-src-name"><em> Name: training_app_pt2.py.</em></label></p>
<pre class="src src-python" id="training_app_pt2.py"><span style="color: #BA36A5;">week</span> = 1
<span style="color: #BA36A5;">schedule</span> = <span style="color: #008000;">'Workout A'</span>
<span style="color: #BA36A5;">exercises</span> = (<span style="color: #008000;">'Bench press'</span>, <span style="color: #008000;">'Deadlift'</span>, <span style="color: #008000;">'Squat'</span>, <span style="color: #008000;">'Biceps curl'</span>)

<span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Would you like to see all exercises in the training schedule? (Yes/No) '</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> response == <span style="color: #008000;">'Yes'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Here are all the exercises:'</span>)


<span style="color: #0000FF; font-weight: bold;">elif</span> response == <span style="color: #008000;">'No'</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Okay, we won&#8217;t show any exercises right now.'</span>)
<span style="color: #0000FF; font-weight: bold;">else</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'Invalid response, please type "Yes" or "No".'</span>)

    <span style="color: #BA36A5;">selected_exercise</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Which exercise would you like to know more about? '</span>)

<span style="color: #0000FF; font-weight: bold;">if</span> selected_exercise <span style="color: #0000FF; font-weight: bold;">in</span> exercises:
    <span style="color: #006FE0;">print</span>(f<span style="color: #008000;">'You chose </span>{selected_exercise}<span style="color: #008000;">. This is a fundamental exercise for building strength.'</span>)
<span style="color: #0000FF; font-weight: bold;">else</span>:
    <span style="color: #006FE0;">print</span>(<span style="color: #008000;">'That exercise is not in the schedule.'</span>)

</pre>
</div>
</div>
</div>
<div id="outline-container-orgb679828" class="outline-2">
<h2 id="orgb679828">Exercises</h2>
<div class="outline-text-2" id="text-orgb679828">
<ol class="org-ol">
<li>Extend the <code>exercises</code> tuple with more exercises.</li>
<li>Improve the exercise details, by creating a different messages for each exercise. You&#8217;d need to write an if-statements inside an if-statement.</li>
<li>Extend the if-statement to for the word No, with both uppercase and lowercase &#8220;N&#8221;. The user should be able to enter either &#8220;no&#8221; or &#8220;No&#8221;.</li>
<li>Extend the if-statement in previous exercise to allow more alternatives, e.g. &#8220;Nope&#8221;, &#8220;Nah&#8221; or whatever you can think of.</li>
<li>In the next part, we’ll use a <b>dictionary</b> to store descriptions for each exercise in a cleaner way.</li>
<li>Another loop is the while-loop, go to docs.python.org to find out more about it. Use the function <code>len()</code> to determine the condition.</li>
</ol>
</div>
</div>
<div id="outline-container-org8b6e642" class="outline-2">
<h2 id="org8b6e642">Terminology</h2>
<div class="outline-text-2" id="text-org8b6e642">
<p> Review these terms </p>
<ul class="org-ul">
<li>tuple</li>
<li>list</li>
<li>if-statement</li>
<li>for-loop</li>
<li>boolean expression</li>
</ul>
</div>
</div>
<div id="outline-container-org81d7ad2" class="outline-2">
<h2 id="org81d7ad2">Summary</h2>
<div class="outline-text-2" id="text-org81d7ad2">
<p> In this part, you’ve seen how to use the <code>if</code>-statements in order to handle different scenarios in your program. It allow your program to become more interactive, but also handle things in the code to work according to your plan. Being able to create different options and decision paths in a program is an important part of programming. It makes your programs more dynamic and user-friendly. </p>
<p> In the next part, we’ll dive deeper into working with <b>loops</b> and explore <b>dictionaries</b>. </p>
<p> If you&#8217;ve missed the previous post, check it out <a href="https://heaplevel.com/?p=450">Python if-statements &#8211; beginning the training app</a> </p>
<p> See you in the next section! </p>
</div>
</div><p>The post <a href="https://heaplevel.com/blog/python-if-statements-and-loops/">Python if-statements and loops – how to be lazy</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python data structures part 1 &#8211; a look at variables and lists</title>
		<link>https://heaplevel.com/blog/python-data-structures-part-1-a-look-at-variables-and-lists/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Sun, 05 Jan 2025 23:00:00 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=416</guid>

					<description><![CDATA[<p>An introduction to datastructures in Python, this post takes a look at variables and introduces lists.</p>
<p>The post <a href="https://heaplevel.com/blog/python-data-structures-part-1-a-look-at-variables-and-lists/">Python data structures part 1 – a look at variables and lists</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p> In this post, we will begin to explore the fundamental idea of storing information in a Python program. As a matter of fact, the ideas here can be translated to other languages as well. </p>
<p> We will keep it as practical and non-academic as possible, not too much theory at one time, in order to not make it boring. </p>
<div id="outline-container-orgfd88787" class="outline-2">
<h2 id="orgfd88787">Purpose</h2>
<div class="outline-text-2" id="text-orgfd88787">
<p> The purpose is to become familiar of basic building blocks of programming and Python. Storing information is where it all begins in a computer program, you must start here and understand how to make the best use out of them. </p>
</div>
</div>
<div id="outline-container-org91452b4" class="outline-2">
<h2 id="org91452b4">Goal</h2>
<div class="outline-text-2" id="text-org91452b4">
<p> By the end of this post you can </p>
<ul class="org-ul">
<li>create variables and understand why they are necessary</li>
<li>use variables of different types: primitive single-value variables, tuple and list</li>
<li>start to work on the training app we introduce, and which we&#8217;ll continue to improve over the course</li>
</ul>
</div>
</div>
<div id="outline-container-orgb21888f" class="outline-2">
<h2 id="orgb21888f">Prerequisites</h2>
<div class="outline-text-2" id="text-orgb21888f">
<p> You need to have Python installed and be able to start IDLE to follow along. You should be familiar with how to create modules/script and run a Python script, either from the terminal or the GUI window. </p>
<p> A good starting point is this link: <a href="https://heaplevel.com/?p=337">How To Install Python On Your Computer</a> </p>
</div>
</div>
<div id="outline-container-orgf30ffad" class="outline-2">
<h2 id="orgf30ffad">Python Variables &#8211; how to store information</h2>
<div class="outline-text-2" id="text-orgf30ffad">
<p> Store variables is necessary because a program need to keep track of information while the program is running. The logic in a program is based on logic and information. Since the amount of information is usually more than what the programmer can keep track of in short-term memory, we use variables. </p>
<p> Everyone starts to learn about variables when they write their first computer program. </p>
<p> On a basic level, just remember this: </p>
<ul class="org-ul">
<li>We use variables as storage in our programs</li>
<li>Variables makes the program easier to read</li>
<li>Variables off-load the programmer&#8217;s short-term memory</li>
<li>Variables can contain primitive values like numbers or more complex structures, e.g. like lists of numbers</li>
</ul>
</div>
<div id="outline-container-org84f1373" class="outline-3">
<h3 id="org84f1373">Code Block to copy</h3>
<div class="outline-text-3" id="text-org84f1373">
<p> In this section you&#8217;re expected to copy and run the code. The purpose is to become familiar with the process. Start IDLE or your environment of choice and copy the code block below. </p>
<p> <b>Run the program</b> If you didn&#8217;t encounter any errors, congratulations! You stored your first piece of information in a computer program and should see three lines of output. </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: ex1.py.</em></label></p>
<pre class="src src-python" id="ex1.py"><span style="color: #BA36A5;">name</span> = <span style="color: #008000;">"Karl"</span>
<span style="color: #BA36A5;">direction</span> = <span style="color: #008000;">"North"</span>
<span style="color: #BA36A5;">cost</span> = 200
<span style="color: #006FE0;">print</span>(name)
<span style="color: #006FE0;">print</span>(direction)
<span style="color: #006FE0;">print</span>(cost)
</pre>
</div>
<p> The three lines in the output correspond to the three variables: <code>name, direction, cost</code>. These are three <b>different</b> variables, each storing a different type of information. </p>
<p> When you write something within quotation marks, it’s called a &#8220;string&#8221;, as in the examples &#8220;Karl&#8221; or &#8220;North&#8221;. It&#8217;s just a piece of text basically, but it&#8217;s important to know the correct terminology. </p>
<p> The variable <code>cost</code>, on the other hand, contains a number (integer). </p>
<p> You must remember the following: a variable has a <b>value</b> and a <b>data type</b>. </p>
<p> So far, the data types we&#8217;ve seen are <code>string</code> and <code>integer</code>, other types we will encounter later on. </p>
</div>
</div>
</div>
<div id="outline-container-org94f2d2b" class="outline-2">
<h2 id="org94f2d2b">Project &#8211; Introducing the Workout App</h2>
<div class="outline-text-2" id="text-org94f2d2b">
<p> In order to enhance learning, we will introduce the project for managing workout programs. </p>
<p> Here we will lay the foundation for the program by reusing our knowledge of variables in a real project. </p>
<p> For now, we will focus on tracking which exercises to perform, how many times you’ll train per week, and similar tasks. </p>
<p> Here’s how you can start building the foundation for a real app to create a workout schedule, we will introduce the <code>tuple</code> now. </p>
</div>
<div id="outline-container-org89d5484" class="outline-3">
<h3 id="org89d5484">Run the program</h3>
<div class="outline-text-3" id="text-org89d5484">
<p> Copy the code into IDLE in a new script and run the program. Print the <b>variable</b> <code>exercises</code> by using the <code>print()</code> function, as we did above. </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: workout.py.</em></label></p>
<pre class="src src-python" id="workout.py"><span style="color: #BA36A5;">week</span> = 1
<span style="color: #BA36A5;">schedule</span> = <span style="color: #008000;">'Workout A'</span>
<span style="color: #BA36A5;">exercises</span> = (<span style="color: #008000;">'Bench press'</span>, <span style="color: #008000;">'Deadlift'</span>, <span style="color: #008000;">'Squat'</span>, <span style="color: #008000;">'Biceps curl'</span>)
</pre>
</div>
<p> The only new construct here is the line containing the variable <code>exercises</code>. The right-hand side is a data structure called a <b>tuple</b>. The <b>tuple</b> contains four elements, one for each exercise name. We are still only using variables, pretty cool huh?! </p>
<p> <b>Question: how many exercises should I have?</b> Answer: there’s no limit to how many elements you can have, except for your computer’s capacity, of course. </p>
<p> Now this is enough to consider it a small program, it is similar to a &#8220;post-it&#8221; note, however since this is programming, we can extend this in a more dynamic fashion as we move along, and we&#8217;ll see how quickly this will be useful. </p>
<p> Let&#8217;s agree to still call this our minimal program for a Workout App &#8211; name it whatever you&#8217;d like! Our schedule for week 1 is simple and it&#8217;s a program that hold three variables: <b>week, schedule, exercises</b> </p>
</div>
</div>
</div>
<div id="outline-container-org5d48b1b" class="outline-2">
<h2 id="org5d48b1b">Exercises</h2>
<div class="outline-text-2" id="text-org5d48b1b">
<ol class="org-ol">
<li>Add a variable <code>frequency</code> that indicates how many times per week you train. Remember, you only have four exercises, a valid value could be something between 1–4—you decide!</li>
<li>Add new line containing the <code>input</code> function, see code block below. This allows the user to enter a response to the program. Run the program, enter a response, and press Enter. What do you see?</li>
<li>Add a new question to the user, again use <code>input</code> with the question: <i>Which exercise do you want to know more about?</i>. Print the result (the value) from that input. You can use the code block below, remember to change the content between the quotation marks only.</li>
</ol>
<p> Use this code block where the exercise asks for it </p>
<div class="org-src-container">
<label class="org-src-name"><em> Name: code for exercise 2,3.</em></label></p>
<pre class="src src-python" id="code for exercise 2,3"><span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Do you want to see all the exercises in the workout plan?'</span>)
<span style="color: #006FE0;">print</span>(response)
</pre>
</div>
<p> When the program runs, it will pause and wait for the user’s input, i.e. press a key. If you don’t press a key, the program could wait indefinitely. So try pressing Enter and see the program finish. In the code, we&#8217;ve added a variable <code>response</code> to the left of the <code>input</code> expression. </p>
</div>
</div>
<div id="outline-container-org090292b" class="outline-2">
<h2 id="org090292b">A note on return values</h2>
<div class="outline-text-2" id="text-org090292b">
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #BA36A5;">week</span> = 1
<span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Do you want to see all the exercises in the workout plan?'</span>)
</pre>
</div>
<p> If we compare these two right-hand sides, `1` is called a constant value, and something we as the programmer have assigned to the variable <code>week</code>. </p>
<p> What we need to understand is that <code>input</code> will generate a value, technically it&#8217;s the <i>return value</i> of the function. While it doesn’t appear as a number in the code, it will guarantee a value will be be stored in a variable <code>response</code>. </p>
<p> <i>The return value of input will be stored in the variable response</i>. Remember this! </p>
<p> Since we cannot see the value, it&#8217;s up to the programmer to either further examine the value or leave it as is. As part of this learning, we decide to print the value. </p>
<p> For now and for a good while ahead, it’s enough to understand and assume that what stands to the right of the equal sign must be an expression that results in a value. </p>
</div>
</div>
<div id="outline-container-orge137d4b" class="outline-2">
<h2 id="orge137d4b">A note about functions in programming</h2>
<div class="outline-text-2" id="text-orge137d4b">
<p> You&#8217;ve used <code>input</code> and <code>print</code> as part of Python. Both are called a <b>built-in Python function</b>. Their purpose is to handle communication between the user and the program, they help make the program interactive. </p>
<p> <b>Functions are packaged solutions to common problems for a programmer</b> &#8211; as matter of fact, they exist in all languages. </p>
<p> Relying on built-in Python functions can take you a long way, and later we will write our own functions too. </p>
<p> Imagine a carpenter cutting a piece of wood, that could be done with a common tool such as a saw (function). An electric saw would be even better, both are examples of functionality the carpenter can use to help him perform his task. Both are better than trying to cut the piece with bare hands only. </p>
<p> Likewise, the reason <code>print</code> and <code>input</code> are built-in functions is that it&#8217;s complex enough for the programmer to handle how a computer &#8220;communicates&#8221; with a user under-the-hood, and it would be a waste of time to program that logic yourself. Functions hide complex logic in a simple format so that the programmer can have a more enjoyable and easier life. </p>
<p> This principle is called <b>abstraction</b> and something we will explore later. </p>
</div>
</div>
<div id="outline-container-org2f5d682" class="outline-2">
<h2 id="org2f5d682">The complete program code</h2>
<div class="outline-text-2" id="text-org2f5d682">
<div class="org-src-container">
<label class="org-src-name"><em> Name: workout.py.</em></label></p>
<pre class="src src-python" id="workout.py"><span style="color: #BA36A5;">week</span> = 1
<span style="color: #BA36A5;">schedule</span> = <span style="color: #008000;">'Workout A'</span>
<span style="color: #BA36A5;">exercises</span> = (<span style="color: #008000;">'Bench press'</span>, <span style="color: #008000;">'Deadlift'</span>, <span style="color: #008000;">'Squat'</span>, <span style="color: #008000;">'Biceps curl'</span>)

<span style="color: #BA36A5;">response</span> = <span style="color: #006FE0;">input</span>(<span style="color: #008000;">'Do you want to see all the exercises in the workout plan? (Yes/No)'</span>)
<span style="color: #006FE0;">print</span>(response)  <span style="color: #8D8D84;"># </span><span style="color: #8D8D84; font-style: italic;">Prints the user&#8217;s response</span>
</pre>
</div>
<p> The program flow is </p>
<ol class="org-ol">
<li>The program asks the user if it wants to view all the exercises of the workout plan</li>
<li>The user answers the question</li>
<li>The program stores the response (return value) from the function in the variable <code>response</code>.</li>
</ol>
</div>
</div>
<div id="outline-container-orge736062" class="outline-2">
<h2 id="orge736062">Reflections</h2>
<div class="outline-text-2" id="text-orge736062">
<p> When we build a program, it&#8217;s normal to think about the relevant questions needed for the program to function the way you want. This will be a recurring theme in your job as a programmer, it&#8217;s important to have an idea and work towards that. It’s important to think this way early to avoid building the &#8220;wrong&#8221; program, or rather to build the program that suits the user as best as possible. </p>
<p> Remember, we haven’t been precise about what a workout plan should look like, so you must decide  how the program should be used as well. This is called requirements analysis in industry language. Translating requirements into code is a <b>major part</b> of writing good programs. The best way to learn is to do it with a real project in mind, that&#8217;s the motivation we start with examples early on. </p>
</div>
</div>
<div id="outline-container-org692fa53" class="outline-2">
<h2 id="org692fa53">Terminology</h2>
<div class="outline-text-2" id="text-org692fa53">
<p> Review these terms </p>
<ul class="org-ul">
<li>string</li>
<li>functions</li>
<li>abstraction</li>
<li>tuple</li>
<li>variable</li>
<li>return value</li>
</ul>
</div>
</div>
<div id="outline-container-org94f45b5" class="outline-2">
<h2 id="org94f45b5">Summary</h2>
<div class="outline-text-2" id="text-org94f45b5">
<p> In this section, we’ve gone through concepts that can be used to build many different programs. You’ve practiced Python’s built-in <b>functions</b> and saved information in a program. </p>
<p> We have also gone through a simplified process for how a program can be developed. We started with an introductory text and expanded it in several steps by asking the user a question. We also printed the user’s response. This is how programming begins—different parts evolve at different pace. </p>
<p> It’s not easy to do everything at once, so it’s good to think of this process as normal. If someone wants to do everything at once, avoid these personalities at work (hah). </p>
<p> In the next section, we’ll see how to control the flow of a program in different ways and use more Python functions to read text files. </p>
<p> Do you have any ideas right now of how you want to develop your program? After the user enters a response, you can, for example, make the program more user-friendly and ask for details about an exercise. </p>
<p> See you in the next section! </p>
</div>
</div><p>The post <a href="https://heaplevel.com/blog/python-data-structures-part-1-a-look-at-variables-and-lists/">Python data structures part 1 – a look at variables and lists</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How To Install Python On Your Computer</title>
		<link>https://heaplevel.com/blog/how-to-install-python-on-your-computer/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Sat, 14 Dec 2024 08:48:05 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=337</guid>

					<description><![CDATA[<p>Installing or updating Python can sometimes be a little tricky and it&#8217;s confusing to understand which version is actually installed. Don&#8217;t worry in this tutorial we show you how to handle that. One of the downsides of Python is setting up the environment in a correct way and the fact that there are a multitude &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/how-to-install-python-on-your-computer/" class="more-link">Continue reading<span class="screen-reader-text"> "How To Install Python On Your Computer"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/how-to-install-python-on-your-computer/">How To Install Python On Your Computer</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Installing or updating Python can sometimes be a little tricky and it&#8217;s confusing to understand which version is actually installed. Don&#8217;t worry in this tutorial we show you how to handle that. One of the downsides of Python is setting up the environment in a correct way and the fact that there are a multitude of installation methods can make the beginner unsure about which Python version is installed. </p>



<p>If you install Visual Studio Code it cannot guarantee that your configuration is in the right place when the time comes to code and run your scripts.</p>



<h3 class="wp-block-heading"><mark style="background-color:#005075" class="has-inline-color has-white-color">Common ways to install Python</mark></h3>



<p>You can download official Python distributions from&nbsp;<a href="https://python.org/">Python.org</a>, install from a package manager, and even install specialized distributions for scientific computing, Internet of Things, and embedded systems.&nbsp;</p>



<p>This tutorial focuses on official distributions, as they’re generally the best option for getting started with learning to program in Python.</p>



<p><strong>In this tutorial you’ll learn how to:</strong></p>



<ul class="wp-block-list">
<li>Check which&nbsp;<strong>version</strong>&nbsp;of Python, if any, is installed on your machine</li>



<li>Install or update Python on&nbsp;<strong>Windows</strong>,&nbsp;<strong>macOS</strong>, and&nbsp;<strong>Linux</strong></li>
</ul>



<p>This is different depending on your operating system. There&#8217;s also the option of using Anaconda or even pyenv.</p>



<p>Depending on your use case I&#8217;d recommend different options. </p>



<h3 class="wp-block-heading" id="pythonbeginnerinstall">Install Python as a beginner for the first time</h3>



<p>This method is common for beginners and applies regardless of operating system you are running. The process the most recognizable for newcomers and is highly recommended.</p>



<ol class="wp-block-list">
<li>Go to <a href="http://python.org/downloads">python.org/downloads</a></li>



<li>Select the correct version for your operating system. The site should handle it automatically for you. It will look something like the following </li>
</ol>



<figure class="wp-block-image size-large"><a href="https://heaplevel.com/wp-content/uploads/2024/02/image.png"><img fetchpriority="high" decoding="async" width="1024" height="405" src="https://heaplevel.com/wp-content/uploads/2024/02/image-1024x405.png" alt="" class="wp-image-340" srcset="https://heaplevel.com/wp-content/uploads/2024/02/image-1024x405.png 1024w, https://heaplevel.com/wp-content/uploads/2024/02/image-300x119.png 300w, https://heaplevel.com/wp-content/uploads/2024/02/image-768x304.png 768w, https://heaplevel.com/wp-content/uploads/2024/02/image.png 1224w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>Proceed to installing and following the default instructions of the installer.</p>



<p>If you are on Windows, then go to the Start Menu and search for &#8220;IDLE&#8221;. That should start the default Python interpreter window.</p>



<p>If you are on MacOS then use Spotlight (Command + Space) and search for &#8220;IDLE&#8221;. Or use Finder to go to Applications -&gt; IDLE</p>



<p>If you are on Linux then you probably need to unzip the artifact/package just downloaded, or in the best case the installer is ready made to just double click. </p>



<h3 class="wp-block-heading">If you are using Linux</h3>



<p>If you are following from the <a href="#pythonbeginnerinstall" data-type="internal" data-id="#pythonbeginnerinstall">section </a>above, and you are not able to double click the package, then you must probably unzip the package with a tool like, tar, bunzip, gunzip. </p>



<p>If you&#8217;re diving right into the terminal, lets first of all check which Python version your Linux distribution comes with.</p>



<p>Sometimes you may have <code>python</code>, <code>python2</code> or <code>python3</code> command available, or sometimes all of them. You can check the system Python version as the following</p>



<p><code>$ python --version</code></p>



<p><code>$ python2 --version</code></p>



<p><code>$ python3 --version</code></p>



<p>If any command gives an error, then you don&#8217;t have that version installed.</p>



<p>Easier would be, if you type <code>which python</code> then your terminal will show which binary is executed and linked to that <code>python</code> command &#8212; given that it exists on your system of course.</p>



<p><strong>If you are using Ubuntu</strong> then go ahead and do the following.</p>



<pre class="wp-block-code"><code>$ sudo apt update
$ sudo apt install python3</code></pre>



<p>If the above raises an error, then you need to find which Python-version exists in your package manager and use that when you install. First search for the correct name like this.</p>



<pre class="wp-block-code"><code>$ apt search python</code></pre>



<h3 class="wp-block-heading">If you are using Windows</h3>



<p>Installing on Windows can get a bit complicated, but this guide will hopefully sort things out for you. The most simple method is to go to <a href="http://python.org/downloads">http://python.org/downloads</a> and download the latest Python version for Windows. If you&#8217;re just a beginner then Windows also offers a very simple method through their Microsoft Store. None of these steps below are necessary if you followed the steps in the first section of <a href="#pythonbeginnerinstall" data-type="internal" data-id="#pythonbeginnerinstall">this post</a></p>



<p><strong>Install Python via The Microsoft Store method</strong></p>



<p>Open up Microsoft Store and search for Python. Select the latest version and install it.</p>



<figure class="wp-block-image size-large"><a href="https://heaplevel.com/wp-content/uploads/2024/03/image-4.png"><img decoding="async" width="1024" height="322" src="https://heaplevel.com/wp-content/uploads/2024/03/image-4-1024x322.png" alt="" class="wp-image-348" srcset="https://heaplevel.com/wp-content/uploads/2024/03/image-4-1024x322.png 1024w, https://heaplevel.com/wp-content/uploads/2024/03/image-4-300x94.png 300w, https://heaplevel.com/wp-content/uploads/2024/03/image-4-768x242.png 768w, https://heaplevel.com/wp-content/uploads/2024/03/image-4-1536x484.png 1536w, https://heaplevel.com/wp-content/uploads/2024/03/image-4-1568x494.png 1568w, https://heaplevel.com/wp-content/uploads/2024/03/image-4.png 1855w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p><strong>Do you already have a Python version installed?</strong></p>



<ol class="wp-block-list">
<li>Open Powershell by going to Start menu</li>



<li>Type in PowerShell, see screenshot</li>



<li>Type the following in the new PowerShell window: <code>python --version</code></li>
</ol>



<p>If you don&#8217;t get an error from the last step, then you should see the Python version installed on your Windows system. In this case you don&#8217;t need to do anything more.</p>



<p></p>



<p><strong>Step 1</strong> &#8211; Locate and open PowerShell</p>



<figure class="wp-block-image size-full"><a href="https://heaplevel.com/wp-content/uploads/2024/03/image-1.png"><img decoding="async" width="615" height="669" src="https://heaplevel.com/wp-content/uploads/2024/03/image-1.png" alt="" class="wp-image-345" srcset="https://heaplevel.com/wp-content/uploads/2024/03/image-1.png 615w, https://heaplevel.com/wp-content/uploads/2024/03/image-1-276x300.png 276w" sizes="(max-width: 615px) 100vw, 615px" /></a></figure>



<p><strong>Step 2</strong> &#8211; Check Python version if it&#8217;s installed</p>



<figure class="wp-block-image size-full"><a href="https://heaplevel.com/wp-content/uploads/2024/03/image-2.png"><img loading="lazy" decoding="async" width="854" height="227" src="https://heaplevel.com/wp-content/uploads/2024/03/image-2.png" alt="" class="wp-image-346" srcset="https://heaplevel.com/wp-content/uploads/2024/03/image-2.png 854w, https://heaplevel.com/wp-content/uploads/2024/03/image-2-300x80.png 300w, https://heaplevel.com/wp-content/uploads/2024/03/image-2-768x204.png 768w" sizes="auto, (max-width: 854px) 100vw, 854px" /></a></figure>



<p><strong>Step 3</strong> &#8211; Decide installation method</p>



<p>If you don&#8217;t have Python installed already then go ahead and either download Python from the official website or the Microsoft Store</p>



<p><strong>Step 4 &#8211; </strong>Open up IDLE</p>



<p>This step is the same as earlier, you can start the IDLE program by going to the Start menu and typing &#8220;IDLE&#8221; like the screenshot below. You see that I have several versions of Python installed at the same time, this is not a problem at all. </p>



<figure class="wp-block-image size-large"><a href="https://heaplevel.com/wp-content/uploads/2024/12/image.png"><img loading="lazy" decoding="async" width="1024" height="888" src="https://heaplevel.com/wp-content/uploads/2024/12/image-1024x888.png" alt="" class="wp-image-401" srcset="https://heaplevel.com/wp-content/uploads/2024/12/image-1024x888.png 1024w, https://heaplevel.com/wp-content/uploads/2024/12/image-300x260.png 300w, https://heaplevel.com/wp-content/uploads/2024/12/image-768x666.png 768w, https://heaplevel.com/wp-content/uploads/2024/12/image.png 1170w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<h3 class="wp-block-heading">EXTRA &#8211; Try online editors for Python</h3>



<p>You can also try to experiment with Python without installing anything on your computer. Click the following site for example</p>



<p><a href="https://www.python.org/shell/">https://www.python.org/shell/</a><br><a href="http://repl.it">https://repl.it</a> &#8211; advanced</p>



<p></p><p>The post <a href="https://heaplevel.com/blog/how-to-install-python-on-your-computer/">How To Install Python On Your Computer</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python and the Building Blocks of Programming</title>
		<link>https://heaplevel.com/blog/python-and-the-building-blocks-of-programming/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Sat, 29 Jun 2024 22:00:00 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=393</guid>

					<description><![CDATA[<p>Table of Contents Python and the Building Blocks of Programming Goals of This Post Series Building Blocks of a Program Examples of how building blocks are used Building block 1 &#8211; Variables Exercise Python and the Building Blocks of Programming Goals of This Post Series You will learn the anatomy of a program and what &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/python-and-the-building-blocks-of-programming/" class="more-link">Continue reading<span class="screen-reader-text"> "Python and the Building Blocks of Programming"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/python-and-the-building-blocks-of-programming/">Python and the Building Blocks of Programming</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#orgc3918b5">Python and the Building Blocks of Programming</a>
<ul>
<li><a href="#org5a963ad">Goals of This Post Series</a></li>
<li><a href="#orgbe9549a">Building Blocks of a Program</a></li>
<li><a href="#org73e47e4">Examples of how building blocks are used</a></li>
<li><a href="#orgc3ba110">Building block 1 &#8211; Variables</a></li>
<li><a href="#org3fb732d">Exercise</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="outline-container-orgc3918b5" class="outline-2">
<h2 id="orgc3918b5">Python and the Building Blocks of Programming</h2>
<div class="outline-text-2" id="text-orgc3918b5">
</div>
<div id="outline-container-org5a963ad" class="outline-3">
<h3 id="org5a963ad">Goals of This Post Series</h3>
<div class="outline-text-3" id="text-org5a963ad">
<ul class="org-ul">
<li>You will learn the anatomy of a program and what a typical Python program consists of.</li>
<li>Introduce variables, data structures and functions as basic building blocks of a program</li>
<li>Introduce classes and objects as <i>advanced</i> building blocks of a program.</li>
</ul>
<p> Each building blocks can be used in different ways, and not all of them are required in a single program. Using these blocks, we can gradually construct our program in different ways until we achieve the desired functionality. </p>
<p> By the end of this post, you will have a first introduction of what constitutes a basic Python program by understanding what variables are. </p>
<p> In the next post you will be able to create interactive dialogues with users and store information in variables and data structures. </p>
<p> <b>Data handling</b> is a fundamental of any program so it&#8217;s important to understand this early on. </p>
</div>
</div>
<div id="outline-container-orgbe9549a" class="outline-3">
<h3 id="orgbe9549a">Building Blocks of a Program</h3>
<div class="outline-text-3" id="text-orgbe9549a">
<p> Every program is made up of one or more building blocks. We will explore all of them in a series of posts in this blog. </p>
<ul class="org-ul">
<li>Variables</li>
<li>Data Structures</li>
<li>Functions</li>
<li>Classes</li>
</ul>
<div id="org3f7ecb5" class="figure">
<p><img decoding="async" src="https://heaplevel.com/wp-content/uploads/2025/01/programming_building_blocks_blog.jpg" alt="programming_building_blocks_blog.jpg" /> </p>
</p></div>
</div>
</div>
<div id="outline-container-org73e47e4" class="outline-3">
<h3 id="org73e47e4">Examples of how building blocks are used</h3>
<div class="outline-text-3" id="text-org73e47e4">
<p> Each building block serves a specific purpose, categorized into storing information (data) or processing it. </p>
<p> Examples of processing information could be: </p>
<ul class="org-ul">
<li>Calculating VAT given a price.</li>
<li>Determining loan costs based on loan amount and interest rate.</li>
<li>Extracting parts of speech (e.g., verbs, nouns) from a long text or simply calculating the text&#8217;s length.</li>
<li>Calculating age based on a birthdate.</li>
</ul>
<p> Examples of holding (storing) information could be: </p>
<ul class="org-ul">
<li>Storing personal details throughout a program</li>
<li>Storing account balance</li>
<li>Storing textual information about a book or news site</li>
</ul>
<p> Here&#8217;s an example of some building blocks in a program, feel free to try it out in your Python environment. </p>
<p> Have you not installed Python yet? Check out the simple guide we have </p>
<p> <a href="https://heaplevel.com/?p=337">How To Install Python On Your Computer</a> </p>
</div>
</div>
<div id="outline-container-orgc3ba110" class="outline-3">
<h3 id="orgc3ba110">Building block 1 &#8211; Variables</h3>
<div class="outline-text-3" id="text-orgc3ba110">
<p> For the examples in this post, it&#8217;s sufficient to write them in IDLE. However, if you are already familiar or prefer VSCode, PyCharm or another editor, feel free to do so. </p>
<p> Each file you create are called a <i>module</i>. You may encounter both when you read online resources. </p>
<p> To create a new file in IDLE, go to <b>File -&gt; New File</b>. Name the new file <code>building_blocks_ex1.py</code>. </p>
<div id="orgff54be8" class="figure">
<p><img decoding="async" src="https://heaplevel.com/wp-content/uploads/2025/01/idle_newfile.jpg" alt="idle_newfile.JPG" /> </p>
</p></div>
<p> You will see an empty window where you can write your code. Paste the following code and then go to <b>Run -&gt; Run Module</b>. </p>
<div class="org-src-container">
<label class="org-src-name"><em></em></label></p>
<pre class="src src-python" id="nil"><span style="color: #4eee94;">name</span> = <span style="color: #deb887;">'Karl'</span>
<span style="color: #4eee94;">direction</span> = <span style="color: #deb887;">'North'</span>
<span style="color: #4eee94;">cost</span> = 200
<span style="color: #f08080;">print</span>(name)
<span style="color: #f08080;">print</span>(direction)
<span style="color: #f08080;">print</span>(cost)
</pre>
</div>
<p> The example above demonstrates a short program showcasing variables, assignment, and output. The left hand side is the variable name and the right hand side is the value assigned to that variable. </p>
<p> A variable is a container to store data in your program. </p>
<p> Python has many built-in functions that we will use, one of them is the useful <code>print()</code>. That will output to your window the result of each variable we created: name, direction and cost. </p>
</div>
</div>
<div id="outline-container-org3fb732d" class="outline-3">
<h3 id="org3fb732d">Exercise</h3>
<div class="outline-text-3" id="text-org3fb732d">
<p> Practice writing your own variables. Notice the following </p>
<ul class="org-ul">
<li>What happens if you change single quote to double quotes?</li>
<li>Can you change cost to something other than a number? Like a name?</li>
<li>Create a new variable and name it, e.g. salary, age, points &#8211; use your imagination!</li>
<li>Print the newly created variable(s).</li>
<li>What happen if you combine the <code>print</code> like so print(name, direction, cost)?</li>
</ul>
<p> This was a short introduction to <code>variables</code> and already in the next post we will build on this to interact with a user. </p>
</div>
</div>
</div><p>The post <a href="https://heaplevel.com/blog/python-and-the-building-blocks-of-programming/">Python and the Building Blocks of Programming</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Host your Discord Bot &#8211; 3 popular options</title>
		<link>https://heaplevel.com/blog/3-ways-to-setup-a-discord-bot-on-your-server/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Tue, 13 Apr 2021 12:06:21 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[discord]]></category>
		<category><![CDATA[discord bot]]></category>
		<category><![CDATA[guide]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=291</guid>

					<description><![CDATA[<p>Having your own Discord Bot can be a nice way of adding a custom experience to your users on the server. In order to host your Discord bot, a maintainer has a couple of options to look at before deciding which is the right one. Along the way, there are also a couple of things &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/3-ways-to-setup-a-discord-bot-on-your-server/" class="more-link">Continue reading<span class="screen-reader-text"> "Host your Discord Bot &#8211; 3 popular options"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/3-ways-to-setup-a-discord-bot-on-your-server/">Host your Discord Bot – 3 popular options</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Having your own Discord Bot can be a nice way of adding a custom experience to your users on the server. In order to host your Discord bot, a maintainer has a couple of options to look at before deciding which is the right one. Along the way, there are also a couple of things to take into consideration when you want to host a Discord Bot on your server. You can first of course look if your needs are met by a bot from <a href="https://top.gg/" target="_blank" rel="noreferrer noopener">https://top.gg/</a>. Otherwise you can write your own and for that there are more things to consider.</p>



<h3 class="wp-block-heading">What to Consider </h3>



<ul class="wp-block-list">
<li>Which language is the bot written in?</li>



<li>How do you want to host it? What matters to you?
<ul class="wp-block-list">
<li>personal support</li>



<li>uptime</li>



<li>monitoring</li>
</ul>
</li>
</ul>



<p>There are popular languages to write your bot in, some of the popular are</p>



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



<li>Python</li>



<li>NodeJS.</li>
</ul>



<h2 class="wp-block-heading">Host options for a Discord Bot</h2>



<p>The common ways to setup a Discord Bot can be</p>



<ul class="wp-block-list">
<li>VPS on your own</li>



<li>External hosting provider, in fact that&#8217;s exactly what we can help you with. Check out our process and pipeline for deploying the Heaplevel Discord bot <a data-type="post" data-id="302" href="https://heaplevel.com/blog/how-we-deploy-our-discord-bot/" target="_blank" rel="noreferrer noopener">here</a>.</li>



<li>Locally on your desktop</li>
</ul>



<p>Let&#8217;s start with the first one VPS. How is the process to get the bot up and running usually? </p>



<h2 class="wp-block-heading">Discord Bot Hosted on a VPS</h2>



<ol class="wp-block-list">
<li>Setup VPS by registering a new account at a hosting provider</li>



<li>Login to the VPS and access the terminal</li>



<li>Install the programming environment necessary. This depends on which language you have written your bot in. It could be Python, NodeJS, Java or anything else.</li>



<li>The code. You need a way to transfer the code to the actual VPS machine. Either it&#8217;s on a code repository like Github or Bitbucket. Or you can transfer it via some UI file manager. Check with your provider. </li>



<li>When you have the code locally, it&#8217;s smart to test run it. this step verifies that you have all the necessary tools for your bot to run. How you do that depends on your code base again. This is probably something you&#8217;ve already tried when developing the code locally on your own desktop machine. </li>



<li>If you have verified the code works then it&#8217;s time to setup the code to run your server. You can either run your main file as a standalone process, setup a cronjob or write a containerized version of it (link to Docker article &#8211; How to run a Docker discord bot).</li>



<li>This step is ususally skipped but if you have the chance to monitor the resource usage on the server it&#8217;s a major plus.</li>



<li>Handle updates to the code</li>



<li>Handle bot crashes &#8211; due to usage utilization or anything else</li>
</ol>



<p>With these things we can also support you if you run into problems. </p>



<h2 class="wp-block-heading">Discord Bot hosted on a external hosting provider</h2>



<p>While the registration part is usually the same as for VPS, the real advantage is that an external hosting provider will provide you with an interface for uploading your code and run it. Usually there is an amount of support included in your account. A good hosting provider will allow you to just point to a repository on GitHub or BitBucket for example instead of you manually uploading the files to the server. </p>



<p>The steps are usually</p>



<ol class="wp-block-list">
<li>Register your account with the Discord bot hosting provider</li>



<li>Upload your files </li>



<li>Start the bot through the provider&#8217;s integrated interface</li>
</ol>



<h2 class="wp-block-heading">Discord Bot locally on your desktop</h2>



<p>Let&#8217;s say you have a little desktop machine laying there without a purpose, you can use it as your local little server. This scenario can look different depending on your setup. But it&#8217;s closest to preparing your VPS for Discord Bot. You will need the following</p>



<ol class="wp-block-list">
<li>Development environment for the language the bot is written in</li>



<li>Some scheduling and monitoring mechanism if the Discord bot will crash. </li>



<li>If you are sure that everything is complete, then you can run the bot through the development environment on the desktop computer.</li>
</ol>



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



<p>We have looked at different options for setting up your Discord Bot. While they look similar, the decision boils down to what&#8217;s important for you. The requirements you have will differ to somebody else. Some are happy with no support from their provider while others are happy to outsource that task to someone else. You still need a fair amount of knowledge to setup the Discord bot on the underlying system, usually in Linux you require a little more experience. </p>



<p>If you find yourself in need of discussing this with us then it&#8217;s something we can provide support for. Even if you have support from your provider, drop us an email. </p>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-fill"><a class="wp-block-button__link wp-element-button" href="https://heaplevel.com/hosting-your-discord-bot/" target="_blank" rel="noreferrer noopener">I Need Help With My Discord Bot</a></div>
</div><p>The post <a href="https://heaplevel.com/blog/3-ways-to-setup-a-discord-bot-on-your-server/">Host your Discord Bot – 3 popular options</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to open a file in Python in different modes</title>
		<link>https://heaplevel.com/blog/how-to-open-a-file-in-python-in-different-modes/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Fri, 16 Aug 2019 06:51:48 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=94</guid>

					<description><![CDATA[<p>Opening a file in Python is really simple. How do you create a file though that doesn&#8217;t exist? If you use the open function in Python like so You&#8217;ll run into the error Mode for open a file We need to understand that opening a file can be followed by a mode parameter, the signature &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/how-to-open-a-file-in-python-in-different-modes/" class="more-link">Continue reading<span class="screen-reader-text"> "How to open a file in Python in different modes"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/how-to-open-a-file-in-python-in-different-modes/">How to open a file in Python in different modes</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Opening a file in Python is really simple. How do you create a file though that doesn&#8217;t exist?</p>



<p>If you use the <em>open</em> function in Python like so</p>



<pre class="wp-block-code"><code>open('file.txt')</code></pre>



<p>You&#8217;ll run into the error</p>



<pre class="wp-block-code"><code>FileNotFoundError: [Errno 2] No such file or directory: 'file.txt'</code></pre>



<h2 class="wp-block-heading">Mode for open a file</h2>



<p>We need to understand that opening a file can be followed by a mode parameter, the signature for the function is <em>open(file, mode)</em>. </p>



<p>If you only submit the filename the default mode is set to &#8216;read&#8217; mode. Which only makes sense if the file exists. Here are the other modes </p>



<ul class="wp-block-list"><li>r &#8211; open for reading (default)</li><li>t &#8211; text mode (default)</li><li>w &#8211; write mode</li><li>a &#8211; append mode</li><li>x &#8211; open file, failing if the file already exists</li><li>b &#8211; <a href="https://en.wikipedia.org/wiki/Binary_file">binary mode</a></li></ul>



<h2 class="wp-block-heading">Open and create the file</h2>



<p>Referring to the above table, we can use different modes for creating a file for the first time. Depending on our purpose if we want to delete an existing file with the same name or not.</p>



<p>Let&#8217;s try this</p>



<pre class="wp-block-code"><code>file = open('file.txt', 'w')
file.write('First line')
file.close()</code></pre>



<p>Do you want to know more about a Python topic? <a href="https://heaplevel.com/contact-us/">Contact us</a> or leave a comment below :).</p><p>The post <a href="https://heaplevel.com/blog/how-to-open-a-file-in-python-in-different-modes/">How to open a file in Python in different modes</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Getting started with Javascript</title>
		<link>https://heaplevel.com/blog/getting-started-with-javascript/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Thu, 25 Jul 2019 16:59:46 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=75</guid>

					<description><![CDATA[<p>If you want to start programming in Javascript you might ask where do you actually start? It might be that you&#8217;ve been interested in learning more about web programming in general, for which it would be useful to also learn about HTML and CSS as well. While HTML and CSS deal with the structure of &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/getting-started-with-javascript/" class="more-link">Continue reading<span class="screen-reader-text"> "Getting started with Javascript"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/getting-started-with-javascript/">Getting started with Javascript</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>If you want to start programming in Javascript you might ask where do you actually start?</p>



<p>It might be that you&#8217;ve been interested in learning more about web programming in general, for which it would be useful to also learn about <a href="https://simplecodeacademy.heaplevel.com">HTML and CSS</a> as well. While HTML and CSS deal with the structure of a website, Javascript adds the dynamic flavour to your website. </p>



<p>There is also a possibility that you want to learn Javascript to write backend applications, using NodeJS. The applications for Javascript are several, both websites and web applications can use Javascript. </p>



<p>If this is the first time to Javascript you can start by learning about the language itself and start play around in a sandbox environment. That is the best option to learn Javascript. </p>



<h2 class="wp-block-heading">Learn Javascript by examples</h2>



<p>We will experiment with Javascript by looking at some examples. This guide is for you that have a little programming background.</p>



<ol class="wp-block-list"><li>Navigate to <a href="https://jsfiddle.net">JSFiddle</a></li><li>Copy the following code in the HTML box</li><li>Hit the Run button. You should see a popup displaying the text &#8220;Hello, world!&#8221;</li></ol>



<pre class="wp-block-code"><code>&lt;!DOCTYPE HTML>
&lt;html>
&lt;head>
&lt;script>
    alert( 'Hello, world!' );
  &lt;/script>
&lt;/head>
&lt;body>
  The body
&lt;/body>

&lt;/html></code></pre>



<p>So what did we actually do here? Simply explained we used the Javascript function called <em>alert</em> to write a message in a popup box. </p>



<p>Go ahead and create a second alert with a new message. After you hit Run you should have two popup boxes with two different messages.</p>



<p></p>



<p></p><p>The post <a href="https://heaplevel.com/blog/getting-started-with-javascript/">Getting started with Javascript</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to setup Matomo with MariaDB on Docker</title>
		<link>https://heaplevel.com/blog/how-to-setup-matomo-with-mariadb-on-docker/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Tue, 23 Jul 2019 04:02:22 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[mariadb]]></category>
		<category><![CDATA[matomo]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=70</guid>

					<description><![CDATA[<p>This will spin up a Matomo instance on MariaDB running on the default port 3306. You can then access the Matomo instance to continue the installation by navigation to your hostname:3306. E.g. if you&#8217;re running this on your VPS it will be your http://&#60;VPS IP>:3306 http://localhost:3306 if you&#8217;re on your local dev machine. The above &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/how-to-setup-matomo-with-mariadb-on-docker/" class="more-link">Continue reading<span class="screen-reader-text"> "How to setup Matomo with MariaDB on Docker"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/how-to-setup-matomo-with-mariadb-on-docker/">How to setup Matomo with MariaDB on Docker</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre class="wp-block-code"><code>$ docker run --name matomo-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:latest</code></pre>



<pre class="wp-block-code"><code>$ docker run -d --link matomo-mariadb:db -p 8089:80 -p 3306:3306 matomo</code></pre>



<p>This will spin up a Matomo instance on MariaDB running on the default port 3306. You can then access the Matomo instance to continue the installation by navigation to your hostname:3306. E.g. if you&#8217;re running this on your VPS it will be your http://&lt;VPS IP>:3306</p>



<p>http://localhost:3306 if you&#8217;re on your local dev machine.</p>



<p>The above will not persist your data, in order to do that you need to use volumes on Docker. So if you plan on restarting your Docker container (likely) then you should use volumes. Otherwise when you restart the Docker container you&#8217;ll have to reinstall the Matomo instance.</p>



<pre class="wp-block-code"><code>docker volume create matomo-vol
docker run -d --link matomo-mariadb:db -p 8089:80 -p 3306:3306 -v matomo-vol:/var/www/html matomo
</code></pre>



<p></p><p>The post <a href="https://heaplevel.com/blog/how-to-setup-matomo-with-mariadb-on-docker/">How to setup Matomo with MariaDB on Docker</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Javascript true and false values</title>
		<link>https://heaplevel.com/blog/javascript-true-and-false-values/</link>
		
		<dc:creator><![CDATA[Heaplevel]]></dc:creator>
		<pubDate>Thu, 23 May 2019 09:34:40 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">https://heaplevel.com/?p=41</guid>

					<description><![CDATA[<p>In Javascript comparing values are not always as straightforward as one would expect. Overcoming that fear of which variables are truthy are sometimes is just as easy as learning which values are falsy. If you remember them (6 values) then you can easily know which values are true. NaN false undefined &#8221;, &#8220;&#8221;, &#8220; &#8211; &#8230; </p>
<p class="link-more"><a href="https://heaplevel.com/blog/javascript-true-and-false-values/" class="more-link">Continue reading<span class="screen-reader-text"> "Javascript true and false values"</span></a></p>
<p>The post <a href="https://heaplevel.com/blog/javascript-true-and-false-values/">Javascript true and false values</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>In Javascript comparing values are not always as straightforward as one would expect. Overcoming that fear of which variables are truthy are sometimes is just as easy as learning which values are falsy. If you remember them (6 values) then you can easily know which values are true.</p>



<ul class="wp-block-list"><li>NaN</li><li>false</li><li>undefined</li><li>&#8221;, &#8220;&#8221;, &#8220; &#8211; the empty string either single quotes, double quotes or template literalts</li><li>0</li><li>null</li></ul>



<p>How do you remember these 6 falsy values in Javascript you say? People remember things differently and since all are unique there are many ways to remember. </p>



<p>Remember the simple things first, the one number i.e 0 (zero) is always false. That&#8217;s easy to remember right? Also false makes perfect sense to be&#8230;you guessed it:  false. </p>



<p>So four values to go, look at this: null, NaN, undefined</p>



<p>Finally strings contain text, strings talk, but a string that doesn&#8217;t contain anything can&#8217;t talk, so it should be false.</p>



<p>The perfect order</p>



<ul class="wp-block-list"><li>0</li><li>false</li><li>null &#8211; NaN &#8211; undefined &#8212; becomes nullnandefined &#8211; null (and) undefined. Those are three values coerced into one to remember easily!</li><li>empty strings &#8211; can&#8217;t talk, should be false then. &#8221;, &#8220;&#8221;, &#8220;</li></ul>



<p></p><p>The post <a href="https://heaplevel.com/blog/javascript-true-and-false-values/">Javascript true and false values</a> first appeared on <a href="https://heaplevel.com">Heaplevel AB</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
