<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Parameters on Arthurdw | Blog</title>
    <link>/tags/parameters/</link>
    <description>Recent content in Parameters on Arthurdw | Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>© Arthurdw / Xiler</copyright>
    <lastBuildDate>Thu, 15 Dec 2022 17:27:51 +0100</lastBuildDate><atom:link href="/tags/parameters/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Introduction to Python</title>
      <link>/posts/introduction-to-python/</link>
      <pubDate>Thu, 15 Dec 2022 17:27:51 +0100</pubDate>
      
      <guid>/posts/introduction-to-python/</guid>
      <description>Introduction to Python Python is a high-level, interpreted programming language that is widely used in many fields, including web development, data science, and scientific computing. It is known for its simple syntax, readability, and flexibility, which makes it a great language for beginners to learn. In this post, we will cover the basics of Python, including its data types, functions (and parameter options), imports, classes (and how to do inheritance, private variables, getters and setters).</description>
      <content>&lt;h1 id=&#34;introduction-to-python&#34;&gt;Introduction to Python&lt;/h1&gt;
&lt;p&gt;Python is a high-level, interpreted programming language that is widely used in many fields, including web development,
data science, and scientific computing. It is known for its simple syntax, readability, and flexibility, which makes it
a great language for beginners to learn. In this post, we will cover the basics of Python, including its data types,
functions &lt;em&gt;(and parameter options)&lt;/em&gt;, imports, classes &lt;em&gt;(and how to do inheritance, private variables, getters and
setters)&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id=&#34;data-types&#34;&gt;Data Types&lt;/h2&gt;
&lt;p&gt;In Python, data types are used to define the kind of value a variable holds. Some common data types in Python
are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;int&lt;/code&gt;: Integer numbers, e.g. &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, &lt;code&gt;3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;float&lt;/code&gt;: Real numbers, e.g. &lt;code&gt;3.14&lt;/code&gt;, &lt;code&gt;0.99&lt;/code&gt;, &lt;code&gt;-1.5&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;str&lt;/code&gt;: Text strings, e.g. &lt;code&gt;&amp;quot;Hello, world!&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;Python is fun!&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bool&lt;/code&gt;: Boolean values, i.e. &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can check the type of a variable using the built-in &lt;code&gt;type()&lt;/code&gt; function. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;a &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
b &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1.5&lt;/span&gt;
c &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello, world!&amp;#34;&lt;/span&gt;
d &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;True&lt;/span&gt;

print(type(a))  &lt;span style=&#34;color:#75715e&#34;&gt;# &amp;lt;class &amp;#39;int&amp;#39;&amp;gt;&lt;/span&gt;
print(type(b))  &lt;span style=&#34;color:#75715e&#34;&gt;# &amp;lt;class &amp;#39;float&amp;#39;&amp;gt;&lt;/span&gt;
print(type(c))  &lt;span style=&#34;color:#75715e&#34;&gt;# &amp;lt;class &amp;#39;str&amp;#39;&amp;gt;&lt;/span&gt;
print(type(d))  &lt;span style=&#34;color:#75715e&#34;&gt;# &amp;lt;class &amp;#39;bool&amp;#39;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;functions&#34;&gt;Functions&lt;/h2&gt;
&lt;p&gt;Functions are blocks of code that are used to perform specific tasks. In Python, we can define our own functions using
the &lt;code&gt;def&lt;/code&gt; keyword, followed by the function name and a set of parentheses &lt;code&gt;()&lt;/code&gt; containing the function&amp;rsquo;s parameters. For
example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;greet&lt;/span&gt;():
    print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello, world!&amp;#34;&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To call a function, we simply use its name followed by a set of parentheses &lt;code&gt;()&lt;/code&gt;. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;greet()  &lt;span style=&#34;color:#75715e&#34;&gt;# Hello, world!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Functions can also take arguments (i.e. input values) and return output values. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;add&lt;/span&gt;(a, b):
    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; a &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; b

result &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; add(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;parameters&#34;&gt;Parameters&lt;/h3&gt;
&lt;p&gt;When defining a function, we can specify its parameters in the parentheses &lt;code&gt;()&lt;/code&gt; following the function name. These
parameters are used to pass input values to the function when it is called. In Python, there are three types of
parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;args&lt;/code&gt;: Positional arguments, which are passed to the function in the same order as they are defined.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;kwargs&lt;/code&gt;: Keyword arguments, which are passed to the function using the name of the argument, followed by an equals
sign &lt;code&gt;=&lt;/code&gt; and the value.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;default&lt;/code&gt;: Default parameters, which are optional parameters that have predefined default values. If a default
parameter is not specified when the function is called, its default value will be used.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is an example of a function that uses all three types of parameters:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;display_info&lt;/span&gt;(name, &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;args, age&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;None&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;kwargs):
    print(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Name: &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;name&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)
    print(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Age: &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;age&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)
    
    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; arg &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; args:
        print(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Extra argument: &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;arg&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)
        
    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; k, v &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; kwargs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;items():
        print(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;k&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;v&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)
        
display_info(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Arthur&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;first extra argument&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;second extra argument&amp;#34;&lt;/span&gt;, extra_kwargs&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;this argument&amp;#34;&lt;/span&gt;, age&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;19&lt;/span&gt;)
&lt;span style=&#34;color:#75715e&#34;&gt;# Name: Arthur&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;# Age: 19&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;# Extra argument: first extra argument&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;# Extra argument: second extra argument&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;# extra_kwargs: this argument&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;imports&#34;&gt;Imports&lt;/h2&gt;
&lt;p&gt;In Python, we can import code from other modules (i.e. files containing Python code) using the &lt;code&gt;import&lt;/code&gt; keyword. This
allows us to use the functions, classes, and other objects defined in the imported module in our own code. For example,
we can import the built-in &lt;code&gt;math&lt;/code&gt; module to access mathematical functions, such as &lt;code&gt;sin&lt;/code&gt;, &lt;code&gt;cos&lt;/code&gt;, and &lt;code&gt;sqrt&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; math

x &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;sin(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 0.8414709848078965&lt;/span&gt;
y &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;cos(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 0.5403023058681398&lt;/span&gt;
z &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;sqrt(&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 1.4142135623730951&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also import specific objects from a module using the &lt;code&gt;from&lt;/code&gt; keyword, followed by the module name and the object(
s) we want to import, separated by commas. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; math &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; sin, cos, sqrt

x &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; sin(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 0.8414709848078965&lt;/span&gt;
y &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; cos(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 0.5403023058681398&lt;/span&gt;
z &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; sqrt(&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)  &lt;span style=&#34;color:#75715e&#34;&gt;# 1.4142135623730951&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;classes&#34;&gt;Classes&lt;/h2&gt;
&lt;p&gt;In Python, a class is a blueprint for creating objects. It defines the attributes (i.e. data) and methods (i.e.
functions) that an object of that class will have. To create a class, we use the &lt;code&gt;class&lt;/code&gt; keyword, followed by the class
name and a colon &lt;code&gt;:&lt;/code&gt;. Then, we define the attributes and methods inside the class using the self keyword to refer to the
current object. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Point&lt;/span&gt;:
    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; __init__(self, x, y):
        self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;x &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; x
        self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;y &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; y

    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;distance&lt;/span&gt;(self, other):
        dx &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;x &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; other&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;x
        dy &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;y &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; other&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;y
        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;sqrt(dx&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; dy&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, we have defined a &lt;code&gt;Point&lt;/code&gt; class with two attributes, &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, and a method, &lt;code&gt;distance&lt;/code&gt;, which calculates the
distance between two &lt;code&gt;Point&lt;/code&gt; objects. To create an object of a class, we use the class name followed by a set of
parentheses &lt;code&gt;()&lt;/code&gt; containing any required arguments. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;p1 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Point(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)
p2 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Point(&lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt;)

print(p1&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;x)  &lt;span style=&#34;color:#75715e&#34;&gt;# 1&lt;/span&gt;
print(p1&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;y)  &lt;span style=&#34;color:#75715e&#34;&gt;# 2&lt;/span&gt;
print(p1&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;distance(p2))  &lt;span style=&#34;color:#75715e&#34;&gt;# 2.8284271247461903&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;inheritance&#34;&gt;Inheritance&lt;/h3&gt;
&lt;p&gt;In Python, inheritance allows us to define a new class that inherits the attributes and methods of an existing class.
This allows us to reuse code and create a hierarchical structure of classes. To create a class that inherits from
another class, we use the &lt;code&gt;class&lt;/code&gt; keyword followed by the new class name, the &lt;code&gt;inherits&lt;/code&gt; keyword, and the name of the
parent class. For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Circle&lt;/span&gt;(Point):
    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; __init__(self, x, y, radius):
        super()&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__init__(x, y)  &lt;span style=&#34;color:#75715e&#34;&gt;# call the parent class&amp;#39;s __init__ method&lt;/span&gt;
        self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;radius &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; radius

    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;area&lt;/span&gt;(self):
        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;pi &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;radius&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;private-variables-and-methods&#34;&gt;Private Variables and Methods&lt;/h2&gt;
&lt;p&gt;In Python, we can define private variables and methods, which cannot be accessed or modified from outside the class.
Private variables and methods are prefixed with two underscores &lt;code&gt;__&lt;/code&gt;, which is called the &amp;ldquo;name mangling&amp;rdquo; syntax.
However, this syntax only serves as a convention, and does not prevent external access to the private attribute. To
truly prevent external access, we can use &amp;ldquo;getter&amp;rdquo; and &amp;ldquo;setter&amp;rdquo; methods, which are decorated with the &lt;code&gt;@property&lt;/code&gt;
and &lt;code&gt;@attribute.setter&lt;/code&gt; decorators, respectively.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Circle&lt;/span&gt;(Point):
    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; __init__(self, x, y, radius):
        super()&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__init__(x, y)  &lt;span style=&#34;color:#75715e&#34;&gt;# call the parent class&amp;#39;s __init__ method&lt;/span&gt;
        self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__radius &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; radius

    &lt;span style=&#34;color:#a6e22e&#34;&gt;@property&lt;/span&gt;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;radius&lt;/span&gt;(self):
        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__radius

    &lt;span style=&#34;color:#a6e22e&#34;&gt;@radius&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;setter
    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;radius&lt;/span&gt;(self, radius):
        self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__radius &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; radius

    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;area&lt;/span&gt;(self):
        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; math&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;pi &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;__radius&lt;span style=&#34;color:#f92672&#34;&gt;**&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, the &lt;code&gt;__radius&lt;/code&gt; attribute is private, so it cannot be accessed or modified directly from outside the class.
Instead, we have defined &lt;code&gt;radius&lt;/code&gt; as a property using the &lt;code&gt;@property&lt;/code&gt; decorator, which allows us to access the value of
the __ radius attribute using dot notation (e.g. &lt;code&gt;circle.radius&lt;/code&gt;). We have also defined the radius attribute as a setter
using the @radius.setter decorator, which allows us to update the value of the &lt;code&gt;__radius&lt;/code&gt; attribute using dot notation (
e.g. &lt;code&gt;circle.radius = 4&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-py&#34; data-lang=&#34;py&#34;&gt;c &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Circle(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;)

print(c&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;radius)  &lt;span style=&#34;color:#75715e&#34;&gt;# 3&lt;/span&gt;
c&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;radius &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;4&lt;/span&gt;
print(c&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;radius)  &lt;span style=&#34;color:#75715e&#34;&gt;# 4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that while getters and setters provide a more robust way to prevent external access to private attributes, they are
not completely foolproof. Therefore, private variables and methods should not be used for security purposes. They are
primarily used for encapsulation, i.e. to prevent accidental modification of an object&amp;rsquo;s internal state.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In conclusion, Python is a powerful, versatile programming language that is widely used in many fields. It has a simple
syntax, making it easy to learn and read. In this post, we have covered the basics of Python, including its data types,
functions, parameters, imports, classes, and inheritance. By understanding these concepts, you can start writing your
own programs in Python and take advantage of its many features.&lt;/p&gt;
</content>
    </item>
    
  </channel>
</rss>
