<?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: Isaac</title>
    <description>The latest articles on DEV Community by Isaac (@obturador).</description>
    <link>https://dev.to/obturador</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%2F1057469%2F748f5a8d-9c4a-48d5-944b-e05ef8e25a4e.jpg</url>
      <title>DEV Community: Isaac</title>
      <link>https://dev.to/obturador</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/obturador"/>
    <language>en</language>
    <item>
      <title>Lothar Collatz hypothesis</title>
      <dc:creator>Isaac</dc:creator>
      <pubDate>Sun, 02 Apr 2023 22:45:01 +0000</pubDate>
      <link>https://dev.to/obturador/lothar-collatz-hypothesis-332</link>
      <guid>https://dev.to/obturador/lothar-collatz-hypothesis-332</guid>
      <description>&lt;p&gt;In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way:&lt;/p&gt;

&lt;p&gt;1.Take any non-negative and non-zero integer number and name it c0.&lt;br&gt;
2.If it's even, evaluate a new c0 as c0 ÷ 2.&lt;br&gt;
3.Otherwise, if it's odd, evaluate a new c0 as 3 × c0 + 1.&lt;br&gt;
4.If c0 ≠ 1, skip to point 2.&lt;/p&gt;

&lt;p&gt;The hypothesis says that regardless of the initial value of c0, it will always go to 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Prove that Lothar Collatz  is wrong!!!!")
c0 = int(input('Enter a non- negative, non-zero integer: '))
step = 0
while c0 != 1:
    if c0 % 2 == 0:
        c0 //= 2
        if c0 != 1:
            step += 1
            print(' New value is ', c0)
            continue
        elif c0 == 1:
            step += 1
            print(' New value is ', c0)
            break
    elif c0 % 2 == 1:
        c0 = c0 * 3 + 1
        if c0 != 1:
            step += 1
            print(' New value is ', c0)
            continue

print('Total Steps: ', step)
print("*"*44)
print("*"*44)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see we have transform the whole Collatz idea in to a &lt;strong&gt;while loop&lt;/strong&gt; that &lt;strong&gt;print&lt;/strong&gt; every step needed to achieve the goal.&lt;br&gt;
At the end we run a &lt;strong&gt;for loop&lt;/strong&gt; with a &lt;strong&gt;sleep&lt;/strong&gt; command to avoid the program to close abruptly after doing the calculations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import time

for i in range(1,11):
    time.sleep(1)

print("*"*44)
print("*"*44)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>maths</category>
    </item>
    <item>
      <title>Tax Calculator</title>
      <dc:creator>Isaac</dc:creator>
      <pubDate>Sun, 02 Apr 2023 22:13:05 +0000</pubDate>
      <link>https://dev.to/obturador/tax-calculator-2ci6</link>
      <guid>https://dev.to/obturador/tax-calculator-2ci6</guid>
      <description>&lt;p&gt;We are going to make a simple program to calculate two different taxes based on the user's income. We are going to call this tax PIB.&lt;br&gt;
First we set the variable for the yearly income that is going to cut between the two taxes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;citincut=85528
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second we define our variables for the two different tax operations base on the user's input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Best rewards loyal citizen, today its time to contribute your Personal Income Tax for the Kingdom of Thalia.")
citinput=float(input("Introduce Year Income:"))
citix=citinput-citincut
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We set the logic  operation for the two different taxes.&lt;br&gt;
As you can see for the people with a lower income than 85528 we are going to apply a tax of the 18% of the income minus 556.2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (citinput&amp;lt;=citincut):
    tax=citinput*18/100-556.2
    print(round(tax),"Is your annual PIT, thank you loyal citizen.\n")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid having a negative tax we introduce a if statement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if (tax&amp;lt;=0):
        print("Move Punk") 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the people with a higher income we are going to set a tax of 14839.2 plus 32% of the surplus over 85528:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;elif (citinput&amp;gt;=citincut):
    tax=citinput-(14839.2+(citix*32/100))
    print(round(tax),"Is your annual PIT, Hail Thalia!\n")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change the value of the variable and use it for your own purposes.  &lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Multi-Dimensional List</title>
      <dc:creator>Isaac</dc:creator>
      <pubDate>Sun, 02 Apr 2023 21:03:34 +0000</pubDate>
      <link>https://dev.to/obturador/multi-dimensional-list-59e4</link>
      <guid>https://dev.to/obturador/multi-dimensional-list-59e4</guid>
      <description>&lt;h1&gt;
  
  
  we are going to create a multi-dimensional list to be able to store telephone numbers and user names together.
&lt;/h1&gt;

&lt;p&gt;First we are going to create a function to run our menu within a loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def list():
    userlist=[["Jimmy",+34666777888],["Bobby",+34668669449],["Charlie",+341999101110]]
    while True:

        print ("*"*43)
        print ("\n*         Multi-Dimensional List         *\n")
        print ("*"*43)
        print ("\n*   1 - Display the users information    *\n")
        print ("*                                          *\n")
        print ("*   2 - Add a new user                     *\n")
        print ("*                                          *\n")
        print ("*   3 - Count the number of users          *\n")
        print ("*                                          *\n")
        print ("*   4 - Exit                               *\n")
        print ("*"*43)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see we added some users already for testing purposes.&lt;br&gt;
After setting the menu we are going to code the conditional statements for the different values of our user input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        action = int(input("Please type the number to perform the action selected:\n"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display the elements without brackets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        if action == 1:
              for i in range(len(userlist)) :
                for j in range(len(userlist[i])) :
                    print(userlist[i][j], end=" ")
                    print()
                continue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding new users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        elif action == 2:
            print("Type new user name: ")
            newusername=input()
            print("Type new telephone number")
            newusertelephone=input()
            newuser="\n".join([newusername,newusertelephone])
            userlist.append([newuser])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the next step we use &lt;strong&gt;len&lt;/strong&gt; so we are going to count only the elements of the list that contains strings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        elif action == 3:
            usercounter=len(userlist)
            print("Numbers of users:",usercounter)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To exit the program we break the loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        elif action == 4:
            break
        else:

            print("Invalid choice. Please try again.")
list()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
