<?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: Brian Mwangi </title>
    <description>The latest articles on DEV Community by Brian Mwangi  (@wildcard_31).</description>
    <link>https://dev.to/wildcard_31</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%2F852658%2F1d05ceb8-dfce-4af1-b0c5-6e12834fc8dd.png</url>
      <title>DEV Community: Brian Mwangi </title>
      <link>https://dev.to/wildcard_31</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wildcard_31"/>
    <language>en</language>
    <item>
      <title>Python 101: The Ultimate Python Tutorial For Beginners.</title>
      <dc:creator>Brian Mwangi </dc:creator>
      <pubDate>Sun, 24 Apr 2022 17:03:26 +0000</pubDate>
      <link>https://dev.to/wildcard_31/python-101-the-ultimate-python-tutorial-for-beginners-2h2j</link>
      <guid>https://dev.to/wildcard_31/python-101-the-ultimate-python-tutorial-for-beginners-2h2j</guid>
      <description>&lt;p&gt;Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small- and large-scale projects. Python is named after Monty Python and its famous flying circus, not the snake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where is python used?&lt;/strong&gt;&lt;br&gt;
Python is applied in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;developing websites.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;software development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;task automation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;data analysis and data visualization. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Machine Learning and Artificial Intelligence &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.python.org/downloads/"&gt;https://www.python.org/downloads/&lt;/a&gt; &lt;br&gt;
&lt;em&gt;use the link to download the latest version of python.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your first python program&lt;/strong&gt;&lt;br&gt;
There is a tradition that the first program you ever run in any language &lt;br&gt;
generates the output “Hello, world!”&lt;br&gt;
We type “print” followed by an opening round brackets and the text &lt;br&gt;
“Hello, world!” surrounded by single quotes, ending with a closing round bracket.Press enter to move to the next line&lt;br&gt;
&lt;code&gt;print('Hello, world!')&lt;/code&gt;&lt;br&gt;
The following is outputed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, world!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Note that Python, as with many but not all programming languages, is “case &lt;br&gt;
sensitive”. The word “print” is not the same as “Print” or “PRINT”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;br&gt;
A comment in Python starts with the hash character, # , and extends to the end of the physical line. It is also possible to use Triple Quotation (''') for multiline comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;br&gt;
A variable is reserved memory location (containers) to store values.Variables do not need to be declared with any particular type, and can even change type after they have been set.A variable is created the moment you first assign a value to it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It must start with a letter or the underscore character.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A variable name cannot start with a number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Variable names are case-sensitive (age, Age and AGE are three different variables)&lt;br&gt;
&lt;em&gt;keywords are not to be used as variable names&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Identifiers&lt;/strong&gt;&lt;br&gt;
A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).&lt;br&gt;
Python does not allow punctuation characters such as @, $, and % within identifiers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Literals&lt;/strong&gt;&lt;br&gt;
Literals in Python is defined as the raw data assigned to variables or constants while programming. We mainly have five types of literals which includes string literals, numeric literals, boolean literals, literal collections and a special literal None.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data types&lt;/strong&gt;&lt;br&gt;
Variables can store data of different types. &lt;br&gt;
Different types can do different things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text Type:    str&lt;/li&gt;
&lt;li&gt;Numeric Types:    int, float, complex&lt;/li&gt;
&lt;li&gt;Sequence Types:   list, tuple, range&lt;/li&gt;
&lt;li&gt;Mapping Type: dict&lt;/li&gt;
&lt;li&gt;Set Types:    set, frozenset&lt;/li&gt;
&lt;li&gt;Boolean Type: bool&lt;/li&gt;
&lt;li&gt;Binary Types: bytes, bytearray. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Operators&lt;/strong&gt;&lt;br&gt;
Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arithmetic operators&lt;/strong&gt;&lt;br&gt;
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(46 + 2)  # 48 (addition)
print(10 - 9)  # 1 (subtraction)
print(3 * 3)  # 9 (multiplication)
print(84 / 2)  # 42.0 (division)
print(2 ** 8)  # 256 (exponent)
print(11 % 2)  # 1 (remainder of the division)
print(11 // 2)  # 5 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Comparison operators&lt;/strong&gt;&lt;br&gt;
Comparison operators are used to compare values. It returns either True or False according to the condition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Comparison operators**
Comparison operators are used to compare values. It returns either True or False according to the condition.
x = 10
y = 12

# Output: x &amp;gt; y is False
print('x &amp;gt; y is',x&amp;gt;y)

# Output: x &amp;lt; y is True
print('x &amp;lt; y is',x&amp;lt;y)

# Output: x == y is False
print('x == y is',x==y)

# Output: x != y is True
print('x != y is',x!=y)

# Output: x &amp;gt;= y is False
print('x &amp;gt;= y is',x&amp;gt;=y)

# Output: x &amp;lt;= y is True
print('x &amp;lt;= y is',x&amp;lt;=y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Logical operators&lt;/strong&gt;&lt;br&gt;
Logical operators are the and, or, not operators.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = True
y = False

print('x and y is',x and y)

print('x or y is',x or y)

print('not x is',not x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other operators include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bitwise operators act on operands as if they were strings of binary digits. They operate bit by bit, hence the name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assignment operators are used in Python to assign values to variables.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conditions&lt;/strong&gt;&lt;br&gt;
Includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;if-else&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;elif&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nested if&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;if test expression:
    Body of if
elif test expression:
    Body of elif
else: 
    Body of else
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Loops&lt;/strong&gt;&lt;br&gt;
A Loop is a control flow statement that is used to repeatedly execute a group of statements as long as the condition is satisfied.&lt;br&gt;
Include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;while loop.
With the while loop we can execute a set of statements as long as a condition is true
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while condition:
    statements(code)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;for loop.&lt;br&gt;
With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;nested loops.&lt;br&gt;
Nested loops mean using a loop inside another loop. We can use any type of loop inside any type of loop&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;even_list = []
for item in range(1, 11):
    while item % 2 == 0:
        even_list.append(item)
        break
print("Even Numbers: ", even_list)

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

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt;&lt;br&gt;
A function is a block of code which only runs when it is called.&lt;br&gt;
You can pass data, known as parameters, into a function.&lt;br&gt;
A function can return data as a result.&lt;br&gt;
Creating a Function&lt;br&gt;
In Python a function is defined using the &lt;em&gt;def&lt;/em&gt; keyword:eg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_function():
  print("Hello from a function")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Information can be passed into functions as arguments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calling a function&lt;/strong&gt;&lt;br&gt;
Once we have defined a function, we can call it from another function, program, or even the Python prompt. To call a function we simply type the function name with appropriate parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def greet(name):
    """
    This function greets to
    the person passed in as
    a parameter
    """
    print("Hello, " + name + ". Good morning!")

greet('Paul')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And congratulations!&lt;br&gt;
You have completed an introductory course on Python. Well done.&lt;br&gt;
It is only an introductory course and there is more. But do not let that &lt;br&gt;
dishearten you; just take a look at what you have accomplish. &lt;/p&gt;

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