Skip to content

Commit

Permalink
Deploying to gh-pages from @ 6196b71 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Feb 11, 2024
1 parent b46d23f commit c05084c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 13 deletions.
28 changes: 16 additions & 12 deletions _sources/description.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ Commands

.. code-block:: python
# example.py
# example.py
def calculate_sum(numbers):
result = 0
for number in numbers:
result += number
return result
def calculate_sum(numbers):
result = 0
for number in numbers:
result += number
return result
class MathOperations:
def multiply(self, a, b):
answer = 0
for i in range(b):
answer += a
return answer
class MathOperations:
def multiply(self, a, b):
answer = 0
for i in range(b):
answer += a
return answer
.. code-block:: shell
Expand All @@ -152,6 +152,9 @@ Commands
results in ....

.. code-block:: python
# example.py
"""
Optimized and Documented Code.
"""
Expand Down Expand Up @@ -199,6 +202,7 @@ Commands
By using these optimizations, we improve the efficiency and readability of the code.
"""
Development
-----------

Expand Down
50 changes: 50 additions & 0 deletions description.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,56 @@ <h3>Commands<a class="headerlink" href="#commands" title="Link to this heading">
</pre></div>
</div>
<p>results in ….</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># example.py</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Optimized and Documented Code.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span>


<span class="k">def</span> <span class="nf">calculate_sum</span><span class="p">(</span><span class="n">numbers</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="nb">int</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Calculates the sum of a list of numbers.</span>

<span class="sd"> Parameters:</span>
<span class="sd"> numbers (List[int]): A list of integers.</span>

<span class="sd"> Returns:</span>
<span class="sd"> int: The sum of the numbers.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">result</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">numbers</span><span class="p">)</span>
<span class="k">return</span> <span class="n">result</span>


<span class="k">class</span> <span class="nc">MathOperations</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">multiply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Multiplies two numbers.</span>

<span class="sd"> Parameters:</span>
<span class="sd"> a (int): The first number.</span>
<span class="sd"> b (int): The second number.</span>

<span class="sd"> Returns:</span>
<span class="sd"> int: The result of multiplying a and b.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">answer</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="n">b</span>
<span class="k">return</span> <span class="n">answer</span>


<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Optimization:</span>

<span class="sd">1. In the &#39;calculate_sum&#39; function, we can use the built-in &#39;sum&#39; function to calculate the sum of the numbers in the list. This is more efficient than manually iterating over the list and adding each number to the result.</span>
<span class="sd">2. In the &#39;multiply&#39; method of the &#39;MathOperations&#39; class, we can directly multiply the two numbers using the &#39;*&#39; operator. This eliminates the need for a loop and improves performance.</span>
<span class="sd">By using these optimizations, we improve the efficiency and readability of the code.</span>
<span class="sd">&quot;&quot;&quot;</span>
</pre></div>
</div>
</li>
</ol>
</section>
Expand Down
Loading

0 comments on commit c05084c

Please sign in to comment.