<?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: flavian-anselmo</title>
    <description>The latest articles on DEV Community by flavian-anselmo (@flaviananselmo).</description>
    <link>https://dev.to/flaviananselmo</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%2F434274%2F9a313b7d-d5da-4322-8ec7-7dd45ddce42f.jpg</url>
      <title>DEV Community: flavian-anselmo</title>
      <link>https://dev.to/flaviananselmo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flaviananselmo"/>
    <language>en</language>
    <item>
      <title>Digital Clock with python</title>
      <dc:creator>flavian-anselmo</dc:creator>
      <pubDate>Mon, 14 Dec 2020 18:42:35 +0000</pubDate>
      <link>https://dev.to/flaviananselmo/digital-clock-with-python-53p2</link>
      <guid>https://dev.to/flaviananselmo/digital-clock-with-python-53p2</guid>
      <description>&lt;p&gt;#datetime #pytz #tkinter&lt;br&gt;
I am still learning python and I am pumped up to get better at it each and every day. I have realized to get better at any language is through creating projects after learning something for example a library. I learnt the date time library and I decided to to create a digital clock in order to sharpen my skills. I decided to share with you guys what I  have created so that some one out there can learn something. The program has GUI(tkinter) where by i implemented dropdown list that has options of time zones using the pytz module.&lt;br&gt;
A user can select a time zone of his or her choice and the current time will be displayed in relation to the time zone. &lt;br&gt;
Check the code below.&lt;br&gt;
check our code running on youtube&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=C9Xke1aG7Ww"&gt;https://www.youtube.com/watch?v=C9Xke1aG7Ww&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"""&lt;br&gt;
A digital clock &lt;br&gt;
-&amp;gt;made this project when leaning about the date time module&lt;br&gt;
-&amp;gt;I used the pytz module to get different time zones &lt;br&gt;
-&amp;gt;A user can change the time zone by selecting a time zone from the drop down list&lt;br&gt;
-&amp;gt;the default timezone used is 'Africa/Nairobi'-&amp;gt;&lt;br&gt;
j=0&lt;br&gt;
for i in pytz.common_timezones:&lt;br&gt;
    j+=1&lt;br&gt;
    if i=='Africa/Nairobi':&lt;br&gt;
        break &lt;br&gt;
print(j-1,i)&lt;br&gt;
Run the above code to get the timezone that 'Africa/Nairobi' belongs&lt;br&gt;
"""&lt;br&gt;
from tkinter import *&lt;br&gt;
from tkinter.font import Font#get the desired font&lt;br&gt;
import datetime&lt;br&gt;
from datetime import datetime&lt;br&gt;
import pytz&lt;/p&gt;

&lt;p&gt;win = Tk()&lt;br&gt;
win.title("Digital Clock")&lt;br&gt;
win.geometry("310x200")&lt;br&gt;
win.resizable(False,False)&lt;/p&gt;

&lt;h1&gt;
  
  
  current_time = datetime.now(pytz.timezone('Africa/Djibouti')) # get the current time
&lt;/h1&gt;

&lt;p&gt;def my_digital_clock():&lt;br&gt;
    current_time = datetime.now(pytz.timezone(timezone_list.get())) # get the current time from the drop_down list&lt;br&gt;
    time_display=current_time.strftime('%H:%M:%S')&lt;br&gt;
    digital_time_lb.config(text=time_display,fg="red")#updates the label to the current time&lt;br&gt;
    day_display=datetime.now()&lt;br&gt;
    day_display=current_time.strftime('%B,%d:%Y')&lt;br&gt;
    print(str(day_display))&lt;br&gt;
    digital_DAY_lb.config(text=day_display,fg="green")&lt;br&gt;
    #print(timezone_list.set(str(pytz.common_timezones[0])))&lt;br&gt;
    #used strftime() to format the display of the current time&lt;br&gt;
    #%H-&amp;gt;hours&lt;br&gt;
    #%M-&amp;gt;minutes&lt;br&gt;
    #%s-&amp;gt;seconds&lt;br&gt;
    #%B-&amp;gt;month name&lt;br&gt;
    #%Y-&amp;gt;year&lt;br&gt;
    #%d-&amp;gt;day&lt;br&gt;
    #change the time after a specific millisecond&lt;br&gt;
    win.after(80,my_digital_clock)&lt;/p&gt;

&lt;p&gt;my_font = Font(size=100)&lt;/p&gt;

&lt;h1&gt;
  
  
  display the time
&lt;/h1&gt;

&lt;p&gt;digital_time_lb = Label(win,font=("Times new roman",30))&lt;br&gt;
digital_time_lb.pack()&lt;/p&gt;

&lt;h1&gt;
  
  
  display the day/month/Year
&lt;/h1&gt;

&lt;p&gt;digital_DAY_lb = Label(win,font=("Times new roman",30))&lt;br&gt;
digital_DAY_lb.pack()&lt;/p&gt;

&lt;p&gt;timezone_list=StringVar()&lt;/p&gt;

&lt;h1&gt;
  
  
  set the default time zone for Nairobi
&lt;/h1&gt;

&lt;p&gt;timezone_list.set(str(pytz.common_timezones[42]))#default timezone is 'Africa/Nairobi'(42)&lt;/p&gt;

&lt;h1&gt;
  
  
  used the OptionMenu()-&amp;gt;function
&lt;/h1&gt;

&lt;p&gt;drop_down=OptionMenu(win,timezone_list,*pytz.common_timezones)&lt;br&gt;
drop_down.pack()&lt;/p&gt;

&lt;p&gt;my_digital_clock()#function call&lt;br&gt;
win.mainloop()&lt;br&gt;
"""&lt;br&gt;
add a label to dislay the time on our screen&lt;br&gt;
the time should change at a pecific time&lt;br&gt;
-&amp;gt;display the time zone &lt;br&gt;
-&amp;gt;choose the time zone and display the time&lt;br&gt;
"""&lt;br&gt;
"""&lt;br&gt;
.config()-&amp;gt;used to update the label&lt;br&gt;
win.config(text="change")&lt;br&gt;
THANK YOU &lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>tic tac toe for absolute beginners in python</title>
      <dc:creator>flavian-anselmo</dc:creator>
      <pubDate>Fri, 17 Jul 2020 21:37:48 +0000</pubDate>
      <link>https://dev.to/flaviananselmo/tic-tac-toe-for-absolute-beginners-2p3i</link>
      <guid>https://dev.to/flaviananselmo/tic-tac-toe-for-absolute-beginners-2p3i</guid>
      <description>&lt;p&gt;bod = ["0","1","2",&lt;br&gt;
       "3","4","5",&lt;br&gt;
       "6","7","8"]&lt;br&gt;
def board():&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(bod[0],'|',  bod[1],'|',  bod[2], '|')
print('----------------')
print(bod[3],'|',  bod[4],'|',  bod[5], '|')
print('----------------')
print(bod[6],'|',  bod[7],'|',  bod[8], '|')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;def game():&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while True:
    board()
    spot = int(input("choose a spot(x):"))
    bod[spot] = "x"
    """if bod[spot] == "x" or bod[spot] == "o":
        print("---spot taken---")"""
    board()
    spot_two = int(input("choose a spot(o):"))
    bod[spot_two] = "o"
    """if bod[spot] == "x" or bod[spot] == "o":
        print("---spot taken---")"""

        #player_one checks
    if bod[0] == bod[1] == bod[2] =="x":
        print("player one (x) won")
        break
    if bod[3] == bod[4] == bod[5] == "x":
        print("player one (x) won")
        break
    if bod[6] == bod[7] == bod[8] == "x":
        print("player one (x) won")
        break
    if bod[0] == bod[3] == bod[6] == "x":
        print("player one (x) won")
        break
    if bod[1] == bod[4] == bod[7] == "x":
        print("player one (x) won")
        break
    if bod[2] == bod[5] == bod[8] == "x":
        print("player one (x) won")
        break
    if bod[0] == bod[4] == bod[8] == "x":
        print("player one (x) won")
        break
    if bod[6] == bod[4] == bod[2] == "x":
        print("player one (x) won")
        break

    #player_two checks
    if bod[0] == bod[1] == bod[2] =="o":
        print("player two (o) won")
        break
    if bod[3] == bod[4] == bod[5] == "o":
        print("player two (o) won")
        break
    if bod[6] == bod[7] == bod[8] == "o":
        print("player two (o) won")
        break
    if bod[0] == bod[3] == bod[6] == "o":
        print("player two (o) won")
        break
    if bod[1] == bod[4] == bod[7] == "o":
        print("player two (o) won")
        break
    if bod[2] == bod[5] == bod[8] == "o":
        print("player two (o) won")
        break
    if bod[0] == bod[4] == bod[8] == "o":
        print("player two (o) won")
        break
    if bod[6] == bod[4] == bod[2] == "o":
        print("player two (o) won")
        break
    else:
        print("---it is a draw---")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;game()&lt;/p&gt;

</description>
      <category>t</category>
    </item>
  </channel>
</rss>
