<?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: Lisa Ghosn</title>
    <description>The latest articles on DEV Community by Lisa Ghosn (@lisag).</description>
    <link>https://dev.to/lisag</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%2F1190031%2F73081a4a-5d11-4f84-907d-60e05185223f.jpg</url>
      <title>DEV Community: Lisa Ghosn</title>
      <link>https://dev.to/lisag</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lisag"/>
    <language>en</language>
    <item>
      <title>User Input() and Outputs</title>
      <dc:creator>Lisa Ghosn</dc:creator>
      <pubDate>Sat, 11 Nov 2023 18:38:11 +0000</pubDate>
      <link>https://dev.to/lisag/user-input-and-outputs-1eoi</link>
      <guid>https://dev.to/lisag/user-input-and-outputs-1eoi</guid>
      <description>&lt;p&gt;User &lt;code&gt;input()&lt;/code&gt; is an interactive function that allows the user to insert a value into your program.&lt;/p&gt;

&lt;p&gt;An Output is the resulting data produced from the input. &lt;br&gt;
&lt;code&gt;print()&lt;/code&gt; is an example of an output function. It is used so the program can display the resulting data and/or communicate with the user.&lt;/p&gt;

&lt;p&gt;Let's create the code for the photo banner above, as a user input example:&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PLEASE ENTER YOUR NAME&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HELLO &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;! AND WELCOME!&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;The program has asked for John's name in order to communicate a welcome message to him.&lt;/p&gt;

&lt;p&gt;There are &lt;strong&gt;implicit&lt;/strong&gt; and &lt;strong&gt;explicit&lt;/strong&gt; data type conversions in python. Inputs will always produce a string unless otherwise stated, this is an implicit (automatic) conversion. &lt;/p&gt;

&lt;p&gt;If you would like an input to produce a different data type, it will need to be explicitly instructed, for example; &lt;br&gt;
&lt;code&gt;age = int(input())&lt;/code&gt; - will convert the input into an integer. &lt;br&gt;
We can check data types with the type() function;&lt;br&gt;
&lt;code&gt;print(type(age))&lt;/code&gt; - will check what data type the value in your variable is. &lt;/p&gt;

&lt;p&gt;Other examples of implicit and explicit conversions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/&lt;/strong&gt; will implicitly produce a float and &lt;strong&gt;//&lt;/strong&gt; will implicitly produce an integer. Also, math operations between an integer and a float will always produce a float. &lt;/p&gt;




</description>
      <category>devjournal</category>
      <category>python</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>F-Strings</title>
      <dc:creator>Lisa Ghosn</dc:creator>
      <pubDate>Fri, 03 Nov 2023 14:09:35 +0000</pubDate>
      <link>https://dev.to/lisag/f-strings-3o0b</link>
      <guid>https://dev.to/lisag/f-strings-3o0b</guid>
      <description>&lt;p&gt;I'm keen to see how f-strings work with the programme I wrote in my previous post. I was advised that they're much easier to work with and less prone to error.&lt;/p&gt;




&lt;p&gt;so...&lt;/p&gt;

&lt;p&gt;I have a lot of boxes of eggs in my fridge and I want to calculate how many omelettes I can make. each box of eggs contains six eggs and I need four eggs for each omelette.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o3z9kxrxo9a8xqnso20.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o3z9kxrxo9a8xqnso20.jpg" alt="Pycharm image of code to run the above task: number_of_eggs_needed_to_make_an_omlette = 4&amp;lt;br&amp;gt;
number_of_eggs_in_a_carton = 6&amp;lt;br&amp;gt;
number_of_egg_cartons = 9&amp;lt;br&amp;gt;
total_eggs = number_of_egg_cartons * number_of_eggs_in_a_carton&amp;lt;br&amp;gt;
omlettes = total_eggs // number_of_eggs_needed_to_make_an_omlette&amp;lt;br&amp;gt;
left_over_eggs = total_eggs % number_of_eggs_needed_to_make_an_omlette&amp;lt;br&amp;gt;
message1 = f'there are {total_eggs} eggs in total, this means you can make {omlettes} omlettes with {left_over_eggs} eggs left over'&amp;lt;br&amp;gt;
print(message1)" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;'to make 25 omlettes, you will need 100 eggs. That means you need to buy 16 cartons of eggs'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;'there are 54 eggs in total, this means you can make 13 omlettes with 2 eggs left over'&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;It's a lot easier to figure out which placeholder represents which variable, so the code is a lot easier to read. I'm also happy to see the code shrink a bit!&lt;/p&gt;




</description>
      <category>python</category>
      <category>coding</category>
      <category>programming</category>
      <category>devpride</category>
    </item>
    <item>
      <title>Python in Practice</title>
      <dc:creator>Lisa Ghosn</dc:creator>
      <pubDate>Wed, 01 Nov 2023 18:34:16 +0000</pubDate>
      <link>https://dev.to/lisag/python-in-practice-3488</link>
      <guid>https://dev.to/lisag/python-in-practice-3488</guid>
      <description>&lt;p&gt;Here are some exercises that I was working on this week:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I am building some very high quality chairs and need exactly four nails for each chair. I've written a program to calculate how many nails I need to buy to build these chairs but something is wrong.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chairs = '15' &lt;br&gt;
nails = 4 &lt;br&gt;
total_nails = chairs * nails &lt;br&gt;
message = 'I need to buy {} nails'.format(total_nails) &lt;br&gt;
print('You need to buy {} nails'.format(message))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When I run the program it tells me that I need to buy 15151515 nails. &lt;/p&gt;

&lt;p&gt;How do I fix it? &lt;br&gt;
To correct the code, I need to change the variable; chairs, from a string into an integer. In order for me to do that, I need to remove the apostrophes on the value 15. &lt;br&gt;
once this is done, the program will run correctly and tell me that I need to buy 60 nails. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm trying to run this program, but I get an error.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;my_name = Penelope &lt;br&gt;
my_age = 29 &lt;br&gt;
message = 'My name is {} and I am {} years old'.format(my_name, my_age) &lt;br&gt;
print(message)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;How do I fix it? &lt;br&gt;
To correct the code, I need to make Penelope a string: &lt;br&gt;
&lt;code&gt;my_name = 'Penelope'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;python hasn't recognised the data type that the value &lt;strong&gt;Penelope&lt;/strong&gt; is and isn't sure how to proceed. Once we specify that this is a string using &lt;strong&gt;''&lt;/strong&gt; it will run as instructed. &lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Program 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have a lot of boxes of eggs in my fridge and I want to calculate how many omelettes I can make. each box of eggs contains six eggs and I need four eggs for each omelette.&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;number_of_eggs_for_omlette&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;number_of_eggs_in_carton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="n"&gt;number_of_egg_cartons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;
&lt;span class="n"&gt;total_eggs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;number_of_egg_cartons&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;number_of_eggs_in_carton&lt;/span&gt;
&lt;span class="n"&gt;omlettes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total_eggs&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;number_of_eggs_for_omlette&lt;/span&gt;
&lt;span class="n"&gt;left_over_eggs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total_eggs&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;number_of_eggs_for_omlette&lt;/span&gt;
&lt;span class="n"&gt;message1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;there are {} eggs in total, this means you can make {} omlettes with {} eggs left over &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total_eggs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;omlettes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;left_over_eggs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;There are 54 eggs in total, this means you can make 13 omlettes with 2 eggs left over&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;I also want write a program to tell me how many eggs I need to buy to make x amount of eggs. For example, I want to make 25 omlettes, how many eggs do I need to buy??&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;number_of_eggs_for_omlette&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;number_of_desired_omlettes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
&lt;span class="n"&gt;number_of_eggs_in_carton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;
&lt;span class="n"&gt;total_eggs_needed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;number_of_eggs_for_omlette&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;number_of_desired_omlettes&lt;/span&gt;
&lt;span class="n"&gt;egg_cartons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;total_eggs_needed&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="n"&gt;number_of_eggs_in_carton&lt;/span&gt;
&lt;span class="n"&gt;message2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;to make {} omlettes, you will need {} eggs. That means you need to buy {} cartons of eggs&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number_of_desired_omlettes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total_eggs_needed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;egg_cartons&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;To make 25 omlettes, you will need 100 eggs. That means you need to buy 16 cartons of eggs&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;These programmes will print the information that I need, depending on the values i'm inputting into it. &lt;/p&gt;

</description>
      <category>python</category>
      <category>coding</category>
      <category>programming</category>
      <category>devpride</category>
    </item>
    <item>
      <title>Data Types, Operators and Variables</title>
      <dc:creator>Lisa Ghosn</dc:creator>
      <pubDate>Wed, 01 Nov 2023 15:53:34 +0000</pubDate>
      <link>https://dev.to/lisag/data-types-and-operators-b9c</link>
      <guid>https://dev.to/lisag/data-types-and-operators-b9c</guid>
      <description>&lt;p&gt;（￣︶￣）↗　Basic Data Types &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Numbers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Integer &lt;code&gt;(int())&lt;/code&gt;: a python data type for whole numbers.&lt;/p&gt;

&lt;p&gt;Float &lt;code&gt;(float())&lt;/code&gt;: a python data type for decimal numbers.&lt;/p&gt;

&lt;p&gt;(also Booleans &lt;code&gt;(bool())&lt;/code&gt;, but we'll get on to them a bit later)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other ways to record numerical data&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Binary &lt;code&gt;(bin())&lt;/code&gt; is how computers best process information using 1's and 0's, to the power of 2.&lt;/li&gt;
&lt;li&gt;Hexadecimal &lt;code&gt;(hex())&lt;/code&gt; is a mixture of numbers and letters and is used to condense binary code and data, to the power of 16.&lt;/li&gt;
&lt;li&gt;Octal numbers &lt;code&gt;(oct())&lt;/code&gt; also condenses data to the power of 8.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Strings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;String: a string is a python data type for text and characters contained within either &lt;strong&gt;""&lt;/strong&gt; or &lt;strong&gt;''&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Using "speech marks" might be better to avoid confusing Python. If apostrophes are used during a word then the whole string may be misread, for example;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyqd22n7ahrq17dtohmi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyqd22n7ahrq17dtohmi.jpg" alt="An example of a string error. Python has confused the apostrophe in the word wasn't as the end of the string" width="800" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print('it wasn't what I needed')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Python has misinterpreted the apostrophe in the word 'wasn't' as an instruction to end the string.&lt;/p&gt;




&lt;p&gt;Strings can have spaces within them but variables need ‘&lt;strong&gt;_&lt;/strong&gt;’ i.e snake_case (common practice) to define a space; variable_name = value&lt;/p&gt;

&lt;p&gt;Variables are labels used to define the value of the data stored within them. Variable names and values are connected with the &lt;strong&gt;=&lt;/strong&gt; sign. Variable names cannot &lt;strong&gt;start&lt;/strong&gt; with a number but can &lt;strong&gt;include&lt;/strong&gt; numbers i.e. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;student_1 = Casey&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithmic Operator Types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;+   add&lt;/li&gt;
&lt;li&gt;-   subtract&lt;/li&gt;
&lt;li&gt;*   multiply&lt;/li&gt;
&lt;li&gt;/   division&lt;/li&gt;
&lt;li&gt;**  exponent&lt;/li&gt;
&lt;li&gt;%   modulo (remainder)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The * and + operators work on strings as well as integers. the * will repeat a string and the + will join the two words together. This is called &lt;strong&gt;concatenation&lt;/strong&gt;.&lt;/p&gt;




</description>
      <category>python</category>
      <category>coding</category>
      <category>devpride</category>
      <category>programming</category>
    </item>
    <item>
      <title>HTML, CSS and JS - a silly little game</title>
      <dc:creator>Lisa Ghosn</dc:creator>
      <pubDate>Wed, 01 Nov 2023 15:43:28 +0000</pubDate>
      <link>https://dev.to/lisag/html-css-and-js-a-silly-little-game-272b</link>
      <guid>https://dev.to/lisag/html-css-and-js-a-silly-little-game-272b</guid>
      <description>&lt;p&gt;Move your mouse carefully through the blue line and safely into the pink square. if you fail, the computer will taunt you BUT IF YOU WIN... &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/Lghova/embed/YzREOdK?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>javascript</category>
      <category>gamedev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
