<?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>Forem: Ayaan Panda</title>
    <description>The latest articles on Forem by Ayaan Panda (@ayaanp).</description>
    <link>https://forem.com/ayaanp</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%2F544169%2Fcdc1fff2-8d66-42d1-86d9-db18b4aec085.jpg</url>
      <title>Forem: Ayaan Panda</title>
      <link>https://forem.com/ayaanp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ayaanp"/>
    <language>en</language>
    <item>
      <title>Basic Programming Fundamentals - Detailed Notes</title>
      <dc:creator>Ayaan Panda</dc:creator>
      <pubDate>Thu, 08 Sep 2022 18:25:16 +0000</pubDate>
      <link>https://forem.com/ayaanp/programming-fundamentals-overly-detailed-notes-4kdh</link>
      <guid>https://forem.com/ayaanp/programming-fundamentals-overly-detailed-notes-4kdh</guid>
      <description>&lt;p&gt;Programming is cool and you might want to learn some coding language like Python or JavaScript, but before all of that stuff, you need to understand the fundamentals that will apply to any code, whether it's game dev or machine learning, or if it's C# or JavaScript. So, here are the basic fundamentals of computer programming!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code samples will be in Java, but the concepts apply to all languages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Types&lt;/strong&gt;: The type that anything being stored in memory has, in code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integer: Any non-decimal number, commonly known as &lt;code&gt;int&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;String: Any combination of multiple characters. Always in double quotes or single quotes&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Char: Any one character&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Float: Any decimal number, ex. 6.4, 2.0, -4.0&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Boolean: Any true or false value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;: Memory locations in your code with a name that store some value.&lt;/p&gt;





&lt;ul&gt;
&lt;li&gt;Always have some sort of data type, depending on the value. Ex. a variable stores &lt;code&gt;"death"&lt;/code&gt;, this would mean that the variable has the data type of string.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Static/constant variables are variables that do not change throughout the whole program and remain constant. Dynamic variables are variables that are well, dynamic. They change based on different conditions in the program.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;The convention for variable names is to have it start with a letter, and separate words in the name with an underscore. For constant vars, the name should be all capital letters, for dynamic, all lowercase. &lt;strong&gt;Naming convention may be different based on the language.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Declaring a variables means creating the variable and making a memory location for it. Assigning means to assign a value to a variable.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;To declare a variable, you could do &lt;code&gt;int num_of_sandwiches&lt;/code&gt; (int is the data type and num_of_sandwiches is the name) then assign it later in the program with &lt;code&gt;num_of_sandwiches = 3&lt;/code&gt;. If you want to assign the variable at the same time you declare it, you could do &lt;code&gt;int num_of_sandwiches = 3&lt;/code&gt; in one line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;If/else/else if&lt;/strong&gt;: Every real-world program uses this. It is basically a block where if a condition is true, it runs some code. Here's an example to help you understand.&lt;/p&gt;

&lt;p&gt;Let's say there is a variable called &lt;code&gt;is_life_good&lt;/code&gt; and the value of that variable is &lt;code&gt;true&lt;/code&gt;. Our task is to show a message saying "Life is good! :D" only if &lt;code&gt;life_is_good&lt;/code&gt; has the value of true. Here's the code to do this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;life_is_good&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;life_is_good&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Life is good! :D"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Life is good! :D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first line, the variable is initialized and assigned. Then, there is an if statement, the condition just being the variable &lt;code&gt;life_is_good&lt;/code&gt;, which has a value of true. As said previously, the if statement only runs if the condition is true, and since it is, it runs &lt;code&gt;System.out.println("Life is good! :D");&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now let's say you want to print "Life's not good :(" if &lt;code&gt;life_is_good&lt;/code&gt; is false, and if it's not true or false, you want to say "You don't have a life lmao", how do you do that? You can use &lt;code&gt;elif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt;. &lt;code&gt;elif&lt;/code&gt; is if you want 3+ conditions. If the &lt;code&gt;if&lt;/code&gt; condition is false, then it will go to the &lt;code&gt;elif&lt;/code&gt; condition(you can have unlimited &lt;code&gt;elif&lt;/code&gt;s), if none of the &lt;code&gt;elif&lt;/code&gt; conditions are true, it will run the &lt;code&gt;else&lt;/code&gt; code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;life_is_good&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;life_is_good&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Life is good! :D"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="n"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;life_is_good&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Life's not good :("&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You don't have a life lmao"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;^^^&lt;br&gt;
This would be the new code with the &lt;code&gt;elif&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt;&lt;br&gt;
output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Life's not good :(
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;P.S: System.out.println is how you print something to the console in Java&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For loops&lt;/strong&gt; - Code gets looped "x" times. Here's an example&lt;/p&gt;

&lt;p&gt;You want to print "Hello!" five times, how do you do that? Well, you could use a for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello!
Hello!
Hello!
Hello!
Hello!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line starts the for loop. The &lt;code&gt;i&lt;/code&gt; variable in there is known as the counter, the first part, &lt;code&gt;int i = 0&lt;/code&gt;, makes the &lt;code&gt;i&lt;/code&gt; variable. The second part, &lt;code&gt;i &amp;lt; 5&lt;/code&gt;, tells the for loop to run if &lt;code&gt;i&lt;/code&gt; is less than 5. Then, the third part, &lt;code&gt;i++&lt;/code&gt;, tells it to increase &lt;code&gt;i&lt;/code&gt; by one each iteration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;While loops&lt;/strong&gt; - Loops that run the code while some condition is true, here's an example.&lt;/p&gt;

&lt;p&gt;You want to say "Lucky, less responsibility for you" while the age is less than 18, to do this, you could use a while loop!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Lucky, less responsibility for you"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="o"&gt;++;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lucky, less responsibility for you
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(repeats 18 times)&lt;/p&gt;

&lt;p&gt;The first line is the variable that the condition depends on, &lt;code&gt;age&lt;/code&gt;. The second line starts the while loop, with the condition being &lt;code&gt;age &amp;lt; 18&lt;/code&gt;. Then in the loop, we print "Lucky, less responsibility for you", then we do &lt;code&gt;age++&lt;/code&gt;. This is to increase the age each iteration, if you don't do that, the loop will run forever because the age will always be less than 18, and that breaks your program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Functions&lt;/strong&gt; - Code blocks that you can reuse and run over and over.&lt;/p&gt;

&lt;p&gt;Your task is to run code that will print "okay" if the variable &lt;code&gt;is_okay&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;, and "not okay" if it's &lt;code&gt;false&lt;/code&gt; 5 times, without using a for loop. You could have 5 if statements, or you could use less code, by putting one if statement in a function, then run that function 5 times, like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;is_okay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_okay&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"okay"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"not okay"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;coolMethod&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;So this is cool, but something that is more useful is functions with parameters, let's see another example.&lt;/p&gt;

&lt;p&gt;You want to make a function that with print whatever you give the function when it's ran. How would you go about doing this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;amazingMethod&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;stuff&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stuff&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;amazingMethod&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"life"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The parameter here is &lt;code&gt;stuff&lt;/code&gt;, and we can use that parameter anywhere in that function.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;println&lt;/code&gt; thing we are using to print stuff to the console is also a function. Other examples of functions are &lt;code&gt;Math.pow()&lt;/code&gt;, &lt;code&gt;Math.random()&lt;/code&gt;, etc.&lt;/p&gt;



&lt;p&gt;And yeah, these are some basic programming fundamentals! If you want me to add some more stuff, please comment, and also comment if you have any questions or anything else! I hoped these notes helped you.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Notes to get into OOP in Python</title>
      <dc:creator>Ayaan Panda</dc:creator>
      <pubDate>Tue, 22 Dec 2020 23:33:54 +0000</pubDate>
      <link>https://forem.com/ayaanp/notes-to-get-into-oop-in-python-3ak4</link>
      <guid>https://forem.com/ayaanp/notes-to-get-into-oop-in-python-3ak4</guid>
      <description>&lt;p&gt;Object Oriented Programming(OOP) is really powerful and really good to use, especially on big projects, here are some notes on OOP in Python.  Remember, you should know Python Basics, if you don't, check out &lt;a href="https://dev.to/codelearnern/notes-to-get-started-with-python-a29"&gt;this other post&lt;/a&gt;,   By the way, I have a video series on OOP in Python, here's the first video if you wanna check that out &lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZwbFJ5oHlPE"&gt;
&lt;/iframe&gt;
  Anyways, here are the notes!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OOP&lt;/strong&gt; - OOP means Object Oriented Programming. Object Oriented Programming is when you do programming with Classes, Objects, and Methods&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class&lt;/strong&gt; - You can think of a class as like a Data Type. All data types like strings, floats, or lists, are all classes. When you create a new class in your program, you're creating a new data type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Methods&lt;/strong&gt; - A method is a function that is part of a class. For example, strings have a method you can use on them called replace.  Well replace is a method of the class string. Similarly, you can add methods to your own classes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt; - An Object is an instantiation of a class, so if you had &lt;code&gt;x = "Something"&lt;/code&gt;, x would be the object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Self Keyword&lt;/strong&gt; - All methods need to have one parameter, and that is the self parameter. Self is a keyword in python that refers to the Object that is created from the class.  For example, lets say you had &lt;code&gt;x = "A String"&lt;/code&gt;.  Well, in the string class, self would refer to that x object.  With the self keyword, you can attach attributes to that object, so for example, lets say you did &lt;code&gt;self.likesCoding = True&lt;/code&gt;, and you made an instance of that class called x.  Now, if you do &lt;code&gt;x.likesCoding&lt;/code&gt;, it should give True.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;init&lt;/strong&gt; - All classes need to have the init method. Whatever you put in the init method will happen whenever an object of that class is instantiated.  With the init method, you can actually make it so that whenever you instantiate the object, it will actually take in some arguments.  For that, you just pass in those parameters in the init method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class Syntax&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breed&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;breed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"breed"&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Bark"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Jeff"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Havanese"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# This will print Jeff
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# This will print 5
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;breed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# This will print Havanese
&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# This will print Bark
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inheritance&lt;/strong&gt; - Lets say you had to classes, Dog and Cat. The only difference between these 2 classes is that Dog has a bark method, and Cat has a meow method. It would be very repetitive. For this situation, you can use Inheritance. Inheritance is a way so that you can have child classes inheriting from a parent class. So the child classes would have all the same things as the parent class, plus it's own things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance Syntax&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;breed&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Bark"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Pet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;meow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Meow"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So that is Object Oriented Programming in Python. You're most of the time going to use OOP in big and production level code. OOP is a must-know in programming. I hope these notes helped!&lt;/p&gt;

</description>
      <category>oop</category>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Notes to get started with Python</title>
      <dc:creator>Ayaan Panda</dc:creator>
      <pubDate>Sun, 20 Dec 2020 21:04:28 +0000</pubDate>
      <link>https://forem.com/ayaanp/notes-to-get-started-with-python-a29</link>
      <guid>https://forem.com/ayaanp/notes-to-get-started-with-python-a29</guid>
      <description>&lt;p&gt;So you're looking to learn Python, here are some notes that will help you to getting started with Python.  By the way, if you want to see videos to get started with python you can check them at my YouTube Channel called Just Program, here is the first video in the series &lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VWAwOPhgoFc"&gt;
&lt;/iframe&gt;
  So, here are the notes!&lt;/p&gt;

&lt;p&gt;What is computer programming - Computer programming is a way to give instructions to a computer to do something&lt;br&gt;
To do computer programming, you write something called code, which is the way that instructions are given to a computer&lt;br&gt;
Code is nice because it isn't 0s and 1s(Binary)&lt;/p&gt;

&lt;p&gt;Why learn Python - Python is a great programming language because it is beginner friendly and readable, but is also&lt;br&gt;
really powerful.&lt;/p&gt;

&lt;p&gt;Installing - Download python for your specific machine specifications at &lt;a href="https://python.org"&gt;https://python.org&lt;/a&gt; and download a text editor to&lt;br&gt;
code in.  I would not recommend using an IDE(integrated development environment) because the beginner should learn the&lt;br&gt;
syntax and learn how to figure our errors instead of letting the IDE do it for them.  Download a text editor like &lt;br&gt;
Sublime Text, Atom, or Vim&lt;/p&gt;

&lt;p&gt;Data Types - A data type is a type a variable is.  Think of a variable as something that stores a piece of information&lt;br&gt;
There are many Data Types, the main ones are Strings, Integers, Floats, and Booleans.&lt;br&gt;
Strings, anything in quotes.  Generally a word, but anything else in quotes are strings. ex: "String", "Joe", "6"&lt;br&gt;
Integers, any number that is not a decimal.  Not in quotes or anything like that.  ex: 1, -5, 78&lt;br&gt;
Floats, any number, decimal or non-decimal.  Not in quotes or anything like that.  ex: 3.1459, 2, 78.4&lt;br&gt;
Booleans, True or False.  HAS TO BE CAPITAL T AND CAPITAL F&lt;/p&gt;

&lt;p&gt;1st Program - Create a new folder where you wanna code in, and create a file called first.py&lt;br&gt;
You HAVE to have a .py extension at the end of the file name because all python code is written in .py files.&lt;br&gt;
To test your python installation, write &lt;code&gt;print("Hello")&lt;/code&gt; in first.py  You can probably guess this will spit out&lt;br&gt;
Hello in the console when we run this.  To run a python program, you do python programname.py on windows or &lt;br&gt;
python3 programname.py on Mac/Linux.&lt;/p&gt;

&lt;p&gt;Variables - Variables are something that store a piece of information.  The syntax is &lt;code&gt;varName = whatYouWantStored&lt;/code&gt;&lt;br&gt;
The variable name cannot start with a number and the convention is to use camelCase or under_scores for variable &lt;br&gt;
names.&lt;/p&gt;

&lt;p&gt;Operators - Operators are things like +, which adds numbers, or -, which subtracts numbers, here's a list of them.&lt;br&gt;
+, adds numbers, Syntax: &lt;code&gt;print(9 + 5 + 4)&lt;/code&gt;&lt;br&gt;
-, subtracts numbers, Syntax: &lt;code&gt;print(4 - 3)&lt;/code&gt;&lt;br&gt;
&lt;em&gt;, multiplies numbers, Syntax: &lt;code&gt;print(8 * 5)&lt;/code&gt;&lt;br&gt;
/, divides numbers, Syntax: &lt;code&gt;print(100 / 10)&lt;/code&gt;&lt;br&gt;
*&lt;/em&gt;, to the power of, Syntax &lt;code&gt;print(8**2)&lt;/code&gt; (will return 64)&lt;br&gt;
%, gets remainder of division problem, Syntax: &lt;code&gt;print(10 % 4)&lt;/code&gt; (will return 2)&lt;/p&gt;

&lt;p&gt;Lists - literally lists of elements, can have different data types in them &lt;br&gt;
Syntax: &lt;code&gt;["Orange", "Apple", "Banana", 3]&lt;/code&gt;&lt;br&gt;
&lt;code&gt;list.append(elementToAdd)&lt;/code&gt; - Appends an element to the end of a list&lt;br&gt;
&lt;code&gt;list.insert(index, elementToAdd)&lt;/code&gt; - Appends an element to a specific index in a list&lt;br&gt;
&lt;code&gt;list[index]&lt;/code&gt; - Gets element of a list at a specific index&lt;br&gt;
&lt;code&gt;del list[index]&lt;/code&gt; - Deletes an element of a list at a specific index&lt;/p&gt;

&lt;p&gt;If statement - if something do this&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hi"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Hi"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Bye"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Goodbye"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Something"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Loops: Loops over something.  Can loop over many things, commonly used to loop over strings and lists&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"Tomato"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Onion"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Lettuce"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While Loops: While something is true, do a specific block of code.  If something always true, never turns into false,&lt;br&gt;
it results in an infinite loop(which is bad)&lt;br&gt;
Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Something"&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Something"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Functions: A block of code that does something.  Generally used when a lot of code is repeated.&lt;br&gt;
Return keyword returns something from a function, think of whatever is being returned as a replacement to the&lt;br&gt;
function call.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;funcName&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"Hi"&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;funcName&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints Hi because Hi was returned.  Convention is to use camelCase in function names.&lt;/p&gt;

&lt;p&gt;Function parameters: Information that can be passed into a function.  Argument is the same thing as a parameter, except&lt;br&gt;
it's called an argument when function is being called.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;funcName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;funcParameter1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;funcParameter2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;funcParameter1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;funcParameter2&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;funcName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return 9.  In this case, 1 and 8 are the arguments and funcParameter1 and funcParameter2 are the parameters.&lt;/p&gt;

&lt;p&gt;Read from a file - You generally use with keyword because you don't have to deal with closing a file and all of that.&lt;br&gt;
You use the open function to open a file, readline function to read first line from the file, and readlines function&lt;br&gt;
to read all the lines of a file.  The second argument in the open function is referring to what mode the file will&lt;br&gt;
be opened in, reading from a file = r mode.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"file.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"r"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write to a file - You generally use with keyword because you don't have to deal with closing a file and all of that.&lt;br&gt;
You use the open function to open a file, write function to write to the file.  You use the open function to write&lt;br&gt;
to a file even if the file doesn't exist as in write or append mode, it creates the file if the file doesn't&lt;br&gt;
already exist.  Also, write mode overwrites what's already in the file, append mode appends on to the end of the file.&lt;br&gt;
w = write mode, a = append mode.  \n = new line&lt;/p&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"file.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"This is appended to the end of the file!&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modules: Way to separate different functionality of your project.  You can also use modules that other people created&lt;br&gt;
like Tensorflow, or PyGame.&lt;/p&gt;

&lt;p&gt;Ex:&lt;/p&gt;

&lt;p&gt;calculator.py -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;main.py -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;calculator&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;

&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter Number: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Enter Number: "&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optional Parameters - Parameters in functions that are optional.  In this example, x and y default to 1 if you don't&lt;br&gt;
enter them, but if you do, they will be whatever you entered&lt;/p&gt;

&lt;p&gt;Ex:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;something&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;String Concatenation: Way to combine strings.  You can combine strings my doing &lt;code&gt;string1 + string2&lt;/code&gt;.  You can repeat a&lt;br&gt;
string by doing &lt;code&gt;string1 * 5&lt;/code&gt;, which is the same as &lt;code&gt;string1 + string1 + string1 + string1 + string1&lt;/code&gt;.  CANNOT ADD&lt;br&gt;
STRING AND NUMBERS.&lt;/p&gt;

&lt;p&gt;F Strings: A much better way for string concatenation.  You can even put numbers in strings.  You put variables/operations&lt;br&gt;
in curly braces.&lt;/p&gt;

&lt;p&gt;Ex WITHOUT F STRINGS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"69"&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"43"&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"The value of x is "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" and the value of y is "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ex WITH F STRINGS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;69&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"The value of x is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; and the value of y is &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So yeah, that is the notes I have for anyone who wants to get started with Python!&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
