<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Print on SourFox</title>
    <link>https://sourfox.khmersite.net/tags/print/</link>
    <description>Recent content in Print on SourFox</description>
    <image>
      <title>SourFox</title>
      <url>https://sourfox.khmersite.net/papermod-cover.png</url>
      <link>https://sourfox.khmersite.net/papermod-cover.png</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 28 Jan 2025 14:21:03 +1100</lastBuildDate>
    <atom:link href="https://sourfox.khmersite.net/tags/print/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Binary to Decimal Updated</title>
      <link>https://sourfox.khmersite.net/p/2025/01/binary_to_decimal_updated/</link>
      <pubDate>Tue, 28 Jan 2025 14:21:03 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2025/01/binary_to_decimal_updated/</guid>
      <description>&lt;p&gt;In my other blog post &amp;lsquo;Binary to Decimal&amp;rsquo;, I realized what if I had put in a different number than 1 and 0. I tried putting a 2 and the code still worked. So I will be sharing an updated version, so that you can only put in either 1 or 0. Else there will be an error.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# make a new function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;bintodeci&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;num&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;reverse&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;len&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;num&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;exp&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;total&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;index&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reverse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;c1&#34;&gt;# if each number is either 0 or 1 else it&amp;#39;ll print out an error.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;num&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;index&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;01&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;total&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;num&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;index&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;**&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;exp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;exp&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;else&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Error: Invalid binary number&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;None&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# return the value&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;total&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# In case I want to import it&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;vm&#34;&gt;__name__&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sa&#34;&gt;f&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;The variable __name__ is &lt;/span&gt;&lt;span class=&#34;si&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;vm&#34;&gt;__name__&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     &lt;span class=&#34;n&#34;&gt;answer&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;bintodeci&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;111&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;     &lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;answer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Recursive function</title>
      <link>https://sourfox.khmersite.net/p/2025/01/recursive_function/</link>
      <pubDate>Mon, 27 Jan 2025 17:53:36 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2025/01/recursive_function/</guid>
      <description>&lt;p&gt;Hi, today I&amp;rsquo;m sharing a recursive funtion in python. Recursive in python means the &amp;lsquo;def&amp;rsquo; function to call itself. The goal is to sum up the numbers to the number I want. For example, if I put in 3:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1 + 2 + 3 = 6
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# def = makes a new function
def sum(num):
    # if we have an &amp;#39;if&amp;#39;, we should also have an &amp;#39;else&amp;#39;.
    if num == 0:
        return 0
    else:
        return sum(num - 1) + num


print(sum(2))
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Outcome:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Binary to Decimal</title>
      <link>https://sourfox.khmersite.net/p/2025/01/binary_to_decimal/</link>
      <pubDate>Thu, 23 Jan 2025 20:33:23 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2025/01/binary_to_decimal/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m sharing a program that converts binary to decimal in python.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# make a new function
def bintodeci(num):
    reverse = len(num) -1
    exp = 0
    total = 0
    # range(start, stop, step)
    for digit in range(reverse, -1, -1):
        total += int(num[digit]) * (2**exp)
        exp += 1
    
    # return the value
    return total


answer = bintodeci(&amp;#34;11&amp;#34;)
print(answer)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;sample output:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;10
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;bai.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Create Restic Backup Program</title>
      <link>https://sourfox.khmersite.net/p/2024/12/create-restic-backup-program/</link>
      <pubDate>Mon, 30 Dec 2024 16:51:56 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/12/create-restic-backup-program/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m sharing a wrapper program written in python to backup my files in my device using restic.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;import subprocess

restic_command = [&amp;#39;restic&amp;#39;, &amp;#39;backup&amp;#39;]

backup = [&amp;#34;C:\\Users\\veronica\\ibisPaint&amp;#34;, &amp;#34;C:\\Users\\veronica\\Pictures&amp;#34;, &amp;#34;C:\\Users\\veronica\\Documents&amp;#34;]

print(&amp;#34;List of directories to be backed up:\n&amp;#34; )

#list the files that will be backed up.
#enumerate = allows you to keep track of the number of iterations in a loop.
for number, dir in enumerate(backup, start=1):
    print(f&amp;#34;    {number}. {dir}&amp;#34;)
#  Or: print(&amp;#34;    &amp;#34; + str(number) + &amp;#34;.&amp;#34;, letter )

# \n makes a new line
print(&amp;#34;\nBackup process started...\n&amp;#34;)

# combines the lists together.
backup_command = restic_command + backup

restic = subprocess.run(backup_command, shell=True)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The end. -w-&lt;/p&gt;</description>
    </item>
    <item>
      <title>Atm Bill Dispenser</title>
      <link>https://sourfox.khmersite.net/p/2024/8/atm/</link>
      <pubDate>Fri, 09 Aug 2024 19:17:12 +1000</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/8/atm/</guid>
      <description>&lt;p&gt;Today, I was given an assignment to write a program to implement an atm dispenser in the following notes: 100, 50, 20, 10, and 5. If the amount is not a multiply of 5, the atm will return a list of 0.&lt;/p&gt;
&lt;p&gt;In the code are short explanations of why I used it.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# asks the customer to enter an amount of number.
atm = int(input(&amp;#34;Enter an amount in a multiple of 5: &amp;#34;))

# This takes in a amount parameter which is the input  from the user and return an array of bills in the following orders: [$100, $50, $20, $10, $5]. 
def dispenser(amount):
    
    # if statement to check if number entered is divisible by 5. If not, return with 0, if yes, continue code.
    if atm % 5 != 0:
        return [0, 0, 0, 0, 0]
    
    result = []
    bill_types = [100, 50, 20, 10, 5]

# starts with the starting amount being divided by each number in bill_types.
    for each_note in bill_types:
        note_counts = amount // each_note
        result.append(note_counts)

        # get the remainder and overwrite the previous.
        amount = amount % each_note

    return result

# The code below is what will be given back as a sentence to the customer.
print(f&amp;#34;You entered ${atm}: {dispenser(atm)}&amp;#34;)
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Finding the GCD of two numbers</title>
      <link>https://sourfox.khmersite.net/p/2024/7/assignment_gcd/</link>
      <pubDate>Fri, 12 Jul 2024 12:43:30 +1000</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/7/assignment_gcd/</guid>
      <description>&lt;p&gt;In this assignment, it&amp;rsquo;ll be finding the GCD(Greatest Common Divisor). This means I need to write a program to find the GCD of two numbers. Below, I have written the program and next to the hashtags are just a sentence that&amp;rsquo;ll explain to you what each part of the code is doing.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;#The two variables &amp;#39;num&amp;#39; and &amp;#39;ber&amp;#39; will be where the inputs will be stored in. When it starts it will show &amp;#39;(num)a: &amp;#39; and you&amp;#39;ll have to put a number in. This goes the same for &amp;#39;(ber)b: &amp;#39;

num = int(input(&amp;#34;a: &amp;#34;))
ber = int(input(&amp;#34;b: &amp;#34;))

#Then once the variable has gotten their information, they will go through this: 

def gcd(num, ber):
    if ber == 0:
        return num
    else:
        return gcd(ber, num % ber)
    
#And last, it&amp;#39;ll gather their answer and print it for you as a sentence.

print(f&amp;#34;The GCD {num}, {ber} is {gcd(num, ber)}.&amp;#34;)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That&amp;rsquo;s all today. Bye!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Check if a year is a leap year</title>
      <link>https://sourfox.khmersite.net/p/2024/5/assignment_9/</link>
      <pubDate>Tue, 14 May 2024 17:43:09 +1000</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/5/assignment_9/</guid>
      <description>&lt;p&gt;Today, I just got back to python after a few months. So when coming back, I got an assignment. My assignment was to &lt;em&gt;check if a year is a leap year.&lt;/em&gt; In the assignment, it also gave hints. These were the hints:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A leap year is a calendar year that contains an additional day (February 29th) compared to a common year. It occurs once every four year.
s
&lt;strong&gt;This is how you can determine if a year is a leap year or not:&lt;/strong&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Make a Frequency Dictionary From the Elements Of a List </title>
      <link>https://sourfox.khmersite.net/p/2024/2/assignment-8/</link>
      <pubDate>Sun, 25 Feb 2024 18:00:14 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/2/assignment-8/</guid>
      <description>&lt;p&gt;Halo! Today I have to make a python program that meets these conditions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Write a Python program that creates and print a dictionary that maps each element in a list to its corresponding frequency (how many times it occurs in the list).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The test should be case-sensitive. Therefore, “A” should not be considered the same element as “a”.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I think for today, I&amp;rsquo;m just going to make it short. Yea&amp;hellip;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Finding the Second Largest Value in a List</title>
      <link>https://sourfox.khmersite.net/p/2024/2/assignment-7/</link>
      <pubDate>Sat, 10 Feb 2024 19:35:52 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/2/assignment-7/</guid>
      <description>&lt;p&gt;Halooo! Today I&amp;rsquo;ll be teaching you how to find the second largest value in a list. The conditions -&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Write a Python program that prints the second largest value in a list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the list is empty or only has one element, print None.SSS&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To do this, we&amp;rsquo;ll have to make a list and then sort it and then we use the if statement and else.&lt;/p&gt;
&lt;p&gt;Input:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;lista = [1, 4, 8, 9, 100, 200, 30]
lista.sort()

if len(lista) &amp;gt; 1:
    print(lista[-2])
else:
    print(&amp;#34;None&amp;#34;)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Output -&lt;/p&gt;</description>
    </item>
    <item>
      <title>Finding elements not in list</title>
      <link>https://sourfox.khmersite.net/p/2024/2/assignment-6/</link>
      <pubDate>Sun, 04 Feb 2024 21:14:07 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2024/2/assignment-6/</guid>
      <description>&lt;p&gt;Haloo people! How long has it been since I&amp;rsquo;ve done a blog post? Welp, I&amp;rsquo;ve finished my long break and now it&amp;rsquo;s time to get back to work. Today, I&amp;rsquo;ll be writing a python program that prints the elements of one list (a) that are not in the other list (b) as a list.&lt;/p&gt;
&lt;p&gt;My conditions are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If the lists have the same elements, it will print an empty list.&lt;/li&gt;
&lt;li&gt;If the first list (a) is an empty list, it&amp;rsquo;ll print an empty list.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;An example -&lt;/p&gt;</description>
    </item>
    <item>
      <title>Commas replaced by dots</title>
      <link>https://sourfox.khmersite.net/p/2023/12/switching-commas/</link>
      <pubDate>Tue, 26 Dec 2023 14:55:12 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/12/switching-commas/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s been a long time since i&amp;rsquo;ve done a blog post. I wonder why&amp;hellip;.&lt;/p&gt;
&lt;p&gt;Welp, today I&amp;rsquo;ve got an assignment, today&amp;rsquo;s one is to write a python program that prints a version of the strings with all commas replaced by dots. Like this.&lt;/p&gt;
&lt;p&gt;Example -&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  Input               Output
&amp;#34;Hello, World!&amp;#34;      &amp;#34;Hello. World!&amp;#34;
&amp;#34;725,000&amp;#34;            &amp;#34;725.000&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;First, I&amp;rsquo;m going to do the 1st one. I&amp;rsquo;m going to assign it to a variable called string.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Bonus assignment: Challenge Add a Key-Value Pair Only if the Key is Not in the Dictionary </title>
      <link>https://sourfox.khmersite.net/p/2023/11/dictionary/</link>
      <pubDate>Sat, 18 Nov 2023 18:51:34 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/11/dictionary/</guid>
      <description>&lt;p&gt;Today I was very bored so I checked my bonus assignments and I got this.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Write a Python program that adds a new key-value pair to a dictionary only if the key doesn&amp;rsquo;t exist already.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the key-value pair exists in the dictionary, do not update the existing value. The dictionary should not be modified in this case.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Store the new key in the new_key variable and the new value in the new_value variable.
Print the final value of the dictionary.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Check if a Key Is in a Dictionary</title>
      <link>https://sourfox.khmersite.net/p/2023/11/check-if-a-key-is-in-a-dictionary/</link>
      <pubDate>Wed, 15 Nov 2023 20:31:21 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/11/check-if-a-key-is-in-a-dictionary/</guid>
      <description>&lt;p&gt;&lt;em&gt;The next one I&amp;rsquo;ll actually explain thoroughly.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So I had enough time to make another program. This time I had to meet the condtitions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Write a Python program that checks if a key exists in a dictionary or not.
 
If the key exists in the dictionary, print True. Else, print False.

The key should be stored in the variable key.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is how I did it:&lt;/p&gt;
&lt;p&gt;Input:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;dict = {&amp;#34;toy&amp;#34;: &amp;#34;dino&amp;#34;, &amp;#34;sport&amp;#34;: &amp;#34;soccer&amp;#34;, &amp;#34;food&amp;#34;: &amp;#34;ramen&amp;#34;}
key = &amp;#34;toy&amp;#34;
if key in dict:
    print(True)
else:
    print(False)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Output:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment 5: Elements and Indices</title>
      <link>https://sourfox.khmersite.net/p/2023/11/assignment-5/</link>
      <pubDate>Sat, 11 Nov 2023 19:08:38 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/11/assignment-5/</guid>
      <description>&lt;p&gt;Today I had to do another assignment which is to create a python program which prints the elements of a list followed by their corresponding indices. Each element and its index must be on the same line seperated by a space. And if the list is empty, print &lt;strong&gt;&amp;ldquo;Empty List&amp;rdquo;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m going to make a list called num and put 1 to 4 inside.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;num = [1, 2, 3, 4]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then I&amp;rsquo;ll use the &lt;strong&gt;if&lt;/strong&gt; statement to do:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment 4: Checking if a list is empty</title>
      <link>https://sourfox.khmersite.net/p/2023/10/assignment-4/</link>
      <pubDate>Sun, 29 Oct 2023 18:42:54 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/10/assignment-4/</guid>
      <description>&lt;p&gt;I was given an assignment for the fourth time. My goal was to write a python program that checks if a list is empty or not. If the list is empty, then it&amp;rsquo;ll print &lt;strong&gt;empty&lt;/strong&gt;, if not, it&amp;rsquo;ll print &lt;strong&gt;not empty&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m going to start with an empty list.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;emp = []
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So that I can start the next step. I&amp;rsquo;m going to use&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;if statement&lt;/li&gt;
&lt;li&gt;len()&lt;/li&gt;
&lt;li&gt;else&lt;/li&gt;
&lt;li&gt;print()&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When using if, there must be a condition met. My condition is:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment 3: Doubling </title>
      <link>https://sourfox.khmersite.net/p/2023/10/assignment-3/</link>
      <pubDate>Wed, 18 Oct 2023 18:59:17 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/10/assignment-3/</guid>
      <description>&lt;p&gt;Today, I was given another assignment. (Which I wasn&amp;rsquo;t expecting.) Today&amp;rsquo;s assignment was to write a python program which had to meet the conditions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Write a Python proram that multiplies all the items in a list by the value of the variable factor.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The program must print the list as the output.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The program should allow multiplying the variable factor by a string in case the list contains strings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You may assume that the value of factor will be a positive integer.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment 1: Using Length and String</title>
      <link>https://sourfox.khmersite.net/p/2023/10/assignment-1-using-length/</link>
      <pubDate>Sun, 15 Oct 2023 11:14:44 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/10/assignment-1-using-length/</guid>
      <description>&lt;p&gt;Today, I was given an assignment. My assignment wanted me to write a Python program that pints the length of a string.&lt;/p&gt;
&lt;p&gt;This is what I had to print out:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;The length of &amp;#34;&amp;#34; is 0.
The length of &amp;#34;H&amp;#34; is 1.
The length of &amp;#34;Hello&amp;#34; is 5.
The length of &amp;#34;Amazing&amp;#34; is 7.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To do this, I have a plan in my mind which is:&lt;/p&gt;
&lt;p&gt;Step 1. Find out what I&amp;rsquo;m going to use.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Assignment 2: Python Using Lists and While-Loop</title>
      <link>https://sourfox.khmersite.net/p/2023/10/assignment-2-python-using-lists-while-loop/</link>
      <pubDate>Sat, 07 Oct 2023 12:43:22 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/10/assignment-2-python-using-lists-while-loop/</guid>
      <description>&lt;p&gt;I had an assignment that I was given for Python. What I have to do is to write a program in Python that asks a user to enter their favourite fruit, store each fruit in a list. At the end of the program, print out the total number of fruits, and also print all the fruits.&lt;/p&gt;
&lt;p&gt;This is what I&amp;rsquo;m expected:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;What is your favourite fruit? Banana (the fruit user put)
What is your favourite fruit? Apple  (the fruit user put)
What is your favourite fruit? Orange  (the fruit user put)
What is your favourite fruit? (empty) (the user didn&amp;#39;t write anything)

You have 3 fruits in the basket: Banana, Apple, and Orange.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So how do I do this?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Display Items in Python List</title>
      <link>https://sourfox.khmersite.net/p/2023/10/display-items-in-python-list/</link>
      <pubDate>Mon, 02 Oct 2023 16:44:02 +1100</pubDate>
      <guid>https://sourfox.khmersite.net/p/2023/10/display-items-in-python-list/</guid>
      <description>&lt;p&gt;Today, I was asked to write a small python code to print out all items in a list with comma seperated. The last item would end the with a &amp;lsquo;dot&amp;rsquo;, or full stop.&lt;/p&gt;
&lt;p&gt;For example, here is a list of sports:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;sports&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;basketball&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;soccer&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;netball&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And I was asked to print out the expected output:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;My&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;favourite&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sports&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;are&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;basketball&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;soccer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;netball&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But how do I do this? Today, I&amp;rsquo;ll be showing you how to show the expected output using &lt;strong&gt;join&lt;/strong&gt; and without join.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
