<?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: Irene  Njuguna</title>
    <description>The latest articles on DEV Community by Irene  Njuguna (@karrey).</description>
    <link>https://dev.to/karrey</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%2F880281%2Ff62a4c38-5f46-422f-8803-b8a308969dd9.jpeg</url>
      <title>DEV Community: Irene  Njuguna</title>
      <link>https://dev.to/karrey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karrey"/>
    <language>en</language>
    <item>
      <title>Exploring Python Tuples: A Beginner's Guide.</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Fri, 02 Feb 2024 13:23:13 +0000</pubDate>
      <link>https://dev.to/karrey/exploring-python-tuples-a-beginners-guide-477n</link>
      <guid>https://dev.to/karrey/exploring-python-tuples-a-beginners-guide-477n</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Tuples is a datatype in Python, it provides a way to store multiple items within a single variable. This article explores tuples, comparing them with other data types like lists, sets, and dictionaries, showing their unique features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a tuple?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A tuple is an ordered and unchangeable collection written with round brackets.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example of a tuple:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;my_tuple = ("Kiwi", "orange", "mango")&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Basic Tuple Properties&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ordered&lt;/strong&gt;: Tuples maintain a defined order of items.&lt;br&gt;
&lt;strong&gt;Unchangeable&lt;/strong&gt;: Once created, tuples remain immutable; items cannot be altered, added, or removed.&lt;br&gt;
&lt;strong&gt;Allow Duplicates&lt;/strong&gt;: Similar values can exist in a tuple.&lt;/p&gt;

&lt;p&gt;How to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create A Tuple&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ("apple", "kiwi", "banana")
print(fruits)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;1. Accessing items in a tuple;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two ways to access a tuple.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By index;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;if you want to access the second item in the fruits tuple above, you can do this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
second_fruit = fruits[1]
print(second_fruit, fruits)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first item has index 0.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By negative indexing;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Negative indexing means starting from the end.&lt;br&gt;
so the last item is accessed by -1, 2nd last item on the list is -2, and so on&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;last_fruit = fruits([-1])
print(last_fruit)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Range of indexes;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can specify a range of indexes by specifying where to start and where to end the range. The new tuple will be a new list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;partial_fruits = fruits[1:3]
print(partial_fruits)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Modifying tuples&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By changing the value;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So we will still use the fruits tuple.&lt;br&gt;
&lt;code&gt;fruits = ("apple", "kiwi", "banana")&lt;br&gt;
&lt;/code&gt; to change the values you first convert the tuple to a list and then change it back to a tuple, because tuples are immutable.&lt;br&gt;
example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ("apple", "kiwi", "banana")
to_list = list(fruits)
to_list[0] = "Mango"
to_tuple = tuple(to_list)
print(to_tuple)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So to check the data type of the tuple you can do that by using the &lt;code&gt;type()&lt;/code&gt; method;&lt;/p&gt;

&lt;p&gt;This checks if the above code is a tuple or still a list after changing the initial values in our tuple. &lt;br&gt;
&lt;code&gt;print(type(to_tuple))&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Adding Items&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can add an item to a tuple by converting it to a list first and then to a tuple, you use the &lt;code&gt;append()&lt;/code&gt; method to add the item as the last item.&lt;/p&gt;

&lt;p&gt;How it's done;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ("apple", "kiwi", "banana")
x =  list(fruits)
x.append("orange")
fruits = tuple(x)
print(fruits)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or you can do this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("apple", "banana", "cherry")
y = ("orange",)
thistuple += y
print(thistuple)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Iterating Through Tuples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;you can iterate through tuples using the loop or while loop method.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using For Loop&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("apple", "banana", "cherry")
for fruit in thistuple:
 print(fruit)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Looping Through Index Numbers&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("apple", "banana", "cherry")
for i in range(len(thistuple)):
 print(thistuple[i])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Using a While Loop&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thistuple = ("apple", "banana", "cherry")
i = 0
while i &amp;lt; len(thistuple):
 print(thistuple[i])
 i = i + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Combining and Multiplying Tuples&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Combining Tuples/Adding them together&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To join two or more tuples you use the + operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tuple1 = ("a", "b" , "c")
tuple2 = (1, 2, 3)
tuple3 = tuple1 + tuple2
print(tuple3)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Multiplying tuples&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you want to multiply the content of a tuple a given number of times, you can use the * operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ("apple", "banana", "cherry")
doubled_fruits = fruits * 2
print(doubled_fruits)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>problem 3:</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Wed, 17 May 2023 22:13:50 +0000</pubDate>
      <link>https://dev.to/karrey/problem-3-43ed</link>
      <guid>https://dev.to/karrey/problem-3-43ed</guid>
      <description>&lt;h2&gt;
  
  
  Question
&lt;/h2&gt;

&lt;p&gt;Largest prime factor&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;br&gt;
The prime factors of 13195 are 5, 7, 13 and 29.&lt;/p&gt;

&lt;p&gt;What is the largest prime factor of the number 600851475143 ?&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;function largestPrimeFactor(number) {&lt;/p&gt;

&lt;p&gt;let largestFactor = 0;&lt;br&gt;
  let divider = 2;&lt;/p&gt;

&lt;p&gt;while (number &amp;gt; 1) {&lt;br&gt;
    if (number % divider === 0) {&lt;br&gt;
      largestFactor = divider;&lt;br&gt;
      number /= divider;&lt;br&gt;
    } else {&lt;br&gt;
      divider++;&lt;br&gt;
    }&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;return largestFactor;&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;p&gt;pass the number as argument.initialize  largestfactor as 0 and the divider 2 which is the smallest prime number.&lt;br&gt;
if the number is greater than 1 , we check if its divisible by 0;then update largest number to the divider,if the number is not divisible by the prime number we add it.then return the largestFactor.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>projecteuler</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Problem 2:</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Wed, 17 May 2023 21:27:38 +0000</pubDate>
      <link>https://dev.to/karrey/problem-2-1mmj</link>
      <guid>https://dev.to/karrey/problem-2-1mmj</guid>
      <description>&lt;h2&gt;
  
  
  Question:
&lt;/h2&gt;

&lt;p&gt;Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:&lt;/p&gt;

&lt;p&gt;1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...&lt;/p&gt;

&lt;p&gt;By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;function sumEvenFibonacci(limit) {&lt;br&gt;
  let sum = 0;&lt;br&gt;
  let fibPrev = 1;&lt;br&gt;
  let fibCurr = 2;&lt;/p&gt;

&lt;p&gt;while (fibCurr &amp;lt;= limit) {&lt;br&gt;
    if (fibCurr % 2 === 0) {&lt;br&gt;
      sum += fibCurr;&lt;br&gt;
    }&lt;br&gt;
    let fibNext = fibPrev + fibCurr;&lt;br&gt;
    fibPrev = fibCurr;&lt;br&gt;
    fibCurr = fibNext;&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;return sum;&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation
&lt;/h2&gt;

&lt;p&gt;Define a function sumEvenFibonacci that takes a limit as an argument.initialize the variables sum to keep track of the sum, fibPrev to store the previous Fibonacci number, and fibCurr to store the current Fibonacci number.start the Fibonacci sequence with the initial values of 1 and 2.&lt;br&gt;
Then use a while loop to generate Fibonacci numbers until the current Fibonacci number exceeds the given limit. Inside the loop, It checks the current Fibonacci number is even (fibCurr % 2 === 0). If it is, we add it to the sum.&lt;br&gt;
Update the Fibonacci numbers by assigning fibCurr to fibPrev and fibNext (the sum of fibPrev and fibCurr) to fibCurr.&lt;br&gt;
Return the sum.&lt;/p&gt;

</description>
      <category>projecteuler</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Project Euler solution 1</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Wed, 17 May 2023 21:20:00 +0000</pubDate>
      <link>https://dev.to/karrey/project-euler-solution-1-48nf</link>
      <guid>https://dev.to/karrey/project-euler-solution-1-48nf</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 1&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.&lt;br&gt;
Find the sum of all the multiples of 3 or 5 below 1000.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;solution&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;function findMultiplesSum() {&lt;br&gt;
  let sum = 0;&lt;/p&gt;

&lt;p&gt;for (let i = 1; i &amp;lt; 1000; i++) {&lt;br&gt;
    if (i % 3 === 0 || i % 5 === 0) {&lt;br&gt;
      sum += i;&lt;br&gt;
    }&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;return sum;&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Explanation:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;initialize a variable sum to keep track of the sum of multiples.then loop through the numbers from 1 to 999 (excluding 1000) using a for loop. For each number,check if it is divisible by 3 or 5 using the modulus operator (%). If it is divisible,add it to the sum variable. Finally,return the sum&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Phase 2</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Fri, 22 Jul 2022 18:38:29 +0000</pubDate>
      <link>https://dev.to/karrey/phase-2-5edb</link>
      <guid>https://dev.to/karrey/phase-2-5edb</guid>
      <description></description>
    </item>
    <item>
      <title>Calmy Cocktails</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Thu, 23 Jun 2022 23:05:08 +0000</pubDate>
      <link>https://dev.to/karrey/calmy-cocktails-23jp</link>
      <guid>https://dev.to/karrey/calmy-cocktails-23jp</guid>
      <description>&lt;p&gt;Hello,&lt;br&gt;
calmy cocktail is a website that i designed using my basics knowledge in javascript,css and html which am very proud of bacause i came up with idea within a day.&lt;br&gt;
Its all about a family that come up together because of their love for the cocktails or as they say the peer pressure of making bad decisions.&lt;br&gt;
I have several lines of code the way i developed this website from scratches using my own knowledge ans thats something am so proud of i hope with time i will be able to create more cleaner codes and be  able to help other devs in the  making as i  progress.&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%2Flo3lw4h746ogetntze0z.png" 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%2Flo3lw4h746ogetntze0z.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;br&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%2Frou5u3ds58rlkweb2lex.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%2Frou5u3ds58rlkweb2lex.jpg" alt="Image description" width="800" height="1000"&gt;&lt;/a&gt;&lt;br&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%2Fs7037pz44nmpc0tp2tte.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%2Fs7037pz44nmpc0tp2tte.jpg" alt="Image description" width="800" height="1000"&gt;&lt;/a&gt;&lt;br&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%2F9p17u5448kx3034qne09.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%2F9p17u5448kx3034qne09.jpg" alt="Image description" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;i hope you liked my page.&lt;br&gt;
                   THANK YOU....&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ice- Cream Hub</title>
      <dc:creator>Irene  Njuguna</dc:creator>
      <pubDate>Tue, 21 Jun 2022 07:10:11 +0000</pubDate>
      <link>https://dev.to/karrey/ice-cream-hub-550d</link>
      <guid>https://dev.to/karrey/ice-cream-hub-550d</guid>
      <description></description>
    </item>
  </channel>
</rss>
