<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dongdiri</title>
    <description>The latest articles on DEV Community by dongdiri (@dongdiri).</description>
    <link>https://dev.to/dongdiri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1185584%2F42ec5f34-1a5a-4ab7-a962-aca9f444fc94.png</url>
      <title>DEV Community: dongdiri</title>
      <link>https://dev.to/dongdiri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dongdiri"/>
    <language>en</language>
    <item>
      <title>DAY23: Python day 31</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Thu, 15 Feb 2024 11:58:28 +0000</pubDate>
      <link>https://dev.to/dongdiri/day23-python-day-31-31lh</link>
      <guid>https://dev.to/dongdiri/day23-python-day-31-31lh</guid>
      <description>&lt;h2&gt;
  
  
  Capstone Project: Flash Card App
&lt;/h2&gt;

&lt;p&gt;This project was the biggest struggle by far, primarily because I was not fully proficient with all the packages. &lt;br&gt;
Here are the things I should remember that may come in handy:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pandas&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;when converting list into .csv file, make dataframe first&lt;/li&gt;
&lt;li&gt;can specify file location as parameter of to_csv() function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    data = pandas.DataFrame(to_learn)
    data.to_csv("data/words_to_learn.csv")
    new_random_word()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;no need to use &lt;code&gt;with&lt;/code&gt; or &lt;code&gt;open&lt;/code&gt; when there is &lt;code&gt;read_csv()&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;dictionary becomes list when used parameter &lt;code&gt;orient="records"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = pandas.read_csv("data/french_words.csv")
to_learn = data.to_dict(orient="records")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;tkinter&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;can create text within canvas with &lt;code&gt;canvas.create_text()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;when creating text inside a canvas, keyword argument to change color is &lt;code&gt;fill&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;card_title = canvas.create_text(400, 150, fill="black")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;to modify things inside canvas, first store as a variable and then use &lt;code&gt;itemconfig()&lt;/code&gt; function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;canvas.itemconfig(card_title, fill="white")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;canvas.after()&lt;/code&gt; function to create timer without using &lt;code&gt;while&lt;/code&gt; loop&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;canvas.after(milliseconds, function)&lt;/code&gt;: carries out a certain function after given milliseconds
-in order to prevent timer overlap, we can create a variable to store it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def new_random_word():
    global flip_timer
    canvas.after_cancel(flip_timer)
    ...
    flip_timer = canvas.after(3000, func=flip_card)
...

flip_timer = canvas.after(3000, func=flip_card)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;miscellaneous&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.remove()&lt;/code&gt; function to delete item from list &lt;/li&gt;
&lt;li&gt;can access files that are under the same folder without &lt;code&gt;./&lt;/code&gt; or &lt;code&gt;../&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DAY22: Python day 30</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Thu, 15 Feb 2024 09:07:12 +0000</pubDate>
      <link>https://dev.to/dongdiri/day22-python-day-30-365l</link>
      <guid>https://dev.to/dongdiri/day22-python-day-30-365l</guid>
      <description>&lt;p&gt;worked on projects and with a deeper dive into tkinter for the past two days.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;catching exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;try&lt;/code&gt;, &lt;code&gt;except&lt;/code&gt;, &lt;code&gt;else&lt;/code&gt;, &lt;code&gt;finally&lt;/code&gt; keywords&lt;/li&gt;
&lt;li&gt;helps prevent error&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;raise&lt;/code&gt; keyword: arbitrarily create error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Json(JavaScript Object Notation)&lt;/strong&gt;&lt;br&gt;
-&lt;code&gt;json.dump()&lt;/code&gt; to add data. Mode should be &lt;code&gt;"w"&lt;/code&gt;&lt;br&gt;
-&lt;code&gt;json.load()&lt;/code&gt; to read json file as dictionary. Mode should be &lt;code&gt;"r"&lt;/code&gt;&lt;br&gt;
-&lt;code&gt;json.update()&lt;/code&gt; to update data we got hold of&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DAY19: Python day 27</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Wed, 14 Feb 2024 01:26:02 +0000</pubDate>
      <link>https://dev.to/dongdiri/day19-python-day-27-5am7</link>
      <guid>https://dev.to/dongdiri/day19-python-day-27-5am7</guid>
      <description>&lt;p&gt;&lt;strong&gt;Advanced python arguments&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;arguments with default values
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def function(a=1, b=2, c=3):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;unlimited positional arguments&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;put &lt;code&gt;(*args)&lt;/code&gt; when defining the function &lt;/li&gt;
&lt;li&gt;creates a tuple &lt;/li&gt;
&lt;li&gt;often goes with a loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;unlimtited keyword arguments&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;put &lt;code&gt;(**kwargs)&lt;/code&gt; when defining function &lt;/li&gt;
&lt;li&gt;creates a dictionary&lt;/li&gt;
&lt;li&gt;use &lt;code&gt;.get()&lt;/code&gt; method to access values without error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GUI: graphical user interface&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;intro to tkinter &lt;/li&gt;
&lt;li&gt;widgets: button, entry, label &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pack()&lt;/code&gt;, &lt;code&gt;grid()&lt;/code&gt; functions&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DAY18: Python day 26</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Mon, 05 Feb 2024 16:31:04 +0000</pubDate>
      <link>https://dev.to/dongdiri/day18-python-day-26-3bk6</link>
      <guid>https://dev.to/dongdiri/day18-python-day-26-3bk6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Python list comprehension&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;very unique to Python&lt;/li&gt;
&lt;li&gt;an alternative to a &lt;code&gt;for&lt;/code&gt; loop when working with sequences like list, range, string, tuple&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;new_list = [new_item for item in list]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers = [1, 2, 3]
new_list = [n+1 for n in numbers]

name = "dongdiri"
character_list = [letter for letter in name]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;also can add an &lt;code&gt;if&lt;/code&gt; statement
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;character_list = [letter for letter in name if character != "r"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dictionary comprehension&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;new_dict = &lt;code&gt;{new_key:new_value for item in list}&lt;/code&gt; or &lt;code&gt;{new_key:new_value for (key, value) in dict.items()}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;be careful not to forget &lt;code&gt;.items()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Panda &lt;code&gt;.iterrows&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;loop through rows of a data frame using panda
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{row.new_key:row.new_value for (index, row) in data.iterrows()}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;End of the lesson project: NATO alphabet converter&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#TODO 1. Create a dictionary in this format:
data = pandas.read_csv("nato_phonetic_alphabet.csv")
new_dict = {row.letter: row.code for (index, row) in data.iterrows()}

#TODO 2. Create a list of the phonetic code words from a word that the user inputs.
name = input("enter a word: ").upper()
code_list = [new_dict[letter] for letter in name]
print(code_list)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Today's content was a bit hard to understand-I should take time to review it as well as python dictionaries.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DAY 17: Python day 24 &amp; 25</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Sun, 04 Feb 2024 12:36:05 +0000</pubDate>
      <link>https://dev.to/dongdiri/day-17-python-day-24-25-3g12</link>
      <guid>https://dev.to/dongdiri/day-17-python-day-24-25-3g12</guid>
      <description>&lt;h2&gt;
  
  
  The file system
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;create a .txt file &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;with open("filename.txt) as&lt;/code&gt; keyword&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;open()&lt;/code&gt; method creates a new file when it doesn't exist&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;read&lt;/code&gt; and &lt;code&gt;write&lt;/code&gt; methods&lt;/li&gt;
&lt;li&gt;&lt;p&gt;setting a mode &lt;code&gt;"r"&lt;/code&gt;(read), &lt;code&gt;"w"&lt;/code&gt;(write), &lt;code&gt;"a"&lt;/code&gt;(append)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;absolute file path: starts from origin &lt;br&gt;
root: /&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;relative file path: starts from working directory&lt;br&gt;
one step down: ./&lt;br&gt;
one step up: ../&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Intro to CSV(comma-separated values)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;csv library&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;built-in&lt;/li&gt;
&lt;li&gt;csv.reader(data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;pandas library&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dataframe &lt;/li&gt;
&lt;li&gt;series&lt;/li&gt;
&lt;li&gt;get data in each column by &lt;code&gt;data.columnname&lt;/code&gt; or &lt;code&gt;data["columnname"]&lt;/code&gt;. Returns a series&lt;/li&gt;
&lt;li&gt;get data in each row by first getting the column value in the row and searching its index.&lt;code&gt;data[data.columnname == item]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;turn series into list through &lt;code&gt;to_list&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;turn list into dataframe through &lt;code&gt;pandas.Dataframe(list)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;turn dataframe into csv file through &lt;code&gt;dataframe.to_csv("filename.csv")&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DAY15&amp;16: Python day 22 &amp; 23</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Sat, 03 Feb 2024 08:16:51 +0000</pubDate>
      <link>https://dev.to/dongdiri/day1516-python-day-22-23-4p9h</link>
      <guid>https://dev.to/dongdiri/day1516-python-day-22-23-4p9h</guid>
      <description>&lt;p&gt;&lt;strong&gt;Created Pong and Crossy Road on each day, respectively.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;reviewed concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating classes&lt;/li&gt;
&lt;li&gt;creating class attributes using &lt;code&gt;__init__()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;creating class methods using &lt;code&gt;def&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;inheriting attributes and methods using &lt;code&gt;super().__init()__&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;event listeners &lt;code&gt;screen.onkey()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;distance logic using &lt;code&gt;if&lt;/code&gt; statements with &lt;code&gt;object.xcor()&lt;/code&gt;, &lt;code&gt;object.ycor()&lt;/code&gt;or &lt;code&gt;object.distance()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;arbitrarily refreshing screen with &lt;code&gt;screen.tracer(0)&lt;/code&gt; and &lt;code&gt;time.sleep()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzzfvaucpmgyhm8yzrqj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzzfvaucpmgyhm8yzrqj.png" alt="Image description" width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6xigkjxy6iheeqsmx8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6xigkjxy6iheeqsmx8o.png" alt="Image description" width="800" height="805"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DAY14:Python day 19, 20, 21</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Sun, 28 Jan 2024 15:55:42 +0000</pubDate>
      <link>https://dev.to/dongdiri/day14python-day-19-20-21-5h4l</link>
      <guid>https://dev.to/dongdiri/day14python-day-19-20-21-5h4l</guid>
      <description>&lt;h2&gt;
  
  
  Day 19
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;event listeners and higher order functions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it a higher-order function (functions that can work with other functions)&lt;/li&gt;
&lt;li&gt;in a higher-order function, we don't add () for parameter function, we only pass the name.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;high_order_function(function2)

screen.onkey(key="space", fun=move_forward) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; creating separate objects from same class that have independent states (attributes, methods) &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Day20: making the snake game
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;update() method to animate&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;turn off tracer &lt;code&gt;screen.tracer[0]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;control by importing &lt;code&gt;time&lt;/code&gt; and delay through &lt;code&gt;time.sleep()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;then update screen when necessary by &lt;code&gt;screen.update()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;how do we turn our snake?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;in order to prevent the body from leaving its head, we need to start from the last segment and make each segment occupy the position of its previous segment. The head moves last. This part was hard to come up with myself. &lt;/li&gt;
&lt;li&gt;we do this by this &lt;code&gt;for&lt;/code&gt; loop:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        for segment_number in range(len(self.segments) - 1, 0, -1):
            new_x = self.segments[segment_number - 1].xcor()
            new_y = self.segments[segment_number - 1].ycor()
            self.segments[segment_number].goto(new_x, new_y)
        self.segments[0].forward(move_distance)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;three parameters in &lt;code&gt;range()&lt;/code&gt; function are start, stop, and step, respectively. So the order starts from the last, and decrements by 1 until it reaches 0, the head. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Day21: snake game continued
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;class inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inheriting attributes/methods from parent(superclass)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class child(parent):
    def __init__(self):
        super().__init__()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;slicing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;accessing set of items from one position to another&lt;/li&gt;
&lt;li&gt;&lt;code&gt;list[start position: end position: increment]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;tip: &lt;code&gt;list[::-1]&lt;/code&gt; to reverse the list&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DAY13: Python day 18</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Thu, 18 Jan 2024 14:48:31 +0000</pubDate>
      <link>https://dev.to/dongdiri/day13-python-day-18-8kn</link>
      <guid>https://dev.to/dongdiri/day13-python-day-18-8kn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Exploration of Turtle&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;successfully built geometric shapes generator, random walk generator, spirograph drawer &lt;/li&gt;
&lt;li&gt;I particularly liked the random walk generator the most
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;timmy = Turtle()
turtle.colormode(255)

direction = [0, 90, 180, 270]
timmy.pensize(10)
timmy.speed(0)
while True:
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    timmy.pencolor(r, g, b)
    timmy.setheading(choice(direction))
    timmy.forward(20)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Various ways to import packages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;import&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;from&lt;/code&gt;...&lt;code&gt;import&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;from&lt;/code&gt;...&lt;code&gt;import*&lt;/code&gt; (not recommended)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;import&lt;/code&gt;...&lt;code&gt;as&lt;/code&gt;... (aliasing)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Python Tuples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;like a list but in &lt;code&gt;()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;wrote in stone(immutable)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;End of the lesson project: Hirst Painting&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import colorgram
from turtle import Turtle, Screen
import turtle
from random import choice
turtle.colormode(255)
# rgb_colors = []
# colors = colorgram.extract('image.jpg', 18 * 20)
# for color in colors:
#     r = color.rgb.r
#     g = color.rgb.g
#     b = color.rgb.b
#     new_color = (r, g, b)
#     rgb_colors.append(new_color)

color_list =[(236, 224, 80), (197, 7, 71), (195, 164, 13), (201, 75, 15), (231, 54, 132), (110, 179, 216), (217, 163, 101), (27, 105, 168), (35, 186, 109), (19, 29, 168), (13, 23, 66), (212, 135, 177), (233, 223, 7), (199, 33, 132), (13, 183, 212), (230, 166, 199), (126, 189, 162), (8, 49, 28), (40, 132, 77), (128, 219, 232), (58, 12, 25), (67, 22, 7), (114, 90, 210), (146, 216, 199), (179, 17, 8), (233, 66, 34), (11, 97, 52), (169, 181, 232), (241, 169, 155), (252, 7, 40), (10, 84, 100), (63, 98, 8), (14, 51, 250), (250, 11, 8)]

timmy = Turtle()
current_x = -200
current_y = -200
timmy.shape("turtle")
timmy.penup()
timmy.hideturtle()
timmy.goto(current_x, current_y)
timmy.pensize(20)

for _ in range(10):
    for _ in range(10):
        timmy.pencolor(choice(color_list))
        timmy.pendown()
        timmy.speed(0)
        timmy.forward(0)
        timmy.penup()
        timmy.forward(50)
    current_y += 50
    timmy.goto(current_x, current_y)


screen = Screen()
screen.exitonclick()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>DAY12: Python day 17</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Wed, 17 Jan 2024 15:54:24 +0000</pubDate>
      <link>https://dev.to/dongdiri/day12-python-day-17-icf</link>
      <guid>https://dev.to/dongdiri/day12-python-day-17-icf</guid>
      <description>&lt;p&gt;&lt;strong&gt;Creating my own class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By convention, we use PascalCase for classes, snake_case for everything else&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;__init__()&lt;/code&gt; function to create a constructor(initialize) for a class: must have a &lt;code&gt;self&lt;/code&gt; parameter&lt;/li&gt;
&lt;li&gt;setting default value inside &lt;code&gt;__init__&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;adding method to class using &lt;code&gt;def&lt;/code&gt; keword: also requires &lt;code&gt;self&lt;/code&gt; parameter
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User:

    def __init__(self, user_id, username):
        self.id = user_id
        self.username = username
        self.followers = 0
        self.following = 0

    def follow(self, user):
        user.followers += 1
        self.following += 1

user_1 = User("001", "angela")
user_2 = User("002", "matthew")


user_1.follow(user_2)
print(user_1.following)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>DAY11: Python day 15 &amp; 16</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Mon, 15 Jan 2024 14:11:33 +0000</pubDate>
      <link>https://dev.to/dongdiri/day11-python-day-16-17-4mi3</link>
      <guid>https://dev.to/dongdiri/day11-python-day-16-17-4mi3</guid>
      <description>&lt;p&gt;I entered the intermediate level!&lt;br&gt;
I started using PyCharm–there are now a lot of files and classes, so I cannot attach a code for my project. Instead, I will add some more detail to my notes, as most of the contents should now be unfamiliar and I can revisit them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Day 16: coffee machine making&lt;/strong&gt;&lt;br&gt;
First project that I struggled with and spent a lot of time on. I should utilize &lt;code&gt;for()&lt;/code&gt; loops better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Day 17: Object-Oriented Programming(OOP)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;an object contains attributes(variables) and methods(functions)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create an object from a class&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import turtle
timmy = turtle.Turtle()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;tap into an attribute and method of an object by &lt;code&gt;.&lt;/code&gt; notation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;exploring PyPi and finding Python Packages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;install package through preferences --&amp;gt; Python Interpreter --&amp;gt; "+" &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>DAY10: Python Day 13&amp;14</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Wed, 20 Dec 2023 13:59:55 +0000</pubDate>
      <link>https://dev.to/dongdiri/day10-python-day-1314-2c5l</link>
      <guid>https://dev.to/dongdiri/day10-python-day-1314-2c5l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Debugging&lt;/strong&gt;&lt;br&gt;
some debugging principles that I really need to follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run code often &lt;/li&gt;
&lt;li&gt;print() often&lt;/li&gt;
&lt;li&gt;debugger: &lt;a href="https://pythontutor.com/render.html#mode=edit"&gt;https://pythontutor.com/render.html#mode=edit&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Higher-Lower game&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import art
from game_data import data
import random 
from replit import clear

#print higher lower logo 
print(art.logo)
#create variable for while loop 
right_answer = True 
current_score = 0

def check_answer(guess, A, B):
  if A &amp;gt; B:
    return guess == "A"
  else: 
    return guess == "B"

def compare(A, B):
  if A["follower_count"]&amp;gt;B["follower_count"]: 
    return A
  else: 
    return B

#pick random two dictionaires from list, store into variables 
A = data[random.randrange(0, 49)]
B = data[random.randrange(0,49)]
#create while loop 
while right_answer: 
  #print compare A: dictionary item 1, dictionary item 2, dictionary item 3
  print(f"Compare A: {A['name']}, {A['description']}, {A['country']}")
  #print vs art
  print(art.vs)
  #print against B: same thing 
  print(f"Against B: {B['name']}, {B['description']}, {B['country']}")
  answer = input("who has more followers? Type A or B: ")
  right_answer = check_answer(answer, A["follower_count"], B["follower_count"])

  clear() 
  print(art.logo)

  #if right answer: 
    #move answer to variable A 
    #pick new dictionary assign variable B
  if right_answer: 
    current_score += 1
    print(f"You're right! current score: {current_score}")
    A = compare(A, B)
    B = data[random.randrange(0, 49)]
print("wrong. Game over")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code works if there is data in a separate file called game_data. &lt;br&gt;
I felt a strong necessity to get more familiar with creating functions and the &lt;code&gt;return&lt;/code&gt; keyword to make the code more concise. I will utilize this more actively in later projects. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>DAY 9: Python Day 12</title>
      <dc:creator>dongdiri</dc:creator>
      <pubDate>Mon, 18 Dec 2023 16:23:20 +0000</pubDate>
      <link>https://dev.to/dongdiri/day-9-python-day-12-5m6</link>
      <guid>https://dev.to/dongdiri/day-9-python-day-12-5m6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Namespace and scope&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;function has local scope &lt;/li&gt;
&lt;li&gt;blocks like &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt; do not&lt;/li&gt;
&lt;li&gt;can tap into global variable with &lt;code&gt;global&lt;/code&gt; keyword within a function (avoid modifying global scope; prone to bugs)
-alternatively, use &lt;code&gt;return&lt;/code&gt;
-CONSTANTS are usually given global scope and are capitalized by convention. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;End of the Lesson Project: number guessing game&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Number Guessing Game Objectives:

# Allow the player to submit a guess for a number between 1 and 100.
# Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer. 
# If they got the answer correct, show the actual answer to the player.
# Track the number of turns remaining.
# If they run out of turns, provide feedback to the player. 
# Include two different difficulty levels (e.g., 10 guesses in easy mode, only 5 guesses in hard mode).
import random
run_project = True 

while run_project:
  number = random.randrange(1, 101)
  print("Welcome to the Number Guessing Game!")
  print("I'm thinking of a number between 1 and 100.")
  difficulty = input("Choose a difficulty. Type 'easy' or 'hard':" )
  def game(attempts): 
    for i in range(1, attempts + 1):
      print(f"You have {attempts+1-i} attempts remaining to guess the number.")
      guess = int(input("Make a guess:" ))
      if guess &amp;gt; number:
        print("Too high.")
      elif guess &amp;lt; number: 
        print("Too low.")
      else: 
        print(f"You got it! The answer was {number}.")
        return 
  if difficulty == "easy": 
    game (10)
  elif difficulty == "hard":
    game (5)

  if input("Restart game? 'yes' or 'no'") == "yes":
    run_project = True
  else: 
    run_project = False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As this project was made some scratch, some improvements can be made: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;store number of turns as a global variable, which was the whole point of today's lesson &lt;/li&gt;
&lt;li&gt;create another function to set the difficulty &lt;/li&gt;
&lt;li&gt;do not forget that &lt;code&gt;return&lt;/code&gt; exits the function!&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
