<?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>Lists on SourFox</title>
    <link>https://sourfox.khmersite.net/tags/lists/</link>
    <description>Recent content in Lists 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>Mon, 30 Dec 2024 16:51:56 +1100</lastBuildDate>
    <atom:link href="https://sourfox.khmersite.net/tags/lists/index.xml" rel="self" type="application/rss+xml" />
    <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>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>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>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>
  </channel>
</rss>
