<?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: chepkirui DOROTHY</title>
    <description>The latest articles on DEV Community by chepkirui DOROTHY (@chepkiruidorothy).</description>
    <link>https://dev.to/chepkiruidorothy</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%2F893995%2Fead8c30d-f32a-4045-b221-8f4f0ef32851.jpeg</url>
      <title>DEV Community: chepkirui DOROTHY</title>
      <link>https://dev.to/chepkiruidorothy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chepkiruidorothy"/>
    <language>en</language>
    <item>
      <title>Understanding data types in Python.</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Wed, 29 Mar 2023 15:07:09 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/understanding-data-types-in-python-k1h</link>
      <guid>https://dev.to/chepkiruidorothy/understanding-data-types-in-python-k1h</guid>
      <description>&lt;p&gt;Variables in Python belong to a data type. A data type is a classification that shows which value a variable has. It ensures that correct operations are done to the variable without causing errors.&lt;/p&gt;

&lt;p&gt;Data types in python fall into two categories: primitive and non-primitive types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitive data types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Primitive data types contain simple values of data and are building blocks. They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Integer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Float&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Boolean&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets look into each and their properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An integer is numerical data type that represents a whole number, both negative and positive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
num = 6

print(type(num))



&amp;lt;class 'int'&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can do arithmetic operations to them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = -6

y = 5

print( "-6 + 5 is" , x + y )#addition

print( "-6 - 5 is" ,x - y )#subtraction

print( "-6 *5 is" ,x* y )#multiplication

print( "-6 / 5 is" ,x / y )#division

print( "-6 % 5 is" ,x % y )#modulus



-6 + 5 is -1

-6 - 5 is -11

-6 * 5 is -30

-6 / 5 is -1.2

-6 % 5 is 4

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Float&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A float is a numeric data type used to represent decimal numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
num = 6.0

print(type(num))



&amp;lt;class 'float'&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also do arithmetic operations, just like the integers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = -6.0

y = 5

print( "-6 + 5 is" , x + y )#addition

print( "-6 - 5 is" ,x - y )#subtraction

print( "-6 *5 is" ,x* y )#multiplication

print( "-6 / 5 is" ,x / y )#division

print( "-6 % 5 is" ,x % y )#modulus



-6 + 5 is -1.0

-6 - 5 is -11.0

-6 * 5 is -30.0

-6 / 5 is -1.2

-6 % 5 is 4.0

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Strings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A string is a collection on characters. An example is a name - like Aron. Aron is made up of four characters, a,r, o, n. They are enclosed with either single quotes or double quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
name = 'Aron'

surname = "Koech"

print(type(name))

print(name)

print(type(surname))

print(surname)



&amp;lt;class 'str'&amp;gt;
Aron
&amp;lt;class 'str'&amp;gt;
Koech

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can concatenate the variables to be one word.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(name +' '+ surname)

print(name , surname)



Aron Koech

Aron Koech

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have combined the name and surname using string concatenation in the first line, with a space in between.&lt;/p&gt;

&lt;p&gt;The second line of code uses comma-separated values to give the same output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boolean&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Boolean is a data type that represents a binary value, either True or False. It is commonly used to evaluate conditions in decision making processes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = -6

y = 5

print(x == y)



False

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;==(equality operator) is used to check if x and y variables are equal. If they are equal, it prints True, otherwise False.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-primitive data types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They are complex data types, that can store collection of values in different formats. They are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Lists&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tuples&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dictionaries&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lists&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lists are data types that store a collection of values, such as integers and strings. They are stored inside [] brackets. Lists are ordered, meaning the order will not change. They are also mutable, meaning the elements can be modified after they have been created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = [1, 2, 3, 4, 5] # creates a list of integers

colors = ['blue', 'pink', 'yellow', 'brown'] # creates a list of strings

list = [5, 10.4, 'Purple', False] # creates a list of mixed data types

print(x)

print(colors)

print(list)



[1, 2, 3, 4, 5]

['blue', 'pink', 'yellow', 'brown']

[5, 10.4, 'Purple', False]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To access an element in the list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(colors[2])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints the color element at index 2, which is yellow.&lt;/p&gt;

&lt;p&gt;Lists can also be sliced.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(colors[2:])

print(x[1:3])

print(list[:2])



['yellow', 'brown']

[2, 3]

[5, 10.4]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can change an element in a list. Suppose we want to replace the second color to purple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
colors[1] = 'purple'

print(colors)



['blue', 'purple', 'yellow', 'brown']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tuples&lt;/p&gt;

&lt;p&gt;Tuples are data types that contain ordered, immutable elements. The elements are enclosed in&lt;/p&gt;

&lt;p&gt;( ) brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = (1, 2, 3, 4, 5)

print(x)



(1, 2, 3, 4, 5)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can access individual elements in a tuple by indexing, just like lists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(x[2])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints the element in index 2, which is 3.&lt;/p&gt;

&lt;p&gt;We can also access the range of elements using slicing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(x[2:])



(3, 4, 5)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints the elements from index 2 to the last element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sets are collection of unique elements. They are unordered and mutable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
x = (1,2,1,3,2,3,2,4,4,5)

print(set(x))



{1, 2, 3, 4, 5}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only the unique elements are printed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dictionaries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dictionaries are data types that are made up of key-value elements in pairs.&lt;/p&gt;

&lt;p&gt;They are stored using curly {} brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
dict = {'Eliud':1, 'Peter':2, 'Andrew':3, 'Mike':4}

print(dict)



{'Eliud': 1, 'Peter': 2, 'Andrew': 3, 'Mike': 4}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can access individual values by referring to their keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(dict['Eliud'])

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return 1, which is its key.&lt;/p&gt;

&lt;p&gt;You can also change the value of the keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
dict['Eliud']=10

print(dict)



{'Eliud': 10, 'Peter': 2, 'Andrew': 3, 'Mike': 4}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Data types are categorized into primitive and non-primitive. There is still more to cover on data types. Check out &lt;a href="https://docs.python.org/3/library/datatypes.html"&gt;python data types&lt;/a&gt; to learn more.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building Age Calculator Using Tkinter In Python</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Tue, 27 Sep 2022 10:08:11 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/building-age-calculator-using-tkinter-in-python-1d4g</link>
      <guid>https://dev.to/chepkiruidorothy/building-age-calculator-using-tkinter-in-python-1d4g</guid>
      <description>&lt;p&gt;Suppose we want to create an application whereby one can input their birthdate and the program will calculate their age.&lt;/p&gt;

&lt;p&gt;We will be building an age calculator using Tkinter. Tkinter is the standard library in Python used to create Graphical User interfaces (GUIs). We will also import the datetime module, which supplies classes for manipulating dates and times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Importing required modules&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will first install the modules needed from the command line interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install tkinter

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;datetime&lt;/em&gt; is a built-in Python module. We do not need to install it as it is already there.&lt;/p&gt;

&lt;p&gt;Next, we import the modules in our code editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from tkinter import *
from datetime import date, datetime

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are importing all libraries in the &lt;em&gt;tkinter&lt;/em&gt; module. We also import &lt;em&gt;date&lt;/em&gt; and &lt;em&gt;datetime&lt;/em&gt; libraries from &lt;em&gt;datetime&lt;/em&gt; module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Designing the interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will then design what our age calculator interface will look like. We will be using some of the tkinter widgets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Label - a widget used to specify the display boxes where we can place the text or images.&lt;/li&gt;
&lt;li&gt;Button - is used to add buttons that can display texts or images that convey the purpose of the buttons.&lt;/li&gt;
&lt;li&gt;Entry - a widget used to accept single-line text strings from a user.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;root = Tk() #initializes tkinter to create display window
root.geometry('500x300') # width and height of the window
root.resizable(0, 0) # sets fix size of window
root.title(' Age calculator') # gives the window a title

#the rest of the code

root.mainloop()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We first create a tkinter instance called root, which aids in the display of the root window and manages all of the other tkinter application components. We then set the width and height of the window, and give it a title. The &lt;em&gt;mainloop()&lt;/em&gt; method runs the script and displays the output window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yourAge = Label(root,fg="red",text = "Date Month Year",font='arial 12 bold').place(x = 210)
setYourAlarm = Label(root,text = "Enter birthday: ",bg="grey",font="arial 11 bold").place(x=80, y=40)

date = StringVar()
month = StringVar()
year = StringVar()

dateTime= Entry(root,textvariable = date, relief = RAISED, width = 4,font=(20)).place(x=210,y=40)
monthTime= Entry(root,textvariable = month,width = 4,font=(20)).place(x=270,y=40)
yearTime = Entry(root,textvariable = year,width = 4,font=(20)).place(x=330,y=40)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We create label widgets, which will display where the date, month, and year data will be input.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;StringVar()&lt;/em&gt; is used to edit a widget's text, and determine whether they have been read, overwritten, or do not exist at all. We create entry widgets for the date, month, and year where one will input their birthday. &lt;em&gt;StringVar()&lt;/em&gt; then holds the string data.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;place()&lt;/em&gt; method allows us to position our widgets by setting corresponding x and y values.&lt;/p&gt;

&lt;p&gt;The interface so far looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zFuZs3gf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664273000787/X_-xNw50a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zFuZs3gf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664273000787/X_-xNw50a.png" alt="Screenshot from 2022-09-08 14-37-47.png" width="502" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding age function&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;def age():
    # Get current date
    today = datetime.today().date()

    setAge_year = int(year.get())
    setAge_month = int(month.get())
    setAge_date = int(date.get())

    current_age = today.year-int(setAge_year)
    if today.month &amp;lt; setAge_month or today.month == setAge_month and today.day &amp;lt; setAge_date:
         current_age -= 1

    CurrentLabel = Label(root, text=f'You are: {current_age} years old',fg='black')
    CurrentLabel.place(relx=0.2, rely=0.8, anchor=CENTER)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We first define a function &lt;em&gt;age&lt;/em&gt;. We then get the current date by using the &lt;em&gt;datetime&lt;/em&gt; method. The function then gets the three entries and finds the difference between the current year and the input year. It then checks to make sure that the input month and date are greater than the current month and date. If not, it means the current age is less by one year.&lt;/p&gt;

&lt;p&gt;We then create a label widget that will display the user's age.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating buttons&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We then create two buttons, one which the user clicks to get their age, and another which when clicked destroys the window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;submit = Button(root,text = "Calculate your age",fg="red",width = 20,command=age,font=("arial 15 bold" )).place(x=90,y=100)
exit = Button(root,text = "Exit",fg="red",width = 10,command=root.destroy,font=("arial 20 bold" )).place(x=150,y=140)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final interface will be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eQYdM6GO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664272749334/r4DeyaXAK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eQYdM6GO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664272749334/r4DeyaXAK.png" alt="Screenshot from 2022-09-08 14-57-47.png" width="502" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we input date, month, and year, it calculates the age.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f0M4iXvx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664272795292/gKzShAd_Y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f0M4iXvx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1664272795292/gKzShAd_Y.png" alt="Screenshot from 2022-09-08 14-58-29.png" width="502" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The complete code is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from tkinter import *
from datetime import date, datetime

root = Tk() #initializes tkinter to create display window
root.geometry('500x300') # width and height of the window
root.resizable(0, 0) # sets fix size of window
root.title(' Age calculator') # gives the window a title

yourAge = Label(root,fg="red",text = "Date Month Year",font='arial 12 bold').place(x = 210)
setYourAlarm = Label(root,text = "Enter birthday: ",bg="grey",font="arial 11 bold").place(x=80, y=40)

date = StringVar()
month = StringVar()
year = StringVar()

dateTime= Entry(root,textvariable = date, relief = RAISED, width = 4,font=(20)).place(x=210,y=40)
monthTime= Entry(root,textvariable = month,width = 4,font=(20)).place(x=270,y=40)
yearTime = Entry(root,textvariable = year,width = 4,font=(20)).place(x=330,y=40)

def age():
    # Get current date
    today = datetime.today().date()

    setAge_year = int(year.get())
    setAge_month = int(month.get())
    setAge_date = int(date.get())

    current_age = today.year-int(setAge_year)
    if today.month &amp;lt; setAge_month or today.month == setAge_month and today.day &amp;lt; setAge_date:
         current_age -= 1

    CurrentLabel = Label(root, text=f'You are: {current_age} years old',fg='black')
    CurrentLabel.place(relx=0.2, rely=0.8, anchor=CENTER)

submit = Button(root,text = "Calculate your age",fg="red",width = 20,command=age,font=("arial 15 bold" )).place(x=90,y=100)
exit = Button(root,text = "Exit",fg="red",width = 10,command=root.destroy,font=("arial 20 bold" )).place(x=150,y=140)

root.mainloop()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have successfully created an age calculator in python using &lt;em&gt;tkinter&lt;/em&gt;. Happy coding.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Django ORM in a nutshell</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Wed, 17 Aug 2022 13:57:39 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/django-orm-in-a-nutshell-378l</link>
      <guid>https://dev.to/chepkiruidorothy/django-orm-in-a-nutshell-378l</guid>
      <description>&lt;p&gt;Python's Django framework, would not be complete if it did not include a way to interact with databases. The feature that makes it more powerful is its ORM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is ORM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ORM (Object-Relational Mapping) is a technique that uses an object-oriented paradigm to query and manipulate data from a database. Django has used this technique to create its own Object Relational Mapper, also known as Django ORM. It is used to query and retrieve data from various relational databases, such as SQLite, PostgreSQL, and MySQL. Simply put, Django ORM is a database-abstraction API that lets you create, retrieve, update and delete objects. The ORM automates this transmission, so the developer does not need to write any SQL. This speeds up and eliminates errors throughout the development process.&lt;/p&gt;

&lt;p&gt;Django ORM provides an alternative to writing the good old Structured Query Language (SQL). Let's create a simple bank account database to better understand how to query data using Django ORM. Bank has a customer, while the customer has one or many accounts. It has two models, Customer and Account. The Customer model has a user field, while the Account model has four fields; name, balance, customer and timestamp. The customer model has used Django's built-in User model. This tutorial will not go into detail about the User model. To better understand how the User model works, check &lt;a href="https://docs.djangoproject.com/en/4.0/topics/auth/default/#user-objects"&gt;User&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Create a &lt;em&gt;models.py&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class Customer(models.Model):
    user=models.OneToOneField(User, on_delete=models.CASCADE)

    def __str__ (self):
        return self.user.username

class Account(models.Model):
    name = models.CharField(max_length=30, unique=True, default='')
    balance=models.DecimalField( max_digits=12, decimal_places=2)
    customer=models.ForeignKey(Customer, on_delete=models.CASCADE)
    timestamp = models.DateTimeField(auto_now_add = True)

    def __str__ (self):
        return self.name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Django Field types used are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OneToOneField&lt;/strong&gt; - is used to define a one-to-one relationship, whereby one record in one table corresponds to one and only one record in another table. Here, Customer has a One-To-One relationship with the existing User model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;CharField&lt;/em&gt;&lt;/strong&gt; - A field where text-based data can be stored. In the Accounts model, the name of the account should have a maximum length of 30 and be unique.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;DecimalField&lt;/em&gt;&lt;/strong&gt; - It is a fixed-precision decimal number represented by a Decimal object in Python. Accounts balance has a maximum digit of twelve with two decimal points.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;DateTimeField&lt;/em&gt;&lt;/strong&gt; - A field to store date and time, represented in Python by a &lt;em&gt;datetime.datetime&lt;/em&gt; instance. &lt;em&gt;auto_now_add&lt;/em&gt; means that when the object is first created, the field is automatically set to that time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;ForeignKey&lt;/em&gt;&lt;/strong&gt; - It is used to define a &lt;em&gt;many-to-one&lt;/em&gt; relationship. A customer can have many accounts, but one account cannot be held by more than one customer. &lt;em&gt;on_delete=models.CASCADE&lt;/em&gt; tells Django that when the referenced item is deleted, all objects with references to it are also deleted. In this case, when a customer is deleted, Django deletes their accounts as well.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After creating a sample database above, run migrations. Migrations are Djangos way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py migrate

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xdhas7j5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659697214924/wnk-cRwr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xdhas7j5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659697214924/wnk-cRwr8.png" alt="Screenshot from 2022-08-05 13-59-47.png" width="786" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Django shell provides easy access to ORM, allowing you to easily interact with the database. To access the shell, run the following command from the main directory of your Django project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py shell

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iaN4WJTe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659697331308/m4nEmRsd2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iaN4WJTe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1659697331308/m4nEmRsd2.png" alt="Screenshot from 2022-08-05 14-01-25.png" width="786" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Import all models to the interactive console you have just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; from bank.models import *
&amp;gt;&amp;gt;&amp;gt; from django.contrib.auth.models import User

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This imports Customer, Accounts and User models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Django employs an easy-to-use mechanism to express database-table data in Python objects: A model class represents a database table, while a model instance in that class represents a specific entry in the database table. To create an object, use &lt;strong&gt;create()&lt;/strong&gt; method which takes keyword arguments. Here, &lt;em&gt;first_name&lt;/em&gt;, &lt;em&gt;last_name&lt;/em&gt; and &lt;em&gt;username&lt;/em&gt; are keyword arguments. Then use the &lt;strong&gt;save()&lt;/strong&gt; method to save it in the database.&lt;/p&gt;

&lt;p&gt;To create a new user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; d=User.objects.create(first_name='tom',last_name='holland', username='holland')
d.save()

e = User.objects.create(first_name= 'jake', last_name= 'candy', username= 'candy')
e.save()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check that the user objects have been saved:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; User.objects.all()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;all()&lt;/strong&gt;method returns a QuerySet of all the objects in the database. This will return all the user objects created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RU-LTy7o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660556476393/PGNGBRsfk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RU-LTy7o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660556476393/PGNGBRsfk.png" alt="Screenshot from 2022-08-15 12-39-51.png" width="660" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have created user objects. To create customer objects, pass the parent object as this objects primary key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cust1 = Customer(user=d)
cust1.save()

cust2 = Customer(user=e)
cust2.save()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To check saved customers,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Customer.objects.all()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the list of all the customers that you have created. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cpSpN98A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660556941383/siivExVR5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cpSpN98A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660556941383/siivExVR5.png" alt="Screenshot from 2022-08-15 12-48-53.png" width="660" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To retrieve objects from the database, use &lt;strong&gt;get()&lt;/strong&gt; or &lt;strong&gt;filter()&lt;/strong&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d=User.objects.get(username='richie')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;get()&lt;/strong&gt; is used to return a required object. If the item doesn't exist or if there are multiple items that meet your criteria, it throws an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;filter()&lt;/strong&gt; returns a queryset object if more than one object matches your query. If no matching items were found, it returns an empty Queryset without throwing an error.&lt;/p&gt;

&lt;p&gt;Let's say you had users who shared the same first name, Jane.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a= User.objects.filter(first_name='jane')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result will be a Queryset will all users whose first name is jane.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can make changes to a user's data and update them on the database by using &lt;strong&gt;save()&lt;/strong&gt; method. If you wanted to change &lt;em&gt;cust1&lt;/em&gt; username from richie to richard and update the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d=User.objects.get(username='richie')
d.username='richard'
d.save()

cust1=Customer.objects.get(user=d)
cust1.save()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Delete objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Django auto-generates a primary key called &lt;em&gt;id&lt;/em&gt; by default if you did not specify one. The customer objects can be accessed by using &lt;em&gt;id&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;b=Customer.objects.get(id=2)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output is the corresponding Customer object. To delete the above Customer object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;b=Customer.objects.get(id=2).delete()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x_EJ6Pwb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660724620612/L8EjaY0L_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x_EJ6Pwb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660724620612/L8EjaY0L_.png" alt="Screenshot from 2022-08-17 11-23-06.png" width="786" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The changes made in Django shell are available in the Django admin interface. The following images show users and customers respectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XC7dYWp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660743563935/8o_aX1EhO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XC7dYWp6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660743563935/8o_aX1EhO.png" alt="Screenshot from 2022-08-17 16-22-21.png" width="880" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4RGvkQAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660743575796/k6d7tUlTf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4RGvkQAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1660743575796/k6d7tUlTf.png" alt="Screenshot from 2022-08-17 16-22-27.png" width="880" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have learned how to create, update, read and delete data in Django using its ORM. This sums up the basic functionalities to get you started querying databases. Happy coding.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Getting started with Django</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Fri, 29 Jul 2022 07:52:48 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/getting-started-with-django-4435</link>
      <guid>https://dev.to/chepkiruidorothy/getting-started-with-django-4435</guid>
      <description>&lt;p&gt;Liquid syntax error: Unknown tag 'block'&lt;/p&gt;
</description>
    </item>
    <item>
      <title>How to create a YouTube video downloader with python</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Mon, 25 Jul 2022 14:01:21 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/how-to-create-a-youtube-video-downloader-with-python-3li1</link>
      <guid>https://dev.to/chepkiruidorothy/how-to-create-a-youtube-video-downloader-with-python-3li1</guid>
      <description>&lt;p&gt;If you have tried to download a YouTube video before, then you know the frustration of going through a million ads, just to get a two megabyte file. In this article, we will create our own simple YouTube video downloader using python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we begin, you should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;python. If not, follow &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;this&lt;/a&gt; guide to install it. &lt;/li&gt;
&lt;li&gt;a code editor&lt;/li&gt;
&lt;li&gt;Pytube &lt;/li&gt;
&lt;li&gt;Tkinter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pytube is a lightweight Python library for downloading youtube videos. Tkinter is a standard GUI( Graphical user interface) library for python.&lt;/p&gt;

&lt;p&gt;To install Pytube and Tkinter, run the following commands on CLI(command line interface) using pip installer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install tk
Pip install pytube

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are using python 2.x, install Tkinter as Tkinter(notice the uppercase T).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install Tkinter

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will follow the following steps in building a YouTube downloader:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import required libraries&lt;/li&gt;
&lt;li&gt;Create display window&lt;/li&gt;
&lt;li&gt;Create link entry&lt;/li&gt;
&lt;li&gt;Create download function&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Import required libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to import the modules that we installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from tkinter import * //import all libraries from tkinter module
from pytube import YouTube // import YouTube library from pytube module

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Create a display window&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;root = Tk() //initializes tkinter to create display window
root.geometry('400x250') // width and height of the window
root.resizable(0, 0) // sets fix size of window
root.title(' our awesome youtube downloader') // gives the window a title

Label(root,text = 'Youtube Video Downloader', font ='arial 20 bold').pack()
//The rest of the code 

root.mainloop() // executes when we want to run the program

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Label()&lt;/strong&gt; widget above displays texts that users cannot modify.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;root&lt;/strong&gt; is the name of the window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we run the code above, it gives us a blank window. The remaining code will go in between the Tk() and mainloop(). The resulting window is as below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754045980%2F-tg7R-LJq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754045980%2F-tg7R-LJq.png" alt="Screenshot from 2022-07-25 12-38-08.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Create link entry&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next step is to create an entry where we can paste a YouTube link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var = StringVar() // specifies variable type
Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x= 100 , y = 60)

label = Message( root, textvariable = var, relief = RAISED )
link_enter = Entry(root, width = 70,textvariable = var).place(x = 32, y = 90)

var.set('Paste Link Here:')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;var&lt;/strong&gt; stores the URL entered as string.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Entry()&lt;/strong&gt; widget is used when we want to create a text field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;textvariable&lt;/strong&gt; is used to obtain the current text variable's value for the entry widget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;place()&lt;/strong&gt; is used to position the widget at a certain location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The output of the above code is as shown in the picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754420662%2Fsb9UowDIT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754420662%2Fsb9UowDIT.png" alt="Screenshot from 2022-07-25 16-04-17.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create download function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our window up and running, we need to create a function to download the videos. We also need a button that when clicked, will call this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def Downloader():
    url =YouTube(str(var.get())) // gets youtube link from link entered and converts it to string
    video = url.streams.first() // video is downloaded in the first stream the video is in
    video.download() // initializes the download
    Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210) // shows "DOWNLOADED" when the download is complete
Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'red', padx = 2, command = Downloader).place(x=180 ,y = 150)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function &lt;em&gt;Downloader&lt;/em&gt; above takes a YouTube URL entered, looks for the first stream (360p, 720p,1080p e.t.c) and downloads the video. The final output is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658755167748%2Fvar15gpk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658755167748%2Fvar15gpk4.png" alt="Screenshot from 2022-07-25 16-19-12.png"&gt;&lt;/a&gt;After pasting the URL as below, hit the &lt;em&gt;DOWNLOAD&lt;/em&gt; button. Wait a few seconds, and you should have your video downloaded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658757451278%2F5S6mg6jin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658757451278%2F5S6mg6jin.png" alt="Screenshot from 2022-07-25 16-56-11.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have successfully developed a youtube video downloader using python. I hope this has been helpful. Thanks for reading.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build a simple YouTube video downloader with python</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Mon, 25 Jul 2022 14:01:21 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/build-a-simple-youtube-video-downloader-with-python-1ein</link>
      <guid>https://dev.to/chepkiruidorothy/build-a-simple-youtube-video-downloader-with-python-1ein</guid>
      <description>&lt;p&gt;If you have tried to download a YouTube video before, then you know the frustration of going through a million ads, just to get a two megabyte file. In this article, we will create our own simple YouTube video downloader using python.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we begin, you should have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;python. If not, follow &lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;this&lt;/a&gt; guide to install it. &lt;/li&gt;
&lt;li&gt;a code editor&lt;/li&gt;
&lt;li&gt;Pytube &lt;/li&gt;
&lt;li&gt;Tkinter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pytube is a lightweight Python library for downloading youtube videos. Tkinter is a standard GUI( Graphical user interface) library for python.&lt;/p&gt;

&lt;p&gt;To install Pytube and Tkinter, run the following commands on CLI(command line interface) using pip installer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install tk
Pip install pytube

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are using python 2.x, install Tkinter as Tkinter(notice the uppercase T).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install Tkinter

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will follow the following steps in building a YouTube downloader:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Import required libraries&lt;/li&gt;
&lt;li&gt;Create display window&lt;/li&gt;
&lt;li&gt;Create link entry&lt;/li&gt;
&lt;li&gt;Create download function&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Import required libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to import the modules that we installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from tkinter import * # import all libraries from tkinter module
from pytube import YouTube # import YouTube library from pytube module

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Create a display window&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;root = Tk() # initializes tkinter to create display window
root.geometry('400x250') # width and height of the window
root.resizable(0, 0) # sets fix size of window
root.title(' our awesome youtube downloader') # gives the window a title

Label(root,text = 'Youtube Video Downloader', font ='arial 20 bold').pack()
# The rest of the code 

root.mainloop() # executes when we want to run the program

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Label()&lt;/strong&gt; widget above displays texts that users cannot modify.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;root&lt;/strong&gt; is the name of the window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we run the code above, it gives us a blank window. The remaining code will go in between the Tk() and mainloop(). The resulting window is as below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754045980%2F-tg7R-LJq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754045980%2F-tg7R-LJq.png" alt="Screenshot from 2022-07-25 12-38-08.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Create link entry&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next step is to create an entry where we can paste a YouTube link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var = StringVar() # specifies variable type
Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x= 100 , y = 60)

label = Message( root, textvariable = var, relief = RAISED )
link_enter = Entry(root, width = 70,textvariable = var).place(x = 32, y = 90)

var.set('Paste Link Here:')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;var&lt;/strong&gt; stores the URL entered as string.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Entry()&lt;/strong&gt; widget is used when we want to create a text field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;textvariable&lt;/strong&gt; is used to obtain the current text variable's value for the entry widget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;place()&lt;/strong&gt; is used to position the widget at a certain location.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The output of the above code is as shown in the picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754420662%2Fsb9UowDIT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658754420662%2Fsb9UowDIT.png" alt="Screenshot from 2022-07-25 16-04-17.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create download function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our window up and running, we need to create a function to download the videos. We also need a button that when clicked, will call this function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def Downloader():
    url =YouTube(str(var.get())) # gets youtube link from link entered and converts it to string
    video = url.streams.first() # video is downloaded in the first stream the video is in
    video.download() # initializes the download
    Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210) # shows "DOWNLOADED" when the download is complete
Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'red', padx = 2, command = Downloader).place(x=180 ,y = 150)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function &lt;em&gt;Downloader&lt;/em&gt; above takes a YouTube URL entered, looks for the first stream (360p, 720p,1080p e.t.c) and downloads the video. The final output is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658755167748%2Fvar15gpk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658755167748%2Fvar15gpk4.png" alt="Screenshot from 2022-07-25 16-19-12.png"&gt;&lt;/a&gt;After pasting the URL as below, hit the &lt;em&gt;DOWNLOAD&lt;/em&gt; button. Wait a few seconds, and you should have your video downloaded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658757451278%2F5S6mg6jin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1658757451278%2F5S6mg6jin.png" alt="Screenshot from 2022-07-25 16-56-11.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have successfully developed a youtube video downloader using python. I hope this has been helpful. Thanks for reading.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>5 steps to become a self-taught software engineer</title>
      <dc:creator>chepkirui DOROTHY</dc:creator>
      <pubDate>Mon, 18 Jul 2022 14:17:08 +0000</pubDate>
      <link>https://dev.to/chepkiruidorothy/5-steps-to-become-a-self-taught-software-engineer-8i2</link>
      <guid>https://dev.to/chepkiruidorothy/5-steps-to-become-a-self-taught-software-engineer-8i2</guid>
      <description>&lt;p&gt;Many people want to be software engineers but lack the financial resources to do so. Returning to college is an option, but it is expensive and takes four years on average. A Bootcamp is another option. While this appears to be a less expensive option than college, it still necessitates some financial resources. The Bootcamp curriculum is brief and intensive, typically lasting three to six months.&lt;/p&gt;

&lt;p&gt;You may not have a lot of time if you are looking to transition from another career to coding. Learning programming in your spare time is the best option. The issue with this option is determining where to begin. The road to becoming a self-taught software engineer is not without bumps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps to being a programmer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here are five steps you can take to become a self taught software engineer without a bootcamp or degree.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose a programming language.&lt;/li&gt;
&lt;li&gt;Look for learning materials online&lt;/li&gt;
&lt;li&gt;Practice by doing&lt;/li&gt;
&lt;li&gt;Online presence&lt;/li&gt;
&lt;li&gt;Prepare for job interviews&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's examine each stage in greater detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Choose a programming language.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Do some online research and see what tickles your interest. There are many paths to choose from. Do you want to be a front-end developer? Or perhaps an Android developer? Are you an expert in iOS or data science? What you want to achieve influences the programming language you select. For example, if you want to be a front-end developer, JavaScript is your best bet. If you haven't decided which path to take, Python is the best place to start. It is the most simple language available. Java, JavaScript, C, and C++ are some other options. Make an effort to become proficient in whatever you choose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Look for learning materials online&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have picked a programming language, what next? There are numerous resources available online, but identifying the most useful ones can be difficult. You don't want to jump from one learning material to the next because the quality is subpar. This can significantly reduce your learning time. Are you comfortable with videos, blogs, or books? It is entirely up to you which one you prefer. The best place to start is freecodecamp or codecademy. Udemy videos are another viable option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Practice makes perfect.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Practice is the best way to remember something. There is nothing wrong with relying on tutorials, but you will only learn so much if you follow and do not practice. You don't want to be trapped in "tutorial hell." This is where, rather than getting your hands dirty, you rely solely on tutorials. Try to replicate what you learned on your own after each tutorial. Follow a tutorial to add new features to the program you just created. The sooner you finish tutorials, the better. As you learn, create simple programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Online visibility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A portfolio is the best way to show potential employers what you have learned. It is an online resume that allows you to showcase the projects you have worked on. Get the best projects that you are confident in for your portfolio. Look for ways to network. Is there a programming meetup in your area? You don't want to miss out on that. Can you tweet? Document your journey. Look for hackathons to attend. You have no idea where your future employer might find you. Alternatively, if you want to be a freelancer, putting yourself out there may lead to your next job. Git is a version control system that allows you to share your code with others. Maintaining a git profile while coding is a good practice because it documents your coding journey. Having your code available raises your visibility to potential employers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.Get ready for job interviews.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Potential employers and recruiters can assess your problem-solving and coding abilities during a coding interview. The best way to prepare is to use resources like leetcode, which has a large collection of interview questions. You will have plenty of opportunities to practice interview questions. This increases your chances of getting the job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, learning to code is difficult. You will have bad days where you want to quit. Persistence and resilience will eventually pay off. So don't give up; keep going.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I would recommend the following resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/"&gt;Freecodecamp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/"&gt;Codecademy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.udemy.com/course/complete-python-bootcamp/?ranMID=39197&amp;amp;ranEAID=JVFxdTr9V80&amp;amp;ranSiteID=JVFxdTr9V80-xZXOaKndYch7QdG9953_vg&amp;amp;LSNPUBID=JVFxdTr9V80&amp;amp;utm_source=aff-campaign&amp;amp;utm_medium=udemyads"&gt;2022 Complete Python Bootcamp From Zero to Hero in Python&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

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