<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by sonia jessica on Medium]]></title>
        <description><![CDATA[Stories by sonia jessica on Medium]]></description>
        <link>https://medium.com/@soniajm?source=rss-6522d17e4247------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kaSKXIc2dFlyyTvkLAH3Hg.png</url>
            <title>Stories by sonia jessica on Medium</title>
            <link>https://medium.com/@soniajm?source=rss-6522d17e4247------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:29:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soniajm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Reverse a String in Python]]></title>
            <link>https://python.plainenglish.io/how-to-reverse-a-string-in-python-3f5c118459ac?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5c118459ac</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 09:17:50 GMT</pubDate>
            <atom:updated>2022-07-07T09:17:50.829Z</atom:updated>
            <content:encoded><![CDATA[<h4>A tutorial on reversing a string in Python.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ikuipaAT--DEnJGE" /><figcaption>Photo by <a href="https://unsplash.com/@altumcode?utm_source=medium&amp;utm_medium=referral">AltumCode</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>What is String in Python?</strong></h4><p>The string is the sequence of characters. In real-world programming, strings are the most commonly used data types. If we consider an example of a project containing 100 variables, then out of these, 80–90 variables are of string type.</p><p><strong>Example</strong>: Name, DOB, Address, Username, password, etc are of string type. Most of the other data is also stored in the form of strings.<br>Python provides support for string declaration. And those are:</p><ul><li><strong>Single Quote</strong>:<strong> ‘ Welcome to InterviewBit ’</strong>. This is one of the ways we can create strings in python (in a single quote).</li><li><strong>Double Quote</strong>: <strong>“ Welcome to InterviewBit ”</strong>. We can also create the strings in the double-quotes.</li><li><strong>Triple Quote:</strong> <strong>‘’’ Hello, Welcome to InterviewBit. ‘’’</strong>. Triple quotes are also allowed in python to declare strings.</li></ul><p>We can declare strings in python in the above 3 ways, But what is the difference between these 3 different types of string declaration?</p><ul><li><strong>Single Quote </strong>and <strong>Double Quote</strong> are used for declaring the single-line string. And we can use an appropriate string declaration with single and double quotes when we have to use an escape sequence or an inside declaration of some text with quotes.</li><li><strong>Triple Quotes</strong> are mostly used for declaring the multiline strings. In most cases when we have a string containing multiple lines in it then we can go for string declaration with triple quotes in python. And also when we have to write multiline comments in python, then we can use these triple quotes to declare that.</li></ul><p>In other programming languages like Java, C/C++ where we have a single quote considered as the character data type. In Python, a single character is also considered a string. There is no character concept in Python. But if we want to access the characters from the string in Python, we can use indexing to get that.<br><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*1dMGBURDYoVR0v3L-rmFxg.png" /></figure><p>In Python, we also have negative indexing that we can index with -1 starting from the last character in the string. As described above in the image.</p><p>The different ways to declare the string in Python program:</p><pre><strong>if __name__ == &quot;__main__&quot;:<br>    #Single Quote String Declaration<br>    single_quote_string = &#39; Hello, Welcome to String declaration in python &#39;<br><br>    #Double Quote String Declaration<br>    double_quote_string = &quot; Double Quote String Declaration in &#39;Python&#39; &quot;<br><br>    #Triple Quote String Declaration<br>    triple_quote_string = &#39;&#39;&#39; Hello, Welcome to InterviewBit Article.<br>    In this, we will see how to reverse a string<br>    in Python&#39;&#39;<br>    <br>    &#39;&#39;&#39;<br>    This is the multiline comment. Python <br>    also allows writing multi-line comments <br>    using triple quotes.<br>    &#39;&#39;&#39;</strong></pre><pre><strong>print(single_quote_string)<br>    print(double_quote_string)<br>    print(triple_quote_string)</strong></pre><p>Till now we have seen how differently we can declare the strings in python. Now the problem statement is, how to reverse a string in python. What are the different ways to reverse it and which method is most effective?</p><h4>Problem Statement</h4><p>You have been given a string s. Now your task is to reverse the string s. For more clarity on the problem, consider the below cases- <br><strong><em>Example </em></strong>—</p><ul><li><strong>s </strong>= “ Hello World! ” <strong>Output </strong>— “ !dlroW olleH ”</li><li><strong>s</strong> = “ Welcome to InterviewBit. ” <strong>Output </strong>— “ .tiBweivretnI ot emocleW ”</li></ul><h4><strong>Approach 1 — (Using While loop)</strong></h4><p>We have already seen that strings are the sequence of characters. And in python, we can get the character from the string using indexing. So using the while loop we can swap the positions of the character in the string. Consider the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*yZU157F3QjUX8925xAPpNA.png" /></figure><p>As per the above image if we swap the characters with their positions, then we can see the string will be reversed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*-G32B-BJhkvUPLjSqyJy2Q.png" /></figure><p>So this can be one way how we can reverse the strings in Python using the while loop. Now the algorithm for this solution will be like this:</p><p><strong>Algorithm:</strong></p><ul><li>Start.</li><li>Declare 2 pointers, i and j. i will point to the 0th index and j will point to the last index of the string.</li><li>Run a loop until both i and j overlap each other.<br>- Swap the positions of the characters with index i and j.<br>- Increment i and decrement j.</li><li>Print the result.</li><li>End.</li></ul><p><a href="https://www.interviewbit.com/online-python-compiler/">Python Program</a> for the above Algorithm:</p><pre>if __name__ == &quot;__main__&quot;:<br>#Declaring a string.<br> string = &quot;Hello and Welcome to InterviewBit&quot;;<br>#Declaring pointers<br> i = 0<br> j = len(string)-1<br>#Converting string to list<br> st = list(string)<br>#Loop for reversing<br> while i &lt; j:<br> #Swapping the characters <br> st[i], st[j] = st[j], st[i]<br>#Incrementing and decrementing the pointers<br> i+=1<br> j-=1<br> <br> #Converting the swapped list to the string<br> string = &#39;&#39;.join(map(str, st))<br> print(string)<br></pre><h4>Run Code:</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2F47461b68752e199c52b1&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2F47461b68752e199c52b1%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/eecbfde2ef1784720e2fc35278693f85/href">https://medium.com/media/eecbfde2ef1784720e2fc35278693f85/href</a></iframe><h4><strong>Explanation of code:</strong></h4><p>In the above code, we first declared the variables that point to both the ends in the string. And we have converted the string into a list because strings are not mutable and we cannot change the values in the string. And we did swapping for the characters until the pointers didn’t cross each other.</p><h4><strong>Approach 2 — (using recursion)</strong></h4><p>We can also use recursion to solve this. Although there are many ways to use recursion, let’s see the approach of using the extra string that will store the reversed string.<br>What we can do in this approach is we will append the last character from the old string into the new string. And will ask recursion for doing the same thing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*HFjKRHKl8xpBxlojBIUEiw.png" /></figure><p>So after recursion terminates, then the string will be reversed and will be copied to a new string and we can print that string. We can also achieve this using for loop, but for the technique, we have seen it using the recursion.</p><h4><strong>Algorithm for this approach:</strong></h4><ul><li>Define a function that reverses a string.</li><li>Copy the last value to the new string.</li><li>Recursively call for the smaller problem.</li></ul><h4><strong>Python Code for the above algorithm:</strong></h4><pre>def revString(st, output, n):<br> #Base case if no character left then return the reversed string<br> if n &lt; 0:<br> return output</pre><pre>#Append the last character to the output string <br> output += st[n]</pre><pre>#Recursively call for the same<br> return revString(st, output, n-1)</pre><pre>if __name__ == “__main__”:<br> st = “Welcome to InterviewBit”<br> output = “”<br> output = revString(st, output, len(st)-1)<br> print(output)</pre><h4><strong>Run Code:</strong></h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2F7045a5d37fb0446f1c72&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2F7045a5d37fb0446f1c72%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/180e098a2bff73448dc00f513f80946b/href">https://medium.com/media/180e098a2bff73448dc00f513f80946b/href</a></iframe><h4><strong>Explanation of the code</strong></h4><p>In the above code, we have declared the function that will reverse the string and return the reversed string. The function will do one task of appending the last character from the string and pass the rest work to the recursive call. Then the recursive function will do the same and when it reaches the end of the string, it returns the reversed string.</p><h4><strong>Approach 3 — (using predefined function ‘reversed()’)</strong></h4><p>There is a predefined function in python called reversed(). This function will take the argument of sequence and return the iterator. The iterator returns start from the last index and end at the first index. So for implementing this approach, we need to join each character with the empty string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*1rOw0ulnofaoKsyBh5SZZw.png" /></figure><h4><strong>Algorithm for this approach:</strong></h4><ul><li>Create a string to reverse.</li><li>Pass it to the reversed function and join it with the empty string.</li><li>Print the reversed string.</li></ul><h4><strong>Python code for the above approach:</strong></h4><pre>if __name__ == &quot;__main__&quot;:<br> s = &quot;Hello and Welcome to InterviewBit<br> #Calling the reversed function and joining with the empty string.<br> revString = &#39;&#39;.join(reversed(s<br> #printing the reversed string<br> print(revString)</pre><p><strong>Run code:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2F8e7e8fb65abc708c9311&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2F8e7e8fb65abc708c9311%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bdb2cfb05a5a80083e01135a647d007/href">https://medium.com/media/2bdb2cfb05a5a80083e01135a647d007/href</a></iframe><h4><strong>Explanation of the code:</strong></h4><p>We are creating the string and then passing it to the reversed function. The reversed() will return the iterator and join the iterator returned values to the new string. The string is reversed.</p><h4><strong>Approach 4 — (using slicing)</strong></h4><p>String slicing is another approach that returns the sequence from the specified position and it also helps to define how many steps we need to take for traversing the sequence. Slicing any sequence accepts 3 arguments. [start, end, noOfSteps]. So using this concept, we can reverse the string.</p><p>Algorithm for the above approach:</p><ul><li>Declare the string.</li><li>Slice the string by passing the -1 in the noOfSteps for slicing.</li><li>Print the reversed string.</li></ul><h4><strong>Python code for the above approach</strong></h4><pre>if __name__ == &quot;__main__&quot;:<br> st = &quot;Hello and Welcome to InterviewBit&quot;<br> #Slicing the string<br> st = st[::-1]<br> print(st)</pre><p>Run code</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2F47887678fae8ffec6d89&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2F47887678fae8ffec6d89%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/925febf9b8c10e9d776bcd16b14e7623/href">https://medium.com/media/925febf9b8c10e9d776bcd16b14e7623/href</a></iframe><h4><strong>Explanation of the code</strong></h4><p>We are passing the -1 in the noOfSteps argument. When slicing sees that the start and end are left blank then it automatically understands that it will be negative indexing that it has to follow. So it traverses from the end to the start. And the result we stored in the variable and printed.</p><h4><strong>Time Complexity Analysis</strong></h4><p>In each of the above approaches either manually or using the predefined function, there is an iterator that traverses the string. So if the length of the string is n. Then the time complexity will be O(n).</p><h4><strong>Conclusion</strong></h4><p>There are many ways that we can reverse the string in python. The question is, which approach do we have to use to reverse the string in python? The answer to the question is when there are complete things we need to handle, then always prefer the predefined functions, because the developers who defined that library function have already optimized it. Here is the python online compiler in which you can able to write and execute your code without installing it on your machine.</p><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><em> and </em><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>. Check out our </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Community Discord</em></strong></a><em> and join our </em><a href="https://inplainenglish.pallet.com/talent/welcome"><strong><em>Talent Collective</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5c118459ac" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/how-to-reverse-a-string-in-python-3f5c118459ac">How to Reverse a String in Python</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics for Data Science]]></title>
            <link>https://pub.towardsai.net/statistics-for-data-science-79584e7d6d9c?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/79584e7d6d9c</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Fri, 06 May 2022 12:03:03 GMT</pubDate>
            <atom:updated>2022-05-06T12:03:03.295Z</atom:updated>
            <content:encoded><![CDATA[<p>In this hyper-connected world, data is being consumed and generated at an unparalleled pace. Despite the fact that we enjoy this superconductivity of data, it brings forth abuse as well. Data professionals have to be trained to utilize statistical methods not just to decipher numbers but to bring to light such abuse and save us from being misled. Few data scientists are formally experienced in <a href="https://datascience.virginia.edu/news/how-much-do-data-scientists-need-know-about-statistics">statistics</a>. There are also a handful of good books and courses that demonstrate these statistical methods from the perspective of data science. A British mathematician, Karl Pearson, once described that statistics is the grammar of science and this is especially true for Computer and Information Sciences, Biological Science, and Physical Science. When you are beginning your <a href="https://www.interviewbit.com/data-science-interview-questions/">career in Data Science</a> or Data Analytics, acquiring statistical knowledge will encourage you to better leverage data insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DUi1KeotT-yKrGBcgDX98A.png" /></figure><p>We cannot underestimate the importance of statistics in data science and data analytics. Statistics offer tools and methods to discover the structure and provide deeper data insights. Both mathematics and statistics love facts and hate guesses. Learning the basics of these two vital subjects will let you think critically and be creative while utilizing the data to resolve business problems and carry out data-driven decisions.</p><p>In this article, we will learn about the importance and basics of Statistics in Data Science. Data science is an interdisciplinary, multifaceted field of study. It not only dominates the digital world but is integral to some of the most basic functions, such as social media feeds, internet searches, grocery store stocking, political campaigns, airline routes, hospital appointments, and more. It’s everywhere. Among other disciplines, statistics is one of the most significant disciplines for data scientists. Learn more about data science interview questions for you to prepare your best for interviews.</p><h4>Statistics for Data Science</h4><p>Statistics act as a base while handling data and its analysis in data science. There are specific core theories and basics which have to be comprehensively understood before getting into advanced algorithms. Visual representation of the data and the algorithm’s performance on the data acts as a good metric for the layman to understand the same. Additionally, visual representation assists in identifying specific trivial patterns, outliers, and specific metric summaries like mean, variance, and median, which help in interpreting the middlemost value, and how the outlier influences the rest of the data. Data related to statistics is of many types. We have discussed some of them below.</p><ul><li>Categorical data describes attributes of people, including marital status, gender, the food they prefer, and so on. It is also regarded as ‘yes/no data’ or ‘qualitative data’. It takes numerical values such as ‘1’, ‘2’, where these numbers show one or other types of attributes. These numbers are not mathematically important, which states that they can’t be associated with each other.</li><li>Continuous data handles data that is immeasurable, and can’t be counted, which basically continual forms of values are. Predictions from linear regression are continuous and are a continuous distribution that is also called the probability density function.</li></ul><p>With statistics, you can create a thorough comprehension of data via data inference and summarization. Talking about these two terms, statistics is split into two –</p><ul><li>Descriptive Statistics</li><li>Inferential Statistics</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCFX8-niox7j5l3xqZxhmg.png" /></figure><ol><li>Descriptive Statistics<br>Descriptive Statistics or summary statistics is used for describing the data. It handles the quantitative summarization of data and this summarization is executed via numerical or graphs representations. To have a full understanding of descriptive statistics, learn a few of the following key concepts:</li></ol><ul><li><strong>Normal Distribution: </strong>In a normal distribution, we show many data samples in a plot. With the help of normal distribution, we portray large values of variables in the form of a bell-shaped curve, called the Gaussian Curve.</li><li><strong>Variability: </strong>Variability calculates the distance between the central mean of the distribution and the data point. There are different measures of variability, including standard deviation, range, variance, and inter-quartile ranges.</li></ul><p>2. Inferential Statistics</p><p>Inferential Statistics is the process of deducing or concluding from the data. With inferential statistics, we deduce a conclusion about the larger population by executing different tests and deductions from the smaller sample. For instance, during an election survey, if you are willing to know the number of people who support a political party, you just have to ask everyone about their views. This approach is not correct, as there are several people in India, and questioning every single person is a tedious task. Thus, we pick a smaller sample, draw conclusions from that sample, and attribute our observations to the larger population. There are several approaches in inferential statistics which are suitable for data science. Let us look at some of these techniques:</p><ul><li><strong>Central Limit Theorem: </strong>The mean of the smaller sample is like that of the mean of the larger population, in a central limit theorem. Thus, the resulting standard deviation is equal to the standard deviation of the population. A crucial concept of the Central Limit Theorem is the evaluation of the population mean. By multiplying the standard error of the mean with the z-score of the percentage of confidence level, we can measure margin error.</li><li><strong>Hypothesis Testing: </strong>Hypothesis testing is the method of assumption. Applying hypothesis testing, we attribute the outcome from a smaller sample to a bigger group. There are two hypotheses that we should be testing against each other: The alternate Hypothesis and the Null Hypothesis. A null hypothesis shows the ideal scenario, while an alternate hypothesis is usually the opposite, using which, we try to prove it wrong.</li><li><strong>Qualitative Data Analysis:</strong> Qualitative Data Analysis comprises two essential techniques, i.e regression, and correlation. In regression, we determine the relationship between the variables. There are simple regression and multivariable regression. Also, if the function is non-linear, then we have a non-linear regression. Correlation is the method of discovering relationships between bi-variate data and random variables.</li></ul><h4>Statistical topics for Data Scientists</h4><p>There are several statistical techniques that data scientists have to grasp. When beginning your career, it is crucial to have a thorough understanding of these principles, as any gaps in knowledge will cause compromised data or false conclusions.</p><p><strong>Understand the Type of Analytics</strong></p><ul><li>Descriptive Analytics informs us what took place in the past and encourages a business to learn how it is performing by offering context to help stakeholders understand information.</li><li>Diagnostic Analytics interprets descriptive data a step further and encourages you to learn why something transpired in the past.</li><li>Predictive Analytics anticipate what is most prone to happen in the future and offer businesses actionable insights based on the data. Prescriptive Analytics offers recommendations in regards to actions that will take advantage of the predictions and advise the necessary actions toward a solution.</li></ul><p>A data scientist carries out a number of decisions every day. They vary from small ones, such as the ways to tune a model all the way up to the big ones, such as the team’s R&amp;D strategy. Many of these decisions need a firm foundation in statistics and probability theory.</p><h4><strong>Central Tendency</strong></h4><ul><li><strong>Mean</strong>: The average of the dataset.</li><li><strong>Median</strong>: The middle value of an ordered dataset.</li><li><strong>Mode</strong>: The most recurrent value in the dataset. If the data have many values that appeared most frequently, we have a multimodal distribution.</li><li><strong>Skewness</strong>: A measure of symmetry.</li><li><strong>Kurtosis</strong>: A measure of whether the data are light-tailed or heavy-tailed relative to a normal distribution</li></ul><h4>Probability distributions</h4><p>We define probability as the chance that something might happen, defined as a simple “yes” or “no” percentage. For example, when weather reporting shows a 30 percent chance of rain, it also implies there is a 70 percent possibility it will not rain. Determining the distribution computes the probability that all those likely values in the study will occur. For instance, calculating the probability that the 30 percent possibility of rain will vary over the coming two days is an example of the probability distribution.</p><h4>Dimension reduction</h4><p>Data scientists scale down the number of random variables under consideration via feature extraction (developing new features from functions of the original features) and feature selection (selecting a subset of relevant features). This streamlines data models and simplifies entering data into algorithms.</p><h4>Over and undersampling</h4><p>Sampling techniques are incorporated when data scientists have too little or too much of a sample size for classification. Data scientists will either curb the selection of a majority class or build copies of a minority class to support equal distribution depending on the balance between the two sample groups.</p><h4>Bayesian statistics</h4><p>Frequency statistics utilize current data to figure out the probability of a future event. However, Bayesian statistics take this concept a step further by accounting for elements we anticipate will be true in the future. For instance, think about predicting whether at least 100 users will visit your coffee shop every Saturday over the next year. Frequency statistics will demonstrate probability by interpreting data from the last Saturday’s visits. But Bayesian statistics will show probability by also taking into account a nearby art show that will begin in the summer and take place each Saturday afternoon. This lets the Bayesian statistical model offer a much more accurate figure.</p><h4>Regression</h4><ul><li>Linear Regression</li><li>Assumptions of Linear Regression</li><li>Linear Relationship</li><li>Multivariate Normality</li><li>No or Little Multicollinearity</li><li>No or Little Autocorrelation</li><li>Homoscedasticity</li></ul><p><strong>Linear Regression</strong> is a linear approach to creating the relationship between one independent variable and a dependent variable. A dependent variable is a variable being calculated in a scientific experiment. An independent variable is handled in a scientific experiment to assess the effects on the dependent variable.</p><p><strong>Another linear approach</strong>, Multiple Linear Regression models the relationship between two or more independent variables and a dependent variable.</p><h4>Steps for Executing the Linear Regression</h4><p><strong>Step 1:</strong> Know about the model description, directionality, and causality.</p><p><strong>Step 2:</strong> Go through the data, missing data, categorical data, and outliers</p><ul><li>Outlier is a data point that varies considerably from other observations. We can utilize the interquartile range (IQR) method and standard deviation method.</li><li>The dummy variable holds only the value 0 or 1 to show the result for categorical variables.</li></ul><p><strong>Step 3:</strong> Simple Analysis- Look at the effect of comparing the dependent variable to the independent variable and the independent variable to the independent variable</p><ul><li>Make use of scatter plots to check the correlation.</li><li>Multicollinearity arises when over two independent variables are extremely correlated. We can utilize the Variance Inflation Factor (VIF) to check if VIF &gt; 5 there is highly correlated and if VIF &gt; 10, then there is definitely multicollinearity among the variables.</li><li>Interaction Term suggests a modification in the slope from one value to another value.</li></ul><p><strong>Step 4</strong>: Multiple Linear Regression- Analyse the model and the correct variables</p><p><strong>Step 5: </strong>Residual Analysis</p><ul><li>Monitor normal distribution and normality for the residuals.</li><li>Homoscedasticity represents a situation where the error term is similar across all values of the independent variables and implies that the residuals are the same across the regression line.</li></ul><p><strong>Step 6:</strong> Interpretation of Regression Output</p><ul><li>R-Squared is a statistical measure of fit that shows how much variation of a dependent variable is demonstrated by the independent variables.]</li><li>A Higher R-Squared value means minor differences between the fitted values and observed data.</li><li>P-value</li><li>Regression Equation</li></ul><h4>Terminologies in Statistics — Statistics for Data Science</h4><p>One should know some of the statistical terminologies while sitting for any Data Science interview. In most of the Data Scientist interview processes, the most commonly asked questions are from machine learning, probability statistics, coding, and algorithms. We’ve discussed these statistical terminologies below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*LpweU0R50dEIopRCd5W21w.png" /></figure><ul><li><strong>Variable</strong>: It can be a number, characteristic, or quantity that can be counted. It is also known as a data point.</li><li><strong>Population</strong>: It is the collection of resources from where the collection of data is worked out.</li><li><strong>Sample</strong>: Basically, it is a subset of the population employed for data sampling and to predict the result in inferential statistics.</li><li><strong>Statistical Parameter</strong>: It is nothing but a quantity that helps index a family of probability distributions such as the median, mode or mean of a population. It is a population parameter.</li><li><strong>Probability Distribution</strong>: It’s a mathematical concept that chiefly provides the probabilities of occurrence of various outcomes, usually for an experiment that statisticians conduct.</li></ul><h4>Data Science Interview Example</h4><p>Data Science <strong>interview preparation </strong>is quite a deal for everyone. Most of the candidates find it difficult to get through the recruitment process. Even though you’ve appeared in many interviews, each interview is a new learning experience. It can be a strenuous situation, as you will have to answer the tricky questions reasonably and satisfactorily.</p><p>In a data science interview, there are fundamental questions revolving around coding, behavioral questions, machine learning, modeling, statistics, and product sense, which the candidate must be certainly prepared for. Let’s talk about statistics in general. Questions about statistical concepts in a data science interview can be tricky to handle, as, unlike a product question, statistics questions have a definite right or wrong answer. This implies that your understanding of certain statistics and probability concepts will be fully tested during the interview. Thus, it is imperative to brush up on your statistics knowledge and be fully prepared before the data science interview. There are also at least three big topics in statistics that are commonly asked in a data science interviews, which are:</p><ul><li>The measure of center and spreads (mean, variance, standard deviation)</li><li>Inferential statistics (p-Value, Confidence Interval, Sample Size, and Margin of Error, Hypothesis Testing)</li><li>Bayes’ theorem</li></ul><p>The questions that the interviewer asks generally fall into one or two buckets: the theory part and the implementation part. So, are you aware of how to improve your theory and implementation knowledge? What we can recommend from experience is that you must have a few personal project stories. You should have two to three stories where you can talk in-depth about a data science project you’ve done in the past. You should be able to answer questions like:</p><ul><li>Why did you choose this model?</li><li>What assumptions do you need to validate in order to use this model correctly?</li><li>What are the trade-offs with that model?</li></ul><p>If you can answer these questions, you are basically convincing to the interviewer that you know both the theory and have implemented a model in the project. So, some of the modeling techniques that you may need to know are:</p><ul><li>Regressions</li><li>Random Forest</li><li>K-Nearest Neighbour</li><li>Gradient Boosting and more</li></ul><p>In the next section, we will learn about the commonly asked statistical question in Data Science interviews.</p><p><strong>10 Frequently asked Statistics interview questions</strong></p><h4>Q.1: Mention the relationship between median and mean in normal distribution?</h4><p>Ans: In the normal distribution, the mean is equal to the median.</p><h4>Q.2: What is the proportion of confidence intervals that will not contain the population parameter?</h4><p>Ans: Alpha is the probability of a confidence interval that will not contain the population parameter. <br>α = 1 — CL<br>We usually express alpha as a proportion. For example, if the confidence level is 95%, then alpha would be equal to 1–0.95 or 0.05.</p><h4>Q.3: Mention the way to calculate range and interquartile range?</h4><p>Ans: IQR = Q3 — Q1<br>Here, Q3 is the third quartile (75 percentile) <br>Here, Q1 is the first quartile (25 percentile)</p><h4>Q.4: What are the consequences of the width of the confidence interval?</h4><p>Ans: Confidence interval is utilized for decision making. As the confidence level rises, the width of the confidence interval also rises. As the width of the confidence interval increases, we seem to receive useless information as well. Useless information — wide CI High risk — narrow CI</p><h4>Q.5: What is the advantage of using box plots?</h4><p>Ans: Boxplot is a visually effective portrayal of two or more data sets and helps a quick comparison between a group of histograms.</p><h4>Q.6: Mention one method to find outliers?</h4><p>Ans: The most efficient way to find all of your outliers is by employing the interquartile range (IQR). The IQR contains the middle bulk of your data, so we can easily find the outliers once we know the IQR.<br>Widely used — Any data point that lies outside the 1.5 * IQR<br>Lower bound = Q1 — (1.5 * IQR)<br>Upper bound = Q3 + (1.5 * IQR)</p><h4>Q.7: What do you understand by the degree of freedom?</h4><p>Ans: We define DF as the number of options we have and we use DF with t-distribution and not with Z-distribution<br>For a series, DF = n-1 (where n is the number of observations in the series)</p><h4>Q.8: When to use t distribution and when to use z distribution?</h4><p>Ans: We must satisfy the following conditions to use Z-distribution Do we know the population standard deviation? Is the sample size &gt; 30?CI = x (bar) — Z*σ/√n to x (bar) + Z*σ/√n<br>Else we should use t-distribution CI = x (bar) — t*s/√n to x (bar) + t*s/√n</p><h4>Q.9: How would you explain a confidence interval to a non-technical audience?</h4><p>Ans: We can apply Bayes Theorem here. Let U stand for the case where we are flipping the unfair coin and F stand for the case where we are flipping a fair coin. As the coin is chosen randomly, we know that P(U) = P(F) = 0.5. Let 5T denote the event where we flip 5 heads in a row. Then we are interested in solving for P(U|5T), i.e., the probability that we are flipping the unfair coin, given that we saw 5 tails in a row.<br>We know P(5T|U) = 1 since by definition the unfair coin will always result in tails. We know that P(5T|F) = 1/2⁵ = 1/32 by definition of a fair coin. As per Bayes Theorem we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKyO21mwmRtuexXfgENu3g.png" /></figure><p>Therefore, the probability we picked the unfair coin is about 97%.</p><h4>Q.10: What are H0 and H1 for the two-tail test?</h4><p>Ans: H0 is regarded as the null hypothesis. It is the normal case or default case. For one tail test x &lt;= µ For two-tail test x = µ<br>H1 is regarded as an alternate hypothesis. It is the other case. For one tail test x &gt; µ For two-tail test x &lt;&gt; µ</p><h3>How is Statistics Important for Data Science?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gLh7gu4_uwUCvwzRmrWgkw.png" /></figure><p>Below mentioned are a few points that show the importance of statistics for data science.</p><h4>Enables classification and organization</h4><p>This is a statistical approach that’s employed by the same name in the data science and mining fields. Classification is used to classify data into proper, observable analyses. Such an organization is key for companies who decide to utilize these insights to draw predictions and create business plans. Also, it is the first step to making a huge chunk of data usable.</p><h4>Helps to measure probability distribution and estimation</h4><p>These statistical approaches are the key to understanding the fundamentals of machine learning and algorithms as logistic regressions. LOOCV and Cross-validation techniques are also intrinsically statistical tools that are introduced into the world of Data Analytics and Machine Learning for A/B, inference-based research, and hypothesis testing.</p><h4>Finds structure in data</h4><p>Businesses often have to handle tons of data from a panoply of sources, each more complex than the last. Statistics can come to your aid in spotting anomalies and trends in this data, which lets the researchers dispose of irrelevant data at a very early stage rather than sifting through data and wasting effort, resources and time.</p><h4>Promotes statistical modeling</h4><p>Data comprises a series of complicated interactions between variables and factors. To frame these or display them coherently, statistical modeling using networks and graphs is the key. This also helps to determine and account for the effect of hierarchies on global structures and escalate local models to a global scene.</p><h4>Aids data visualization</h4><p>Visualization in data is the portrayal and analysis of found structures, insights, and models in interactive, effective, and logical formats. It’s also essential that these formats be simple to update. In this way, nothing has to go through a massive overhaul every time there’s a fluctuation in data. Apart from this, data analytics representations also utilize the same display formats as statistics — histograms, graphs, and pie charts. Not only does this make data more readable, but it also makes it much simpler to identify trends or errors and offset or enhance them as needed.</p><h4>Promotes awareness of distributions in model-based data analytics</h4><p>Statistics can help to find clusters in data or even other structures that depend on time, space, and other variable factors. Reporting on networks and values without statistical distribution methods can cause measures that don’t regard variability, which can make or break your results.</p><h3>Conclusion</h3><p>Every company is aiming to become data-driven. Thus, we are noticing a rising demand for data scientists and analysts. Now, to deal with issues, answer questions, and chalk out a strategy, we need to make sense of the data. Fortuitously, statistics provide a pile of implements to engender those insights. We learned about various statistical requirements for Data Science. We studied how data science depends on statistics and how descriptive and inferential statistics form its core. In a nutshell, we conclude that statistics for data science is a mandatory requirement for mastering it. Hope now you are clear with all the theories related to statistics for data science. It’s time to check how this concept will help you ace your first job in data science.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79584e7d6d9c" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/statistics-for-data-science-79584e7d6d9c">Statistics for Data Science</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET MVC 5: New Features]]></title>
            <link>https://medium.com/c-sharp-programming/asp-net-mvc-5-new-features-f23f46038ada?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/f23f46038ada</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[aspnet-mvc]]></category>
            <category><![CDATA[aspnet]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 07:43:43 GMT</pubDate>
            <atom:updated>2022-04-18T07:43:43.690Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>Today, people all over the world use numerous web applications in their daily lives. Many of these applications are boring, tedious, and not secure. This is where ASP.NET comes into play and makes these applications valuable.</p><p>The <a href="https://docs.microsoft.com/en-us/aspnet/mvc/">ASP.NET MVC</a> framework has developed into a popular choice among developers for building all types of web applications. It is easier to develop, debug, and deploy ASP.NET MVC web apps. All of these tasks can be handled within Visual Studio .NET, an integrated development environment.</p><p>Several of the world’s largest companies have their heavily trafficked websites built on <a href="https://www.interviewbit.com/asp-net-mvc-interview-questions/">ASP.NET MVC</a>, including Microsoft, Volvo, Stack Overflow, Ikea, etc.</p><h4>What is ASP.NET MVC 5?</h4><p>Based on Model-View-Controller (MVC) architecture, ASP.NET MVC 5 is a web development framework that supports programming models, complete software infrastructures, and various services for the creation of powerful web applications for mobile devices and PCs. By using HTML, CSS, and JavaScript, ASP.NET allows developers to create web applications. It was released by Microsoft in 2009 and is a part of the Microsoft .Net platform. ASP.NET applications employ compiled codes written with reusable and extensible .Net framework components and objects. These codes can utilize all the classes in the .Net framework. HTML/JS, WML, XML, VB.NET, C#, J#, JScript.NET, and Visual Studio are all supported by the framework.</p><p>Now some of you must be thinking- <strong>What does MVC mean</strong>?</p><p>In the field of software and web development, “Model-View-Controller (MVC)” is a term you hear a lot, but if you’re unfamiliar with it, it can be confusing.</p><p>Model-View-Controller is essentially a design pattern that provides code reusability and a more structured application architecture by separating the different aspects of a piece of Software.</p><p>A website, for example, could be broken down into three main components.</p><ul><li>Firstly, the “View” is what the user sees and is usually composed of HTML, CSS, and Javascript</li><li>Secondly, the “Model” refers to how the website interacts with the database.</li><li>Furthermore the “Controller” connects the “View” and “Model” together. The “Controller” brings a request from the “View” and dispatches it to the “Model” when a user requests something from the database.</li></ul><p><strong>A real-world example of the Model-View-Controller (MVC) model can be picturized through a Car driving mechanism:</strong></p><p>Three main components make up every car:</p><ul><li>The View is illustrated by-User interface which consists of the brake, Gear lever, steering wheel, and much more elements of a car.</li><li>The Controller is depicted by-Mechanism (Engine of the vehicle)</li><li>Model is depicted by-Storage (fuel tank of the vehicle)</li></ul><p><strong>ASP.NET MVC 5 new features:</strong></p><p><strong>1. One ASP.NET</strong><br>One ASP.NET provides web developers with a unified project system. With this system, you can work with numerous frameworks, such as MVC, Web API, Web Forms, etc., in one project. Using the One ASP.NET project system, as a result, you will be able to use ASP.NET Web Forms and MVC jointly and, if desired, ASP.NET Web API and SignalR, as well in the same Web application.</p><p>Employing One ASP.NET Experience to Create a New Site:</p><ul><li>First, open the Visual Studio Express 2013 for Web</li><li>From the file menu, select new project.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4GCY_D-2VKwJ1QgGDektkA.png" /></figure><ul><li>Now after selecting a new project, choose ASP.NET Web Application and click OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*MXvsvNlb_JMs3w5L8drSag.png" /></figure><ul><li>After performing that, select the Web Forms template and select the MVC and Web API checkboxes.</li><li>Authentication option should be set to Individual User Accounts and after performing that select OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*oR0va60mQXiGstnxrhkPig.png" /></figure><p>This is how you can start a new project and add Web API and MVC components utilizing the Web Forms template.</p><p><strong>2. Bootstrap:</strong></p><p>Twitter Bootstrap has been added as the default user interface framework for MVC applications in Visual Studio 2013. Twitter created Bootstrap to design forms, navigation, buttons, tables, etc. with HTML and CSS. Bootstrap is used for developing Rapidly Responsive User Interfaces by leveraging HTML and CSS-based templates.</p><p>Bootstrap can be used to create an interface that performs well across all screen sizes, including devices that we use for day-to-day activities like desktops and mobile devices.</p><p>Commencing a new MVC project will include Bootstrap, so you will see Bootstrap.css and Bootstrap.js in your project.</p><p><strong>2a. Attribute-Based Routing</strong></p><p>ASP.NET MVC routes a URI to action through routing. In MVC 5, there is a new type of routing called attribute routing. The method depicts routes that are based on attributes. Using attribute routing in your web application will give you greater control over URIs.</p><p>There is still support for the earlier style of routing, known as convention-based routing. Moreover, both techniques can be combined within a single project.</p><p>During configuration, call <strong><em>MapMvcAttributeRoutes</em></strong> in the RouteConfig file to enable attribute routing.</p><p><strong>SYNTAX:</strong></p><pre>public class RouteConfig<br>{<br>    public static void RegisterRoutes(RouteCollection routes)<br>    {<br>        routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);<br> <br>        routes.MapMvcAttributeRoutes();<br>    }<br>}</pre><p><strong>2b. Scaffolding</strong></p><p>In many MVC frameworks, such as ASP.NET MVC, scaffolding is employed to generate code for primary CRUD (create, read, update, and delete) operations against your database. The auto-generated code can also be edited or customized to meet your needs. Scaffolding can help to diminish the length of codes that you wrote manually in the earlier versions of MVC.</p><p>Among scaffolding’s components are page templates, entity page templates, field page templates, and filter templates. This type of template is called a scaffold template and is very useful as it facilitates you to quickly create a data-driven website.</p><p>We will further see how to implement it in the project discussed later in this article.</p><p><strong>2c. Filter Overrides</strong></p><p>In previous versions of MVC, you had to apply a filter for every action and controller individually in order to override a filter. A new feature of MVC 5 is Filter Overrides. According to the documentation “Overriding which filters apply to an action method or a controller can now be accomplished by defining a filter override. An override filter will define a set of filter types that should not be applied to a provided action or controller. This allows you to add on global filters, but exclude some from a certain action or controller”.</p><p>With MVC, the following filters are available:</p><ul><li>Authentication filters</li><li>Exception filters</li><li>Action filters</li><li>Result filters</li><li>Authorization filters</li></ul><p>Accordingly, we have five filter overrides</p><ul><li>OverrideAuthenticationAttribute</li><li>OverrideExceptionAttribute</li><li>OverrideAuthorizationAttribute</li><li>OverrideActionFiltersAttribute</li><li>OverrideResultAttribute</li></ul><p>The Authorize Filter is applied at the controller level in the following example. Thus, only the Admin user can access the Home controller action methods. The Authorize Filter can now be excluded or bypassed from the “About” method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*xag-CaoWZvTNazmStlUvog.png" /></figure><p>In the following case, this “About” method can be marked with the “OverrideAuthorization” attribute. The Admin user can now access all action methods of the home controller except the “About” method. “About” can be accessed without authorization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*lUF9LMB_coD2CP1hNKGWeQ.png" /></figure><p>3. <strong>Understanding and Implementing the ASP.NET MVC 5 features in Real-Time project</strong></p><p>The Library Management System will be created using ASP NET and is used for keeping track of all library management activities, such as recording book stocks, all the student information, issuing books, returning the books.</p><p><strong>By Building this project you will learn:</strong></p><ul><li>How to create a data model</li><li>How to scaffold a basic crud application for your model.</li><li>How does ASP.Net MVC handles all the requests efficiently</li><li>How to perform Routing</li></ul><p>The functionality of a librarian includes:</p><ul><li>It should be possible for him to add new books to the library.</li><li>The list of all the books and books borrowed should also be known to him</li><li>Viewing the history of books borrowed by customers.</li><li>It should be possible for him to edit the book details.</li><li>It should be possible for him to remove a book.</li><li>Customers can be added to the list.</li><li>Assigning a borrowed book to a customer should be another possible task for him.</li></ul><p>As discussed before also, you can commence a new project and add Web API and MVC components using the Web Forms template.</p><p>1) First, open the Visual Studio Express 2013 for Web <br>2)Open the file menu and then select new project.<br>3)Now select ASP.NET Web Application and click OK.<br>4) After that, select the Web Forms template and select the MVC and Web API checkboxes. <br>5) Authentication option should be set to Individual User Accounts and after that select OK.<br>In the solution explorer, open the Models folder.</p><p>Create a new class called management in the Models folder. This can be done by right-clicking on the Models folder, choosing add and clicking class.</p><p>This is how your management class should look after you update the code.</p><pre>public class Management<br> {<br> public int BId { get; set; }<br>public string Book_Tittle <br>{ get; set; }</pre><pre>public string No<br> { get; set; }</pre><pre>public string Writer <br>{ get; set; }</pre><pre>public string Published_By<br> { get; set; }<br> }<br>}</pre><p>To map our textbook model to our database, we need to add it to the ApplicationDbContext.</p><p>As you work you are scaffolding a basic CRUD operation for books, namely Create, Read, Update, and Delete.</p><p>Our navigation bar will possess a link to books. This is done by using Html.ActionLink takes three parameters. The first parameter is the name that will appear in the link, the second parameter is the Action within our controller, and the third parameter is the name of the controller.</p><p>Run the application after you’ve added the link to our textbook.</p><p>In the navigation bar, you should now see the link for Textbooks. Click on it, and this page will appear. On this page, you will find the book controller’s index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*k5NQnuGNMnxeMeNxw46ukQ.png" /></figure><p>Now, Understanding the request lifecycle in ASP.Net MVC is crucial to building this project.</p><p>Our MVC application looks for the routes registered in the URL Routing Module for which controller to call when making HTTP requests.</p><p>In the App_Start folder, open the RouteConfig.cs file to see the registered routes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*ui5kbZ1uFQwIOxw_X1NDHw.png" /></figure><p>Compare the value of URL in routes.MapRoute with our browser’s URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*rqg1FN9PA72G8EUsj2oKmw.png" /></figure><p>To determine which controller will handle a request from the above URL, it will first inspect the registered routes. When the controller is determined, the module will initialize the controller and determine what action should be executed for the request with a module called Action Invoker.</p><p>The Edit method can be found in the code of the BooksController.</p><p>The view-engine will find the necessary view in the Views folder after performing the action.In our case it will be looking for Views -&gt; Books -&gt; Edit.cshtml. After that view will be rendered for the user.</p><p>For building the complete project you can find the source code <a href="https://github.com/alexcalingasan/LibraryManagement">here</a>.</p><h4>Conclusion</h4><p>So in this article, we discussed some new and interesting features of ASP.NET MVC 5 to make your coding journey easy. Earlier versions of MVC could have provided some of the functionality provided by these new features, but now that these features are part of MVC, it is easier than ever before to use them since there are no configuration changes or external components needed. Hope you find this article helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f23f46038ada" width="1" height="1" alt=""><hr><p><a href="https://medium.com/c-sharp-programming/asp-net-mvc-5-new-features-f23f46038ada">ASP.NET MVC 5: New Features</a> was originally published in <a href="https://medium.com/c-sharp-programming">Any Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top Applications of Deep Learning]]></title>
            <link>https://medium.com/coderbyte/top-applications-of-deep-learning-85e40754c6d7?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/85e40754c6d7</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[deep-learning-framework]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Wed, 06 Apr 2022 16:08:41 GMT</pubDate>
            <atom:updated>2022-04-06T16:08:41.838Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is Deep Learning?</h4><p>A neural network architecture-based <strong>deep learning</strong> technique is a subset of machine learning that imitates the way how human beings gain knowledge. In neural networks, “deep” refers to the number of hidden layers and the no of hidden layers in traditional neural networks is two to three, while deep neural networks can hold 150 or more than that. As part of data science, including statistics and predictive modeling, deep learning is an important component. A key benefit of deep learning is that it speeds up and simplifies the process of gathering, examining, and analyzing immense amounts of data that is utilized by data scientists.</p><p>Through the help of deep learning, computer models can retain to perform classification tasks from images, text, or audio directly. In order to prepare models, a considerable set of labeled data and a neural network architecture holding many layers is used. Deep learning algorithms vary from traditional machine learning algorithms in that they are stacked in a hierarchy from the simplest to the most complex.</p><p><em>As an example of deep learning</em>, <em>picture a toddler whose first word is “cat.”. As the toddler points to objects and says the word cat, he learns what a cat is and what a cat isn’t. In response, parents say, “Yes, that’s a cat,” or “No, that’s not a cat.” As the toddler points to objects, he becomes more aware of the traits that all cats share. By building a hierarchy, the toddler clarifies a complex abstraction — the concept of a cat — by using the knowledge gained from the preceding layers of the hierarchy.</em></p><h4>Stats from relevant recent sources of its usage in various industries:</h4><p>Deep learning has a lot of applications and in the next few years, the market for deep learning will reach almost $1 billion. Check out the following statistics:</p><ul><li>Platforms behind voice assistants were created by deep learning, and the pandemic increased the use of these devices. From Mar-April 2020, twenty-five per cent of people used it several times a day, up from 20% between Dec 2019-Jan 2020 (<a href="https://voicebot.ai/2020/05/01/voice-assistants-see-uptick-in-daily-use-during-the-pandemic-report/">Voicebot.ai, 2020</a>).</li><li>The market size of deep learning software in the US by 2025 (<a href="https://www.statista.com/statistics/779696/united-states-deep-learning-market-size/">Statista, 2019</a>): $80 million.</li><li>By 2027, the global deep learning market is expected to reach $44.3 billion at a CAGR of thirty-nine per cent (<a href="https://www.reportlinker.com/p05798338/Global-Deep-Learning-Industry.html">ReportLinker, 2020</a>).</li><li>Deep learning techniques account for 40% of the annual value created by analytics (<a href="https://www.mckinsey.com/featured-insights/artificial-intelligence/notes-from-the-ai-frontier-applications-and-value-of-deep-learning">McKinsey</a>).</li><li>Google’s Deep Learning program detects breast cancer with an accuracy of 89% (<a href="https://www.mercurynews.com/2017/03/03/google-computers-trained-to-detect-cancer/">Health Analytics</a>).</li></ul><p>After checking out these interesting stats about deep learning you must be curious about knowing — <strong>which are common applications of deep learning in artificial intelligence (ai)?</strong>.</p><p>So, let’s begin with <a href="https://www.interviewbit.com/deep-learning-interview-questions/">applications of deep learning</a>.</p><h3>Applications of deep learning:</h3><ol><li><strong>Digital Marketing:</strong></li></ol><p>Everything is going digital currently, including marketing. Marketing on the internet is more prevalent than traditional methods today because traditional methods are no longer in-demand. Marketing professionals can gauge the efficacy of their campaigns by leveraging deep learning in digital marketing.</p><p>By utilizing data and its output, it is revolutionizing the marketing industry, and based on deep learning algorithms, companies can very accurately predict customer demand, customer satisfaction, and create a specific target market for their brand. The modern marketing professional can truly use it as an invaluable asset to keep their business competitive.</p><p>SEO which is very essential for many websites for engagement is one region where AI is likely to outshine human marketers. This is because SEO is data-driven and search engines use algorithms to define the order in which websites appear on their results pages, which makes it a natural fit for the technology.</p><p>Although privacy is a major concern, once the deep learning algorithm recognizes a person, there is no boundary between a successful marketing campaign and a satisfied customer. The return on investment, as well as engagement rate, can get a boost if customer experience on various digital platforms is improved by analyzing the customer’s behavior.</p><p><strong>2) Deep Learning in Natural Language Processing (NLP):</strong></p><p>An algorithmic approach to interpreting and manipulating human speech, known as natural language processing, falls under the areas of linguistics, computer science, and AI.</p><p>As humans, we need years and years of human interaction and exposure to various social environments to learn and understand the variation in tones and patterns of a language so we cannot expect a machine to learn all these things by itself.</p><p>With the help of deep learning and constructing correct responses to every situation, NLP i.e Natural Language Processing trains machines to do that easily.</p><p>Various algorithms are used in NLP for analyzing the data which makes the system capable of producing human language or recognizing tonal variations in a human voice.</p><p>Deep learning is gaining popularity nowadays in a no. of areas of natural language processing which includes providing answers to various questions, model building, etc. It has been used quite often for upgrading the text analytic functions and features of natural language processing. These proposals have helped a lot in converting text which was not structured earlier into beneficial information.</p><p><strong>3) Chatbots:</strong></p><p>Chatbots are computer software programs that mimic human conversation via text or audio messages. Chatbots are very common when we use an online platform nowadays and today’s AI systems are able to understand users’ requirements, and preferences and recommend what actions to execute with very less or bare minimal intervention from humans. A number of popular conversational assistants are available in the market today including Siri which is developed by Apple, Cortana which is developed by Microsoft, and Alexa developed by Amazon and Google Assistant.</p><p>With the advent of Chatbots, all platforms can now provide their visitors with a customized experience. Machine learning algorithms and deep learning algorithms are used by chatbots to generate a combination of replies. Having been trained with a lot of data, chatbots can understand customer requests, and difficulties faced by them and also guide and assist the customer in resolving their problem in a very simple way.</p><p>In addition, it has many other benefits like it saves time for customers and with the advent of chatbots, companies are employing less no. of employees to reduce their costs and improve their customer experience.</p><p><strong>4) Deep Learning in Virtual Assistants:</strong></p><p>Virtual Assistants like Alexa which is developed by Amazon, Siri by Apple, and Google Assistant are popular applications for deep learning. These are used in many households and offices to make day-to-day tasks easier. The number of people using these assistants is increasing and these assistants are becoming smart and learn more and more about you and your preferences whenever you interact with them. Deep learning is used by virtual assistants to understand our interests, like our favourite hangout places or our favourite tv shows. In order to understand what we say, they consider human speech. A virtual assistant can also translate our voice into a textual format, schedule meetings for us, etc.</p><p>Virtual assistants can do everything from handling to instantly and automatically answering our work calls for helping us and our team manage tasks. A virtual assistant can also assist us in composing and mailing emails to your boss, clients, teachers, etc by summarizing the documents.</p><p>In addition, virtual assistants are used in many places and are also being integrated into various devices, including microwave systems and cars. These assistants will continue to become more intelligent day by day, thanks to the internet and smart devices.</p><p><strong>5) Fraud Detection and News Aggregation:</strong></p><p>Especially money transactions are going digital nowadays, which is why deep learning is a valuable tool. A number of applications are being developed with the help of deep learning that can help in detecting fraud which can help save financial organizations a tremendous amount of money. Also, the news feed can now be filtered to remove all the unwanted news and readers can get to read the news that is based on their field of interest.</p><p>Detection of fake news is very essential nowadays because the internet is filled with a lot of sources of blogs, research papers, news, and many other forms of information and all of them are not faithful. Fake news is circulating very fast in today’s time with the help of bots and therefore it becomes extremely difficult to tell whether the news is fake or real.</p><p>In addition to developing classifiers to detect fake and biased news, deep learning can also be used to notify you about potential privacy violations and take out the content. The major challenge with training and validating a deep learning neural network for news detection is that the data is littered with opinions from all around the world and it’s difficult to determine whether the news story is biased or neutral.</p><p><strong>6) Earthquake Prediction:</strong></p><p>Earth science is grappling with the problem of earthquake forecasts because of their devastating outcomes. An earthquake forecast that is successful could save numerous lives. Scientists are attempting to predict earthquakes based on when and where they will happen, as well as on the basis of their magnitude</p><p>Von mises yield criterion is used by deep learning for the prediction of earthquakes and this application of deep learning helped the scientists to improve the time of earthquake prediction by fifty thousand per cent. We went from just guessing when an earthquake is gonna happen to being able to have a decent prediction as to when the earthquakes are gonna hit.</p><p>A deep learning model which is taught on a large amount of data will be able to learn from the data by extracting elements from raw data to recognize natural things and make good decisions about a broad range of subject areas. Additionally, it has become easier for large models to be trained because of refinements in computing power. Deep learning makes earthquake forecast possible due to its advantages.</p><p><strong>7) Deep Learning in Visual Recognition:</strong></p><p>Image recognition involves recognizing photos and organizing them into separate categories based on their features. Thus, image recognition software and apps can determine what is shown in a photo and differentiate them. I am pretty sure you have seen this in your social media application or on your mobile phone. Essentially, it sorts images based on the location of people in a photograph, occasions, etc.</p><p>Consider browsing through a collection of old photos for remembering some good old times. Some photos need framing, but first, we like to arrange them in proper order. Since there was no information about the photos, it was only possible to do this manually. All we could do was arrange them on the basis of the date on which the photo was taken, but sometimes the date is missing from downloaded photos. Due to Deep Learning, images can now be arranged according to locations at which the photos were taken or on the basis of looks, individuals, occasions, etc.</p><p><strong>8) Customizations:</strong></p><p>Platforms including Amazon, Flipkart, etc., are using Deep Learning to make their e-commerce offerings more personalized by offering suggestions for different products, customized packages, and deals.</p><p>Deep learning technology is used by platforms like Amazon Prime, and Gaana to screen videos, tv shows, and your most loved songs based on your viewing preferences. It helps you to stream famous shows and songs from your playlists through online streaming media. Also, we get a customized experience in online streaming platforms just because of deep learning, and ads are also recommended to us based on our viewing preferences. In terms of acceptance, this is the most popular application. For instance, after you have watched a movie starring Tom Holland, your Amazon account may suggest other movies starring Tom Holland. Using deep learning, users can experience customized streaming based on past streaming choices and experiences. Remember deep learning the next time you listen to a song and similar songs get queued up behind it.</p><p>There are some people who are creeped out by the content suggested to them based on their liking, but the data collected is all derived from previous dealings with your application.</p><p><strong>9) Robotics:</strong></p><p>A few robotics applications have been boosted by deep learning’s favorable results in the field of computer vision and deep learning is heavily used in robotics to execute human-like tasks. Robots are built to understand the world around them and it is very important for them to figure out which thing is what. If you go back 20 years robots could not figure out many basic differences like the difference between a soda bottle and a pen because they both have the same shape.</p><p>It’s no secret that the field of robotics proposes a distinctive set of challenges for learning algorithms which are:<br> <br>It can be difficult and even impossible to code entirely fresh learning algorithms and elements for each job that robots execute.<br> <br>The second challenge is that robots have to handle a great deal of variousness in the real world which makes it tough for many learning algorithms to handle.</p><p>But deep learning algorithms are general models that are able to learn straight from data, so they are well-suited for robotics. Certainly, robotics and artificial intelligence boost human capability, improving productivity and enabling the transition from simple thinking to human-like capabilities</p><p><strong>10) Autonomous Vehicles:</strong></p><p>The intent of driving is to react safely to external factors such as cars around you, street signs, and pedestrians to get from one point to another. Despite the fact that we are still some distance away from fully autonomous vehicles, deep learning has been pivotal in getting the technology to where it is today.</p><p>Self-driving is getting a boost in today’s time and is more powerful than ever due to a lot of advancements such as increased-performance graphics cards, strong processors, and vast quantities of info. In addition to easing traffic congestion, it will boost safety. Automobiles that drive themselves are autonomous decision-making systems. Inertia detectors and GPS are a few types of sensors that can provide data streams. The deep learning algorithms then model the data and make decisions according to the car’s environment.</p><p>Automated vehicles are able to foresee obstacles in their background and deduce a safe path to get from a particular location to another, by bringing into account where they need to go using deep learning.</p><p>Pony.ai, for example, employs deep learning to power its planning as well as a control module for its independent vehicle technology that allows automobiles to navigate roads with eight lanes, control mishaps, etc. Waymo, a Google subsidiary, is another self-driving car company that employs deep learning.</p><h4>Conclusion</h4><p>To conclude, deep learning enables computers to be like human brains in both performance and behaviour. It has become prominent in a wide range of industries. There are numerous applications and benefits of deep learning that can be explored in further detail. Our lives are becoming easier and more efficient due to deep learning, which is present in everything from automatic cars to voice assistants.</p><p>We hope that after reading this article you understood the meaning of deep learning and its applications in various fields.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85e40754c6d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coderbyte/top-applications-of-deep-learning-85e40754c6d7">Top Applications of Deep Learning</a> was originally published in <a href="https://medium.com/coderbyte">Tech x Talent</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tower of Hanoi in Python]]></title>
            <link>https://medium.com/geekculture/tower-of-hanoi-in-python-3de58db9e2b5?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/3de58db9e2b5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python-web-developer]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 13:03:10 GMT</pubDate>
            <atom:updated>2022-03-17T13:03:10.238Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is the Tower of Hanoi?</strong></p><p>The Tower of Hanoi is the problem in which there are 3 towers, let’s mark it with the names Tower A, Tower B, and Tower C. And in Tower A, we have n number of disks. And the task is to move all disks from Tower A to Tower C using Tower B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*8V5n0SbnWUfe0J1IT3IeQg.png" /></figure><p><strong>Origin of the Problem-</strong></p><p>This problem was created by French mathematician Édouard Lucas in the 19th century. This problem was related to Hindu Mythology. And this is also called the Tower of Brahmas or Lucas Tower.</p><p>This problem is believed to be unsolvable. Because there is a story behind this. And that is related to the priests of the temple. It is being said that in Kashi Vishwanath Temple in India, there is a stack of 64 golden disks that are kept sequentially on top of another. And priests are trying to rearrange that disk on another tower from many years ago. They used to believe that once all 64 disks are successfully moved then the world is going to end. And the other version of the story is about the place (Hanoi) in Vietnam. The golden plate belongs there.</p><p>This mathematical puzzle is supposed to be unsolvable. But using the help of recursion it becomes very easy to solve.</p><p><strong>What is Recursion? </strong>In terms of programming, A recursion is a function that calls itself. There is a base case in the recursion that helps to terminate the recursion. If the base case is not present then it will never terminate.</p><p><strong>Rules for Solving the </strong><a href="https://www.interviewbit.com/online-python-compiler/"><strong>Tower of Hanoi Problem</strong></a><strong> —</strong></p><ul><li>In every step, only one disk is allowed to move.</li><li>No Disk should overlay its smaller disk. This means if the disk with size 2 then it can’t be put on disk with size 1, but it can be put on any other disk that is larger with that disk.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*Xjcr4W7Fz0iJVzBFh88VkQ.png" /></figure><p>So these 2 conditions must have to be applied for moving these disks from Tower A to Tower C. And with only 2 towers we cannot move the disk. So we have taken an auxiliary tower (Tower B) to achieve that.</p><p>So the extra condition that also needs to be satisfied is that we have to use Tower B to keep the disk on that for a temporary basis because we can’t put the disk outside the tower.</p><p><strong>Problem Statement:</strong></p><p>How can we solve this problem using the help of Recursion? For understanding the solution better. Let’s understand the steps we need to follow when we have only 1 disk. Because that will be like a base case for our solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*RG7uk_dtWuK8uU8hBbHloA.png" /></figure><p>So for only 1 disk to move, we simply moved that 1 disk, from source to destination. Then the algorithm is like — <strong>Move disk from source to destination using the auxiliary tower</strong>.<br>Although we are not using that auxiliary tower, consider that.</p><p>Then for 2 disks, the steps should be like -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*PLMDxkBi9jVj-upUmXW-WQ.png" /></figure><p>So, the algorithm for the moving 2 disks will be -</p><p><strong>TOH( A, B, C, 2)</strong></p><ul><li>TOH( A, B, C, 1)</li><li>Movie disk from A to C</li><li>TOH( B, A, C, 1)</li></ul><p>Then using this approach, Can we solve this with any number of disks? So let’s take an example to solve it with the help of 4 disks. <br>If we consider the tower of 4 disks then we can judge that to move these 4 disks from source tower to destination tower we need to follow some steps -</p><ul><li>We have to move 3 disks out of 4 from the source tower (Tower A) to the auxiliary tower (Tower B).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*SQWbvbG8pkqzRClxfuLMXA.png" /></figure><ul><li>Then Move the 4th disk from the source tower (Tower A) to the destination tower (Tower C).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*weWRz8pzYFFe-tKWczrbiA.png" /></figure><ul><li>And at last, move the 3 disks from the auxiliary tower (Tower B) to the destination tower (Tower C).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*KjyhNt6KZ6ExMOd6yrUAqA.png" /></figure><p><strong>Problem Solved</strong>, With just 3 simple steps to have concluded the solution of the problem. But the condition 1 that is stated for solving the problem is that we need to move only 1 disk at a time. But here we are moving 3 disks at a time (Move 3 Disks from A to B and Move 3 disks from B to C). How do we solve this problem?</p><p>So, why can’t we do one thing that at the very first step, instead of moving 3 disks, we can ask someone to move 1 disk from source to destination, then that person ask someone else for the same, and then we proceed accordingly? <br>Yes, that’s the recursive function that we have to make, and that will solve our problem.</p><p><strong>Now let’s take a deep dive into each of the steps to solve this puzzle -</strong></p><p>We have given a total of 4 disks and 3 towers ‘A’, ‘B’, and ‘C’. The task is to move this disk from tower ‘A’ (Source) to Tower ‘B’ (Destination) by following the rules of the Tower of Hanoi. So steps for solving the Tower of Hanoi problem with 4 disks are-</p><p><strong>Given -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*SOJng1r0qTpBuwt0z_xeAw.png" /></figure><p><strong>Steps -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*0D9LekZip61H9-svd3sRPw.png" /></figure><p><strong>Step 1: Move Disk from A to B using C:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*uLM-KLVC6GDpxpvr4xYrIQ.png" /></figure><p><strong>Step 2: Move Disk from A to C using B:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*BBUZ1Do0o9xIXM3teXC6Dg.png" /></figure><p><strong>Step 3: Move Disk from B to C using A:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*IGrmi-SiHadfij0h72ZiWQ.png" /></figure><p><strong>Step 4: Move Disk from A to B using C:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*TR13-tFb7Fb58HlYiWF74Q.png" /></figure><p><strong>Step 5: Move Disk from C to A using B:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*oLnUrzsQsNV8kBsKF4h0aw.png" /></figure><p><strong>Step 6: Move Disk from C to B using A:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*EbjaN3rzLhew90lYdc-LRw.png" /></figure><p><strong>Step 7: Move Disk from A to B using C:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*XSWzJaZqFZEjo2lX1BHkvA.png" /></figure><p><strong>Step 8: Move Disk from A to C using B:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*r_CWl7yvzbF-dpXesGvMaw.png" /></figure><p><strong>Step 9: Move Disk from B to C using A:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*0IQ9w_ETlp34TM5f2pd_NQ.png" /></figure><p><strong>Step 10: Move Disk from B to A using C:</strong><br>+</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*KMjqxryd7aq6Jz4Ijbzg0A.png" /></figure><p><strong>Step 11: Move Disk from C to A using B:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*BBUZ1Do0o9xIXM3teXC6Dg.png" /></figure><p><strong>Step 12: Move Disk from B to C using A:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*iGv_uKMsgqa6hLPkIH70Sw.png" /></figure><p><strong>Step 13: Move Disk from A to B using C:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*Q7_2FF97ISFvnpLFyOBqAQ.png" /></figure><p><strong>Step 14: Move Disk from A to C using B:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*ptYn3u5Gj2Q8N8iidr4ymA.png" /></figure><p><strong>Step 15: Move Disk from B to C using A.</strong></p><p><strong>So the algorithm for the solution of Tower of Hanoi with 4 steps will be -</strong></p><p><strong>TOH( source, auxiliary, destination, 4)</strong></p><ul><li><strong>TOH(</strong> source, destination, auxiliary, 3 )</li><li>Move the disk from source to destination using auxiliary.</li><li><strong>TOH</strong>( auxiliary, source, destination, 3 )</li></ul><p><strong>Python Code for solving the Tower of Hanoi for 4 disks will be-</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2F66fd73131d1c6bcf506a&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2F66fd73131d1c6bcf506a%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f589b7ab5f35f7fa6ed897ac4e16781/href">https://medium.com/media/4f589b7ab5f35f7fa6ed897ac4e16781/href</a></iframe><p><strong>Input — 4 Disk.</strong><br><strong>Output-</strong></p><p><strong>Move 1 disk from A to B using C.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to B using C.<br>Move 1 disk from C to A using B.<br>Move 1 disk from C to B using A.<br>Move 1 disk from A to B using C.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to C using A.<br>Move 1 disk from B to A using C.<br>Move 1 disk from C to A using B.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to B using C.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to C using A.</strong></p><p><strong>Now consider the problem’s solution with the 5 Disk-</strong></p><p>We have been given 5 disk’s stack arranged on tower ‘A’ source. Now we need to move this disk from source to destination tower ‘C’ following the tower of Hanoi rules. So the steps for solving the puzzle with 5 disks will be -</p><p><strong>Given -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*QNN5Ih_WvBJAdAwzqdCk0Q.png" /></figure><p><strong>Steps -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*bUsIIbIMuouITlztwKO6Xg.png" /></figure><p><strong>Step 1: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*-l-W66HSX3XuZWKq5v8h5g.png" /></figure><p><strong>Step 2: Move 1 disk from A to B using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*dUnzI2J9hTWI-t5BN9ooUQ.png" /></figure><p><strong>Step 3: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*IyYXA6BgfF7N-yW6Bp800g.png" /></figure><p><strong>Step 4: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*yrhQe_uNoIb2LE47qp2YHA.png" /></figure><p><strong>Step 5: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*dmdv9JP-3THNlfdiD3H2kQ.png" /></figure><p><strong>Step 6: Move 1 disk from B to C using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*MphaQIiCWIciFQHFh1rW8g.png" /></figure><p><strong>Step 7: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*IA4L_zSyeRLBTAKX-_Oz2w.png" /></figure><p><strong>Step 8: Move 1 disk from A to B using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*GLeVHd97M3Ima6emdxzZjw.png" /></figure><p><strong>Step 9: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*wb6uV3zZDApLUP_swYq-ag.png" /></figure><p><strong>Step 10: Move 1 disk from C to A using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*1sRUnkWOLAiKKUyqvAEnyA.png" /></figure><p><strong>Step 11: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*hXdacObeygBUAcJdmPMWTQ.png" /></figure><p><strong>Step 12: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*3-Ye4gpd2Wr4c0k9XECezA.png" /></figure><p><strong>Step 13: Move 1 disk from A to C using B.</strong></p><p><strong>Step 14: Move 1 disk from A to B using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*LV6EFK2rWAZNPzJiS1uS5g.png" /></figure><p><strong>Step 15: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*hgUC7-rfBssFYj6JDGNoOQ.png" /></figure><p><strong>Step 16: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*QxF4gPqa5eq1Mbd6L_7AdA.png" /></figure><p><strong>Step 17: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*8UofDvGDRwRBymnJftsYrw.png" /></figure><p><strong>Step 18: Move 1 disk from B to C using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*V0N-DkEXA5nymdC8mvwhVg.png" /></figure><p><strong>Step 19: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*mtvAf3v299zmgsTxuowzWA.png" /></figure><p><strong>Step 20: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*U-Hk7khAErkSPBSZ8DfDgg.png" /></figure><p><strong>Step 21: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*KD4bxBOY0tEfQlwXZDJmqw.png" /></figure><p><strong>Step 22: Move 1 disk from C to A using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*2RodEhm143SC9_UVbsXvFA.png" /></figure><p><strong>Step 23: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*N1P7gO8KOiaFkDHG7Hqqwg.png" /></figure><p><strong>Step 24: Move 1 disk from B to C using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*MphaQIiCWIciFQHFh1rW8g.png" /></figure><p><strong>Step 25: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*d7lVVDO0dvo18xKjn3QoEQ.png" /></figure><p><strong>Step 26: Move 1 disk from A to B using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*GLeVHd97M3Ima6emdxzZjw.png" /></figure><p><strong>Step 27: Move 1 disk from C to B using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*BZ0SbQmTboas3-JlW6Vn_g.png" /></figure><p><strong>Step 28: Move 1 disk from A to C using B.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*YK4iIi4lj4mK-R2vajfLoQ.png" /></figure><p><strong>Step 29: Move 1 disk from B to A using C.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*klSfCpPP89X1ZIr625odPw.png" /></figure><p><strong>Step 30: Move 1 disk from B to C using A.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*bR9DZp6Cpj3zsBOrRqojaw.png" /></figure><p><strong>Step 31: Move 1 disk from A to C using B.</strong></p><p><strong>So the algorithm for the solution of Tower of Hanoi with 5 disks will be -</strong></p><p><strong>TOH( source, auxiliary, destination, 5)</strong></p><ul><li>TOH( source, destination, auxiliary, 4 )</li><li>Move the disk from source to destination using auxiliary.</li><li>TOH( auxiliary, source, destination, 4 )</li></ul><p><strong>Python code for solving the Tower of Hanoi using 5 Disk —</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.interviewbit.com%2Fembed%2Fsnippet%2Fcfdf34df53ebeb1fcdc1&amp;display_name=Interviewbit&amp;url=https%3A%2F%2Fwww.interviewbit.com%2Fsnippet%2Fcfdf34df53ebeb1fcdc1%2F&amp;image=https%3A%2F%2Fibassets.s3.us-west-2.amazonaws.com%2Fstatic-assets%2Fpractice-page-og.webp&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=interviewbit" width="700" height="375" frameborder="0" scrolling="no"><a href="https://medium.com/media/1432d51eaee1463e1e3b7c7d9bd71cd2/href">https://medium.com/media/1432d51eaee1463e1e3b7c7d9bd71cd2/href</a></iframe><p><strong>Input — 5 Disk.<br>Output — Move 1 disk from A to C using B.<br>Move 1 disk from A to B using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from A to B using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from C to A using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from A to B using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from C to A using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from A to B using C.<br>Move 1 disk from C to B using A.<br>Move 1 disk from A to C using B.<br>Move 1 disk from B to A using C.<br>Move 1 disk from B to C using A.<br>Move 1 disk from A to C using B.</strong></p><p>After analyzing these 2 examples of solving the tower of Hanoi with 4 and 5 disks, the algorithm for n number of disks will be -</p><p><strong>TOH( source, auxiliary, destination, numOfDisk)</strong></p><ul><li>TOH( source, destination, auxiliary, numOfDisk )</li><li>Move the disk from source to destination using auxiliary.</li><li>TOH( auxiliary, source, destination, numOfDisk )</li></ul><p><strong>Explanation of Algorithm —</strong></p><p>Like we have analyzed above for the 4 disk solution,</p><ul><li>For any n number of disks, firstly the n-1 disk will be moved from source to auxiliary.</li><li>Then the nth disk will be moved from the source tower to the destination tower.</li><li>And then last, the n-1 disk will be moved from the auxiliary tower to the destination tower.</li></ul><p>And these n-1 moves are called recursively such that individual function call is responsible to handle the 1 disk move in each call.</p><p><strong>Python program for Solving Tower of Hanoi is -</strong></p><pre>def TOH(source, auxiliary, destination, numOfDisk):<br> #Base case of Recursion that when there is no disk to move <br> #then terminate the call.<br> if numOfDisk &gt; 0:<br> #Recursively calling for moving the n-1 disk from source<br> #to auxiliary using destination. <br> TOH(source, destination, auxiliary, numOfDisk-1)</pre><pre>#Moving the disk from source to destination<br> print(“Move 1 disk from {0} to {1} using {2}.”<br> .format(source, destination, auxiliary))<br> <br> #Recursively asking to move remaining disk from <br> #auxiliary to destination using source.<br> TOH(auxiliary, source, destination, numOfDisk-1)</pre><pre>if __name__ == “__main__”:<br> numOfDisk = int(input())<br> TOH(‘A’, ‘B’, ‘C’, numOfDisk)</pre><p><strong>Time Complexity Analysis —</strong></p><p>If we check the steps of solving this problem then we find that firstly it is recursively calling for (n-1) problem, then it is talking one constant step. And again recursively calling for (n-1) steps. So in the mathematical term we can state the time function as —<strong> T(n) = 2T(n-1) +1.</strong></p><p>So, if we solve this equation then the time complexity will be O(2n). <br>Although we can verify the time complexity by the number of steps it has taken for the different inputs.</p><p>For 1 Disk — 1 Move. <strong>(2^1–1)</strong><br>For 2 Disk — 3 Moves. <strong>(2^2–1)</strong><br>For 3 Disk — 7 Moves. <strong>(2^3–1)</strong><br>For 4 Disk — 15 Moves. <strong>(2^4–1)</strong><br>For 5 Disk — 31 Moves.<strong> (2^5–1)</strong></p><p>So the degree of the equation<strong> O(2n-1) is O(2n).</strong></p><p><strong>Space Complexity</strong> — Since the time is taken of <strong>O(2n)</strong>, we are using recursion for solving the problem. So the space complexity also will be <strong>O(2n)</strong>. Because recursion uses call stack.</p><p><strong>Conclusion —</strong></p><p>The Tower of Hanoi is a mathematical puzzle discovered by the French mathematician Édouard Lucas. And this puzzle is based on some mythology. <br>This problem seems to be impossible to solve in the real world considering the temple priest example. But in the programming using recursion. It can be easily solved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3de58db9e2b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/tower-of-hanoi-in-python-3de58db9e2b5">Tower of Hanoi in Python</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Convert a List to a Dictionary in Python]]></title>
            <link>https://levelup.gitconnected.com/how-to-convert-a-list-to-a-dictionary-in-python-f2c809e808e7?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2c809e808e7</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-projects]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 01:17:44 GMT</pubDate>
            <atom:updated>2022-03-14T01:17:44.513Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we dive into the conversion of a list to a dictionary let us first understand what exactly they represent and why do we use them.</p><p><strong>List and dictionary are a type of data structures. What are data structures you may ask?</strong></p><p>The answer itself lies in the name. A data structure simply means some sort of a structure that is used to handle, store and use data in an efficient and effective manner. They help in organizing data so that various operations such as insertion, deletion, updating can be done quickly. We can relate it to our room. Like if in our room there is a place for everything and all commodities are arranged in an organized manner then it becomes easy for us to find anything in the room. Similarly, the main idea of using data structures is to may our job easy and efficient.</p><h4>LIST</h4><p>The list is a linear data structure that is capable of storing values of different data types together in one place. Some key features of a list in python are:-</p><ul><li>They are <strong>dynamic</strong> in nature which essentially means that their size is not fixed. This property alone makes them very useful.</li><li>Values of a list can be accessed using indexes.</li><li>A single list can store data of different data types.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*N1aKK1xxuO8Tthx0pEDe0Q.png" /></figure><ul><li>Indexes can be both positive and negative.</li></ul><h4>Different Functionalities of a List: <a href="https://www.interviewbit.com/snippet/f98daeedf4a392aa05be/">Run Code</a></h4><p>Python provides a number of functions related to a list. Let us see them and understand them one by one through some actual code:-</p><pre># initialize and empty list<br>l  = []<br># insert one single element in the list<br>l.append(5)</pre><pre># insert multiple elements in the list<br>l.append(6.9)<br>l.append(7)<br>l.append(-6)</pre><pre>print(&quot;List after insertions: &quot;,l) # l = [5,6.9,7,-6] → current state of the list</pre><pre># access and print an element from the list using both positive and #negative indexes<br>print(&quot;Access element from positive and negative index:&quot;,l[3],l[-1]) # -6,-6</pre><pre># removing an element from the list<br>l.remove(7)<br># [5,6.9,-6]</pre><pre># iterating in a list<br>print(&quot;Print list using iteration&quot;)<br>for i in range(0,len(l)):<br>    print(l[i])</pre><pre>Output:-<br>List after insertions:  [5, 6.9, 7, -6]<br>Access element from positive and negative index: -6 -6<br>Print list using iteration<br>5<br>6.9<br>-6</pre><ul><li><strong>append()</strong>: this function is used to insert an element at the end of the list<br><em>Syntax:</em> listName.append(element)</li><li><strong>remove()</strong>: this function is used to remove an element from the list<br><em>Syntax:</em> listName.remove(element)</li><li><strong>len()</strong>: this function is used to find the length of the list<br><em>Syntax :</em> len(listName)</li></ul><p><strong>Time Complexities of operations in a List</strong></p><p>Given that there are <strong>N</strong> elements in a list let us observe the time complexities of various operations:-</p><ul><li><strong>Insertion</strong>: Since we have to traverse the entire list to insert/append an element at the end of the list time complexity for insertion will be <strong>O(N)</strong>.</li><li><strong>Deletion</strong>: In this case as well we will have to traverse the array to find the element that we want to delete so the time complexity for deletion will be <strong>O(N)</strong>.</li><li><strong>Access ith element</strong>: Since we can access any element in the list using it index time complexity for this operation is <strong>O(1)</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*JwYp3d3rrBGcy7HRVzLyZA.png" /></figure><h4>Dictionary</h4><p>It is another data structure that stores data in form of key-value pairs. Internally they use the concept of hashing for making these pairs.</p><p>They are used in places where any kind of <strong>mapping</strong> is required. It is a very powerful data structure that is used very frequently not only to optimize a solution but to store data in a meaningful way. The most common example is where a dictionary is used in <strong>JSON</strong>. Data in JSON is stored in key-value pairs which makes it easy to understand and use. Some of the key features of dictionaries are:-</p><ul><li>In order to store data in a dictionary a key and value must always be specified.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*JAUIQneUsaztjQlhSHqKeA.png" /></figure><ul><li>Keys of a dictionary must be unique and immutable.</li><li>Values of a dictionary can be of any data type.</li><li>There are various ways to access values but the most simple method is through keys just like values of lists can be accessed through indexes same can be done using keys in the case of dictionaries.</li></ul><pre>def dictionary_operations():<br>    # Create an dictionary <br>    d = {}</pre><pre># Add elements in a dictionary <br>    d[&#39;a&#39;] = 1<br>    d[&#39;b&#39;] = 2<br>    d[&#39;c&#39;] = 3</pre><pre># Print the dictionary<br>    print(&quot;Print the dictionary&quot;)<br>    print(d)</pre><pre>print(&quot;Iterate and print the key value pairs in the dictionary&quot;)</pre><pre># iterate and print the dictionary<br>    for i in d:<br>        print(i,d[i])<br>dictionary_operations()</pre><pre><a href="https://www.interviewbit.com/snippet/62694e13bf53e55fa363/">OUTPUT</a><br>Print the dictionary<br>{&#39;c&#39;: 3, &#39;a&#39;: 1, &#39;b&#39;: 2}<br>Iterate and print the key value pairs in the dictionary<br>c 3<br>a 1<br>b 2</pre><h4>Conversion of List to Dictionary:</h4><ol><li><strong>Two different lists of the same sizes: </strong>In this will we have two separate lists in which elements of one list will act as a key and another as value.</li></ol><pre>keyList = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;]<br>valueList = [1,2,3,4]<br>d = {}<br>for i in range(len(keyList)):<br>    d[keyList[i]] = valueList[i]<br>print(d)</pre><pre><a href="https://www.interviewbit.com/snippet/4f0ca5aedeea4b3141c4/">Output</a> : {&#39;d&#39;: 4, &#39;a&#39;: 1, &#39;c&#39;: 3, &#39;b&#39;: 2}</pre><p><strong>NOTE:</strong> In the above case since dictionaries are unordered the key-value pairs will be paired perfectly but their order is not maintained. To achieve this we can use the zip() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtvhI9RzFLvXKNPpkEQMsA.png" /></figure><p>The way zip() function works have been demonstrated above.</p><pre>keyList = [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;]<br>valueList = [1,2,3,4]<br>d = zip(keyList,valueList)<br># since zip returns an object we need to change it to dictionary<br>d = dict(d)<br>print(d)</pre><pre><a href="https://www.interviewbit.com/snippet/68bcc60bb452396d2614/">Output</a> : {&#39;a&#39;: 1, &#39;c&#39;: 3, &#39;b&#39;: 2, &#39;d&#39;: 4}</pre><p><strong>2. A single list</strong></p><p>In this case, we have to create a dictionary from a single list with keys and values as given below:</p><p>Input : [‘x’, 1, ‘y’, 2, ‘z’, 3]<br>Output : {‘x’: 1, ‘y’: 2, ‘z’: 3}</p><pre>a = [&#39;x&#39;, 1, &#39;y&#39;, 2, &#39;z&#39;, 3]</pre><pre># First we have to create an iterable of the array <br># To use the zip function later on</pre><pre>iterable = iter(a)<br>resultantDict = dict(zip(iterable,iterable))<br>print(resultantDict)</pre><pre><a href="https://www.interviewbit.com/snippet/a06208859e4a051e01f3/">output</a>:{&#39;x&#39;: 1, &#39;y&#39;: 2, &#39;z&#39;: 3}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2c809e808e7" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-convert-a-list-to-a-dictionary-in-python-f2c809e808e7">How to Convert a List to a Dictionary in Python</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem-Solving Through Programming In C]]></title>
            <link>https://soniajm.medium.com/problem-solving-through-programming-in-c-5ca745b1be44?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ca745b1be44</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[c-programming-language]]></category>
            <category><![CDATA[online-compiler]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Sun, 13 Feb 2022 14:35:45 GMT</pubDate>
            <atom:updated>2022-02-13T14:35:45.225Z</atom:updated>
            <content:encoded><![CDATA[<p>The development and industrialization of the modern world are accelerating. The technological advancements combined with the increased market competitiveness necessitate the modern generation to be better problem solvers.</p><figure><img alt="c compiler" src="https://cdn-images-1.medium.com/max/1024/1*d1c3gzIV2X_nnnQSykQrMg.jpeg" /><figcaption>Source: pexels</figcaption></figure><h3>Why is it important to learn problem-solving through programming?</h3><p>The simple answer- we all make decisions every day. Problem-solving abilities via programming are one of the most in-demand skills in present times. So the time, for you to improve them is now.</p><p>In this article, we will be tackling problem-solving through C programming. For embedded devices, C is the most extensively used language. C is a structured programming language with a large number of built-in functions and operators that can be used to create complicated programs. It’s crucial to be able to solve problems in C. Don’t get dismayed if you lack these abilities. We’ll get you up and running in no time….</p><h3>What is a program and what does programming means?</h3><p>A program is a set of instructions arranged in a sequence to guide a computer to find a solution for the given problem. The process of writing a program (converting algorithm or flowcharts) to a specific set of instructions is called programming. A computer language is used to write a set of instructions (Computer Program).</p><h3>What is the most important aspect of problem-solving?</h3><p>Programmers must first understand how a human solves a problem, then recognize to translate this “algorithm” (a set of instructions for guiding a computer to generate a solution) into something a computer can perform, and lastly “code” the program (a computer is dumb at its core; it’s you who makes it smart).</p><p>A ‘C’ program is composed of preprocessor commands, a global declaration section, and one or more functions (a function is a set of instructions used to perform a specific task).</p><blockquote>Quick Tip: The most important C header file is: #include&lt;stdio.h&gt;</blockquote><p>In general, a C program comprises of,</p><ul><li>Declaration of Variables</li><li>User-defined input/output (eg printf)</li><li>Decision making (if, else if, if-else)</li><li>Loops for multiple Iteration (for, while…, do…while)</li><li>Functions (can be called as many times as the user wishes) and Strings</li><li>Arrays (elements with a similar data type, stored at contiguous memory locations)</li><li>Pointers(stores memory address)</li></ul><p>One of the most significant steps in the coding process is to develop a logic for the given programming question. We recommend that you think about the question before tackling it head-on. Try developing its algorithm and strive to come up with multiple solutions (code), for a given problem. Working back and forth with the code and understanding its logic will take you far in this endeavour.</p><blockquote>Quick tip- Try drawing flowcharts and look for the output, this will save you a lot of time.</blockquote><p>Fortunately, C includes keywords, operators, switch, looping elements, and other useful features to get you going. Some simple steps to follow are,</p><h4>Define/Establish the problem:</h4><p>Before attempting to solve a specific problem, It is vital to first comprehend it. To acquire a handle on the problem, read it twice. In most cases, a clear and succinct problem statement is supplied. Input and output should be specified in the problem definition. A thorough understanding of the program is essential. The provided technical challenges can be solved analytically. Most difficulties can be resolved with a basic understanding of math. In the majority of cases, complete knowledge of the topic is offered together with the underlying mathematical notion. Writing a pseudo-code at this point is helpful</p><p><strong>Formulate simple algorithms for arithmetic and logical problems</strong></p><p>Developing an algorithm is the most important part of a successful code. A well-defined algorithm will help you structuralize the C code making it easier to find errors. Algorithms are frequently regarded as the foundation of a programming code. They are preferred in job interviews to access a candidate’s potential in coding skills. An algorithm is the core structure of your C program.</p><p>Let’s solve a simple C Programming problem together,</p><p><strong>Find the area and the circumference of a circle.</strong></p><p>Try developing an algorithm for this program,</p><ol><li>Step 1: Start</li><li>Step 2: Read r</li><li>Step 3: Calculate<br>A=3.14*r*r<br>C=2*3.14*r</li><li>Step 4: Print A, C</li><li>Step 5: Stop</li></ol><h3>Convert Algorithms into Programs (in C language)</h3><p>C, C++, MFC <br>Problem-Solving Through Programming In C<br>Sonali Desai Sonali Desai Updated date Feb 08, 2022<br> 22 0 0</p><p>facebook<br>twitter<br>linkedIn<br>Reddit<br>Expand<br>Download Free .NET &amp; JAVA Files API<br>Try Free File Format APIs for Word/Excel/PDF<br>The development and industrialization of the modern world are accelerating. The technological advancements combined with the increased market competitiveness necessitate the modern generation to be better problem solvers.</p><p>Why is it important to learn problem-solving through programming?<br>The simple answer- we all make decisions every day. Problem-solving abilities via programming are one of the most in-demand skills in present times. So the time, for you to improve them is now.</p><p>In this article, we will be tackling problem-solving through C programming. For embedded devices, C is the most extensively used language. C is a structured programming language with a large number of built-in functions and operators that can be used to create complicated programs. It’s crucial to be able to solve problems in C. Don’t get dismayed if you lack these abilities. We’ll get you up and running in no time….</p><p>What is a program and what does programming means?<br>A program is a set of instructions arranged in a sequence to guide a computer to find a solution for the given problem. The process of writing a program (converting algorithm or flowcharts) to a specific set of instructions is called programming. A computer language is used to write a set of instructions (Computer Program).</p><p>What is the most important aspect of problem-solving?<br>Programmers must first understand how a human solves a problem, then recognize to translate this “algorithm” (a set of instructions for guiding a computer to generate a solution) into something a computer can perform, and lastly “code” the program (a computer is dumb at its core; it’s you who makes it smart).</p><p>A ‘C’ program is composed of preprocessor commands, a global declaration section, and one or more functions (a function is a set of instructions used to perform a specific task).</p><p>Quick Tip: The most important C header file is: #include&lt;stdio.h&gt;</p><p>In general, a C program comprises of,</p><p>Declaration of Variables<br>User-defined input/output (eg printf)<br>Decision making (if, else if, if-else)<br>Loops for multiple Iteration (for, while…, do…while)<br>Functions (can be called as many times as the user wishes) and Strings<br>Arrays (elements with a similar data type, stored at contiguous memory locations) <br>Pointers(stores memory address)<br>One of the most significant steps in the coding process is to develop a logic for the given programming question. We recommend that you think about the question before tackling it head-on. Try developing its algorithm and strive to come up with multiple solutions (code), for a given problem. Working back and forth with the code and understanding its logic will take you far in this endeavor.</p><p>Quick tip- Try drawing flowcharts and look for the output, this will save you a lot of time.</p><p>Fortunately, C includes keywords, operators, switch, looping elements, and other useful features to get you going. Some simple steps to follow are,</p><p>Define/Establish the problem<br>Before attempting to solve a specific problem, It is vital to first comprehend it. To acquire a handle on the problem, read it twice. In most cases, a clear and succinct problem statement is supplied. Input and output should be specified in the problem definition. A thorough understanding of the program is essential. The provided technical challenges can be solved analytically. Most difficulties can be resolved with a basic understanding of math. In the majority of cases, complete knowledge of the topic is offered together with the underlying mathematical notion. Writing a pseudo-code at this point is helpful</p><p>Formulate simple algorithms for arithmetic and logical problems<br>Developing an algorithm is the most important part of a successful code. A well-defined algorithm will help you structuralize the C code making it easier to find errors. Algorithms are frequently regarded as the foundation of a programming code. They are preferred in job interviews to access a candidate’s potential in coding skills. An algorithm is the core structure of your C program.</p><p>Let’s solve a simple C Programming problem together,</p><p>Find the area and the circumference of a circle.<br>Try developing an algorithm for this program,</p><p>Step 1: Start<br>Step 2: Read r<br>Step 3: Calculate<br>A=3.14*r*r<br>C=2*3.14*r<br>Step 4: Print A, C<br>Step 5: Stop</p><h3>Convert Algorithms into Programs (in C language)</h3><p>Now, that you have your algorithm, you should start translating it into a program. Try to keep it simple as possible, and be careful with brackets and semicolons (you’re not working with Python), they will bring your program crashing down. Any text editor (such as Onlinegdb, Programiz, Jdoodle, Interviewbit and others) can be used to write C program source code. Here, we have used <a href="https://www.interviewbit.com/online-c-compiler/"><strong>InterviewBit’s online compiler</strong></a><strong> </strong>to write code, make sure to sign in to save your work for future use. Try inserting comments ( beginning with ‘/*’ and ending with ‘/*’). Although comments are not required, it is a good practice to provide them for readability and comprehension purposes. Remember to start your program with ‘ #include&lt;stdio.h&gt;’, failing to include the header file will result in, the inexecution of program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*Y_BnGhPfeReESq6-f6PzGA.jpeg" /></figure><h3>Implement conditional branching and iteration</h3><p>This is the fun part. It may be necessary to iterate a few times while simplifying and optimizing code, identifying ways to further simplify and optimize code. Using loops in C, you can run a series of instructions repeatedly ( for, while…, do…while loops used for multiple iterations). They are efficient and time-saving. Conditions can be generated using: (if-else, else if, if), or by using ternary operators. A switch can be used to create a variety of menu-driven programs. Try playing around with loops to develop a better understanding of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6JUZOQyJUFZXnepmgSZ_g.png" /></figure><p>Although blank spaces are allowed between an operand and an operator, no space is permitted between the components of an operator (like &gt; = is not allowed, it should be &gt;=). Therefore, writing x==y is correct but writing x= =y is not acceptable in C language. Take out a piece of paper and work through the problem manually for simplicity. Consider at least three data sets that you can use. Also, consider the possibilities on the outside. It’s easy to overlook the steps when you’re initially starting out. Writing pseudo-codes in such cases can be of great help. Refer back to the problem to make sure you are correct.</p><h3>Using Functions and Recursion</h3><p>Using the divide and conquer method, decompose a problem into functions and synthesize a complete program. In C, there are four different ways to declare and call a function.</p><ul><li>Function with an argument with return value.</li><li>Function with an argument without return value.</li><li>Function without argument without return value.</li><li>Function without argument with return value.</li></ul><blockquote>Ask yourself, What is the purpose of this function? What am I returning at the end of this function?</blockquote><p>Recursion (a function that calls itself) improves the speed of a program’s execution while also making it compact and easier to understand. They are good for programs that have a complex iterative approach ( eg, find the largest number among n numbers using a function ). Nested loops can be simply avoided while using them.</p><blockquote>Quick tip- Break apart larger C projects into several modules.</blockquote><h3>Using arrays, pointers, and structures, to create algorithms and program</h3><p>Have you ever wanted to know how to program a matrix? Well, 2-D arrays are here to help you out. Using arrays and pointers, you can save substantial time. They can be used to store a variety of data type such as int, float, long int, double, char, etc of any particular type. Accessing the address of a variable can be done by using pointers. Allocation and de-allocation become simple.</p><p>(To get a better hold on topic, apply to solve matrix addition and multiplication, searching and sorting problems using C language )</p><p>Keep in mind, C does not permit arrays of bit fields, pointers to bit fields, and function returning bit fields. C permits ordinary member variables along with fields as structure members. In all implementations, the default integer type for a bit field is unsigned.</p><h3>Test and effectuate the programs</h3><p>Compiling and running a C program is usually straightforward; the tricky part comes next. Your code may have some errors, choose one error at a time, correct its syntax and look for logical fallacies. Some common errors are: Initialization errors, stack over-flow, compile-time error, Boolean expression flaws, type conversion ( while type conversion is done implicitly, typecasting has to be done explicitly by the programmer. Typecasting is done when the value of higher data type has to be converted to lower data type.), and several more. When the code is free of errors, it will get executed.</p><p>Quick tip- Remember, C is a case sensitive language. Typing scanf function as Scanf will generate an error.</p><p>Debugging your program is essential for its execution. Remember syntax will come naturally over time. The <a href="https://www.interviewbit.com/snippet/478e785ce9b0a66a15f4/">execution of the above program</a> is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_Qr79FDTkEbjaH2bNDR3w.jpeg" /></figure><p>How in school, most of us used to dread solving math questions. Often our approach to questions was abstract and our methods were incorrect. Programming in some ways is similar to math; it requires practice and an open approach to problem-solving. Solving a bunch of questions, developing your own algorithm, creating different codes for the same problem, and understanding the basics of C Programming Language will make you a pro in no time.</p><p>Keep pushing yourself. You improve as a developer with each problem you solve. Celebrate each success, however small and be sure to remember how far you’ve come.</p><p>By engaging with this subject, you will learn to think, solve problems and make informed decisions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ca745b1be44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Numpy in Python]]></title>
            <link>https://pub.towardsai.net/introduction-to-numpy-in-python-1d7e0be2d7c8?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d7e0be2d7c8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[numpy-tutorial]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Fri, 29 Oct 2021 12:02:22 GMT</pubDate>
            <atom:updated>2021-10-29T12:02:22.631Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsai.net/p/category/programming">Programming</a></h4><h4>What is NumPy?</h4><p>NumPy stands for numeric python, a Python module that allows you to compute and manipulate multi-dimensional and single-dimensional array items. It comes with a high-performance multidimensional array object as well as utilities for working with them.</p><p>In 2005, Travis Oliphant created the NumPy package by combining the features of the ancestral module Numeric with the characteristics of another module Numarray. NumPy implements multidimensional arrays and matrices as well as other complex data structures. These data structures help to compute arrays and matrices in the most efficient way possible. NumPy allows you to conduct mathematical and logical operations on arrays. Many other prominent Python packages, like pandas and matplotlib, are compatible with Numpy and use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0VTcgJSYuTPbAr0Fdj9DA.png" /></figure><h4>Need to use NumPy in Python?</h4><p><a href="https://www.interviewbit.com/python-interview-questions/#python-numpy">NumPy</a> is a valuable and efficient tool for dealing with large amounts of data. NumPy is quick; thus, it’s easy to work with a vast amount of data. Data analysis libraries like NumPy, SciPy, Pandas, and others have exploded in popularity due to the data science revolution. Python is the most simple language in terms of syntax, and is the priority for many data scientists; therefore, NumPy is getting popular day by day. <br>Many <strong>mathematical procedures</strong> commonly used in scientific computing are made quick and simple with Numpy, including:</p><ul><li>Multiplication of Vector or Matrix to Vector or Matrix.</li><li>Operations on vectors and matrices at the element level (i.e., adding, subtracting, multiplying, and dividing by a number )</li><li>Applying functions to a vector/matrix element by element ( like power, log, and exponential).</li><li>NumPy has functions for linear algebra and random number generation built-in.</li><li>NumPy also makes matrix multiplication and data reshaping simple.</li><li>Multidimensional arrays are implemented efficiently using NumPy.</li><li>NumPy arrays in Python give capabilities for integrating C, C++, and other languages. It’s also useful in linear algebra and random number generation, among other things. NumPy arrays can also be used to store generic data in a multi-dimensional container.</li><li>It’s faster than standard Python arrays, which don’t have NumPy’s pre-compiled C code(Precompiled code is a header file that is compiled into an intermediate form that is faster to process for the compiler).</li></ul><h4>Installation of NumPy</h4><p>Go to your command prompt and run “pip install numpy” to install Python NumPy. Once the installation is complete, simply go to your IDE (for example, VS Code, Jupyter Notebook, PyCharm) and type “import numpy as np” to import it; now you are ready to use NumPy.</p><h4>What is a NumPy Array?</h4><p>The Numpy array object is a strong N-dimensional array object with rows and columns. NumPy arrays can be created from nested Python lists, and their elements can be accessed. It refers to a group of items that are all of the same types and can be accessed using zero-based indexing. Every item in a ndarray is the same size as the memory block. Each entry in ndarray is a data-type object (called dtype).</p><h4>Types of Numpy Array:</h4><ul><li><strong>One-Dimensional NumPy array</strong><br>A one-dimensional array has only one dimension of elements. In other words, the one-dimensional NumPy array should only contain one tuple value.<br><strong>Example:</strong></li></ul><pre># One-Dimensional Array<br>import numpy as np<br>val=np.array([1, 5, 2, 6])<br>print(val)</pre><p><strong>Implementation:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*skw9PhdfsisiQSMsMhgGLQ.png" /></figure><p><strong>Explanation:</strong> print() function is used to print the whole array provided.</p><ul><li><strong>Multi-Dimensional NumPy Array</strong><br>A multi-dimensional array can have n dimensions of elements. In other words, the multi-dimensional NumPy array can contain a number of tuple values.<br><strong>Example:</strong></li></ul><pre># Multi-Dimensional Array<br>import numpy as np<br>val=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val)</pre><p><strong>Implementation</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*WIKRRLshhPrav3ysUDK-Tg.png" /></figure><p><strong>Explanation:</strong> print() function is used to print the whole array provided.</p><h4><strong>Accessing Element in the Array</strong></h4><p>Indexing or accessing the array index in a NumPy array can be done in a variety of ways. <br>1. Slicing is used to print a range of an array. The built-in slice function is used to create a Python slice object by passing start, stop, and step parameters to it. Slicing an array involves establishing a range in a new array used to print a subset of the original array’s elements. Because a sliced array holds a subset of the original array’s elements, editing content alters the original array’s content.<br><strong>Example 1:</strong></p><pre># Accessing Array Element<br>import numpy as np<br>val=np.array([1, 5, 2, 6])<br># Zero based indexing<br>print(val[1])<br>val_mul=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val_mul[1][1])</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*MCNCh_fV5SlxVnataz7qEw.png" /></figure><p><strong>Explanation:</strong> Here we are accessing the 1st index value of the 1-D array via writing val[1] and accessing the value in the 2nd row and 2nd column of the 2-D array as the arrays have zero-based indexing.</p><p><strong>Example 2:</strong></p><pre>#Accessing Range of Elements <br>#in array using slicing<br>val_mul=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>slice_val = val_mul[:2, :2]<br>print (“First 2 rows and columns of the array\n”, slice_val)<br>Implementation:</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quftUHHErkKavw6nluOTlg.png" /></figure><p><strong>Explanation:</strong> Here we are trying to access the values in rows and columns starting from 1st row to 2nd row by writing “ :2 ” as the first argument and similarly accessing all the values corresponding to those rows and having columns from starting to the 2nd.</p><p><strong>Example 3:</strong></p><pre>val_mul1=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6),(1, 5, 0, 1),(7, 3, 3, 0)])<br>slice_step_row = val_mul1[::2, :2]<br>print (“All rows and 2 columns of the array with step size of 2 along the row\n”, slice_step_row)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nZecaDInN9ZL7vdS0sB2w.png" /></figure><p><strong>Explanation:</strong> Here we are trying to access the values in rows and columns starting from 1st row to end row with a step size of 2 which means the difference between consecutive rows to be 2 by writing “::2 ” as the first argument and similarly accessing all the values corresponding to those rows and having columns from starting to the 2nd.</p><p><strong>Example 4:</strong></p><pre># Accessing multiple elements at one go<br>val_mul1=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6),(1, 5, 0, 1),(7, 3, 3, 0)])<br>mul_idx_arr = val_mul1[<br> [1, 2, 2, 3], <br> [1, 2, 3, 3]<br> ]<br>print (“\nAccessing Elements at multiple indices (1, 1),(2, 2), (2, 3), (3, 3) →”, mul_idx_arr)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S6lrZQCEajJSpucDDeEtrw.png" /></figure><p><strong>Explanation:</strong> Here we are trying to access the values from the array which are present at the indexes (1,1),(2,2),(2,3), and (3,3).</p><p>2. Another type of accessing technique is the boolean array indexing where we can give the condition where elements that follow the condition are printed.</p><p><strong>Example:</strong></p><pre># Boolean array indexing<br>val_mul=np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6),(1, 5, 0, 1),(7, 3, 3, 0)])<br>condition = val_mul &gt; 3 <br>res = val_mul[condition]<br>print (res)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SA27k-JjbfcwyYBP6NqWDg.png" /></figure><p><strong>Explanation:</strong> Here we are accessing the values which follow the given conditions i.e. the value of the element should be greater than 3.</p><h3><strong>Frequently used Operations on Numpy Array</strong></h3><ul><li><strong>ndim</strong>- This operation is used to compute the dimension of the array.</li></ul><p><strong>Example:</strong></p><pre># Dimension of the array<br>val1 = np.array([1, 5, 2, 6])<br>print(val1.ndim)</pre><pre># 2-D array<br>val2 = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val2.ndim)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*-clizFxsYN_8CuIGZ6uufg.png" /></figure><p><strong>Explanation:</strong> Here val1 is a 1-D array having values 1,5,2 and 6 therefore we are getting value 1 for val1.ndim and val2 is a 2-D array <br>3 4 2 5<br>3 6 2 4<br>1 5 2 6<br>Therefore we are getting value 2 corresponding to val2.ndim</p><ul><li><strong>Size </strong>— This operation is used to calculate the number of elements in the array.</li></ul><p><strong>Example:</strong></p><pre># Calculate Array Size <br>val2 = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val2.size)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYMg_ZE5qv5Kzfr0BGxMIw.png" /></figure><p><strong>Explanation:</strong> Here val2 contains 12 values 3, 4, 2, 5, 3, 6, 2, 4, 1, 5, 2, 6 therefore we are getting the size of the val2 array as 12.</p><ul><li><strong>Shape</strong> — This operation is used to calculate the shape of the array.</li></ul><p><strong>Example:</strong></p><pre># Calculate Array Shape <br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.shape)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*g_DZRvi1AK4ceME6ZCG6oA.png" /></figure><p><strong>Explanation: </strong>Here Val array is a 2-D array <br>3 4 2 5<br>3 6 2 4<br>1 5 2 6<br>It has 3 rows and 4 columns and val.shape is used to get the size corresponding to each dimension.</p><ul><li><strong>Reshape </strong>— Reshape is used to reshape the array according to the given parameters</li></ul><p><strong>Example:</strong></p><pre># Reshape the Array<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val)</pre><pre>val=val.reshape(2,6)<br>print(val)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYIKIMAsdhvAlKKHpsY3VA.png" /></figure><p><strong>Explanation:</strong> reshape function helps us to reshape the array and fill the values of the array correspondingly. Here we have 12 values and we want to reshape the array from (3,4) to (2,6) so now there would be only 2 rows and 6 columns.</p><ul><li><strong>Transpose </strong>— T operator is used in getting the transpose of an array.<br><strong>Example:</strong></li></ul><pre># Transpose of an array<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.T)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*lgTmd4eGHfNN6f1BihqG3A.png" /></figure><p><strong>Explanation:</strong> When we need to replace all the rows of an array with the columns and columns with rows then we need to call the val.T to get the transpose of the array. In transpose, the shape of the array changes as now number of rows becomes a number of columns and vice versa. As here 3, 4, 2, 5 was the first row initially but after transpose, it becomes the 1st column.</p><ul><li><strong>Ravel </strong>— ravel is used to convert the array into a single column<br><strong>Example:</strong></li></ul><pre># Convert Array to Single Column<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.ravel())</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*i8MHauYuCzctdS0yF69-DA.png" /></figure><p><strong>Explanation:</strong> When we want to convert the array to a 1-D array we use the ravel function as it combines all the values of the array as in the above example we had initially a 2-D array of 3 rows and 4 columns but after applying the ravel function we gets the 1-D array of 12 values.</p><ul><li><strong>Itemsize:</strong> Itemsize is used to compute the size of each element in bytes.<br><strong>Example:</strong></li></ul><pre># Calculate Array Itemsize<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br># size of each element in bytes<br>print(val.itemsize)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ZIlbAm7A1akW3DfobVxWMw.png" /></figure><p><strong>Explanation:</strong> When we want to get the size of each element in bytes we use (array_name.itemsize) as in the above example the data type is int32 which means integer of 32 bits and as we know that 1 byte is equal to 8 bits and hence it is 4 bytes in size.</p><ul><li><strong>Dtype</strong>- Dtype is used to get the data type of the elements in the array.<br><strong>Example:</strong></li></ul><pre># Calculate Data type of each element<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.dtype)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*9i6pVg3KEhChCWF7wi3kJw.png" /></figure><p><strong>Explanation:</strong> When we want to compute the data type of the elements present in the array we use val.dtype which gives us the data type here in the above example the values of the array are integer so the data type given is int32 which means it represents an integer of 32 bits.</p><ul><li><strong>np.zeros()/np.ones() </strong>— ones() and zeros() functions of numpy are used to generate arrays having all 1’s and 0’s respectively.<br><strong>Example:</strong></li></ul><pre># Generating array having all 1&#39;s<br>val = np.ones(3)<br>print(val)<br> <br># Generating array having all 0&#39;s<br>val0 = np.zeros(3)<br>print(val0)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*yY122OQlwHhTZq1B1lbcNA.png" /></figure><p><strong>Explanation:</strong> When we want to generate an array having all 1’s or 0’s we use the above-given functions which helped us generate an array of size n. Here we gave the size of the array as 3 so an array of size 3 having all 1’s and 0’s is generated. <br> <br>- <strong>linspace</strong> — The linspace function is used to generate an array containing elements distributed equally in a given range. It takes 3 parameters to start and end of the range and the number of elements to be present in the array.</p><p><strong>Example:</strong></p><pre># Linspce generate 8 numbers present in range 2–5<br>val = np.linspace(2,5,8)<br>print(val)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELJISb0Cj_R5EBz_HQd95Q.png" /></figure><p><strong>Explanation:</strong> When we want to generate an array having specific order like in range x to y and size of the array to be n then we use linspace function as here we wanted to generate an array of size 8 having values equally spaced between range 2 to 5.</p><ul><li><strong>Max</strong> — Max is used in getting the maximum element across the whole array.</li></ul><p><strong>Example:</strong></p><pre># Find maximum element in whole array<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.max())</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Tjxhrk50JlhGHspt_L24w.png" /></figure><p><strong>Explanation:</strong> When we want to calculate the maximum of all elements of the array we can simply write array_name.max() and get the maximum element as here we get 6 which is the maximum of all the elements.</p><ul><li><strong>Min</strong> — Min function is used in getting the minimum element across the whole array.</li></ul><p><strong>Example:</strong></p><pre># Find minimum element in whole array<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.min())</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*JXPBIE1_-zwWIAtUhxC3QQ.png" /></figure><p><strong>Explanation:</strong> When we want to calculate the minimum of all elements of the array we can simply write array_name.min() and get the minimum element as here we get 1 which is the minimum of all the elements.</p><ul><li><strong>Sum</strong> — Sum function is used to get the total of all the elements of the array.</li></ul><p><strong>Example:</strong></p><pre># Sum of all elements in whole array<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val.sum())</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*Gfwag-BlkQBnlRRqtVqNag.png" /></figure><p><strong>Explanation:</strong> When we want to calculate the sum of all elements of the array we can simply write array_name.sum().</p><ul><li><strong>np.sqrt()</strong> — This function is used to get the square root of all the elements of the array.<br> <br><strong>Example:</strong></li></ul><pre># Used to calculate square root of each element<br>val=np.array([1, 4, 9])<br>print(np.sqrt(val))</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*IzWYDalS-dIPykooy4KF_w.png" /></figure><p><strong>Explanation:</strong> When we want to calculate the square root of each value of an array we can simply write np.sqrt(array_name) and we get the corresponding square roots to each and every value e.g. 2 corresponding to 4 and 3 corresponding to 9.</p><ul><li><strong>np.std()</strong>: This function is used to calculate the standard deviation of all the elements of the array.</li></ul><p><strong>Example:</strong></p><pre># Used to calculate standard deviation of all elements<br>val=np.array([1, 4, 9])<br>print(np.std(val))</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*WGSW3zZ678oi8969ZCf0xw.png" /></figure><p><strong>Explanation:</strong> When we want to find the standard deviation of all the values of the array we do not need to do the hectic math calculation for calculating the standard deviation, we can simply write (np.std(array_name)).</p><ul><li><strong>Summation operation on the array</strong> — When we need to add some particular number n to all the elements of the array or one array to another array.</li></ul><p><strong>Example1:</strong></p><pre># Add number 3 to all elements of array val<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val+3)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*mkcJ1QHE9vENDECaDRki5g.png" /></figure><p><strong>Explanation:</strong> When we want to add value n from each value of array we can simply write (array_name+n).</p><p><strong>Example 2:</strong></p><pre># Add array val to another array val1<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>val1 = np.array([(4, 4, 8, 2),(9, 0, 3, 5),(6, 8, 3, 3)])<br>print(val+val1)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*KIG_3h2HXM7oqukaCyQ9VQ.png" /></figure><p><strong>Explanation:</strong> When we want to find the addition of 2 arrays we can simply write (array1+array2) to get the addition of arrays but just keep in mind that the dimensions of both the arrays must be the same.</p><ul><li><strong>Subtraction operation on the array </strong>— When we need to subtract some particular number n to all the elements of the array or one array from another array.</li></ul><p><strong>Example1:</strong></p><pre># Subtract number 3 from all elements of array val<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val-3)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*3FwC3J1YMjLKHN6fanHiAA.png" /></figure><p><strong>Explanation:</strong> When we want to subtract value n from each value of array we can simply write (array_name-n).</p><p><strong>Example 2:</strong></p><pre># Subtract array val from another array val1<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>val1 = np.array([(4, 4, 8, 2),(9, 0, 3, 5),(6, 8, 3, 3)])<br>print(val1-val)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*-btWxxOxinTWEqDrciuDvA.png" /></figure><p><strong>Explanation:</strong> When we want to find the difference between 2 arrays we can simply write (array1-array2) to get the difference of arrays but just keep in mind that the dimensions of both the arrays must be the same.</p><ul><li><strong>Power of each element of the array raised to numbe</strong>r n:</li></ul><p><strong>Example:</strong></p><pre># Power of each element of the array raise to 3<br># Cube of each element<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val**(3))</pre><pre># Power of each element of the array raise to 0.5<br># Square root of each element<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val**(0.5))</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*LO99plS2oOBxBNoLGzY8SQ.png" /></figure><p><strong>Explanation</strong>: Here we are raising to the power of 3 each and every value of the array and printing it.When we want to raise to the power of n each value of array we simply write (array_name)**n to raise to the power of each and every value of the array by value n.</p><ul><li><strong>Modify each element:</strong></li></ul><p><strong>Example:</strong></p><pre># Multiply each element of the array by 3<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val*(3))</pre><pre># Divide each element of the array by 3<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(val/3)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*F4IsuGpcmVJALB2v2YSLcA.png" /></figure><p><strong>Explanation:</strong> Here we are multiplying each and every value of the array by 3 and printing it. Similarly, when we want to divide each value of array we simply write (array_name)/n to divide the array by value n.</p><ul><li><strong>np.sort()</strong> — This function is used to sort the array and takes the argument axis which allows sorting the array row-wise and column-wise when initialized with values 1 and 0 respectively.</li></ul><p><strong>Example1:</strong></p><pre># Sort the array row-wise<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>print(np.sort(val,axis=1))</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*Qn1-mpARUtg2pkSzc-8oLg.png" /></figure><p><strong>Explanation:</strong> Here we are sorting the values of the array row-wise as we have provided the value of the axis as 1.</p><p><strong>Example2:</strong></p><pre># Sort the array column-wise<br>val = np.array([(3, 4, 2, 5),(3, 6, 2, 4),(1, 5, 2, 6)])<br>np.sort(val,axis=0)</pre><p><strong>Implementation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*flITsjEUcAOKYqmGQqTmvw.png" /></figure><p><strong>Explanation:</strong> Here we are sorting the values of the array column-wise as we have provided the value of the axis as 0.</p><h4>What to do next?</h4><p>The NumPy library in Python is one of the most widely used libraries for numerical computation. We looked at the NumPy library in-depth with the help of various examples in this article. We also demonstrated how to utilize the NumPy library to do several linear algebra operations. I recommend that you practice the examples provided in this post. If you want to work as a data scientist, the NumPy library is one of the tools you’ll need to master to be a successful and productive member of the profession. <a href="https://numpy.org/">Learn More</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d7e0be2d7c8" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/introduction-to-numpy-in-python-1d7e0be2d7c8">Introduction to Numpy in Python</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dataframe in Python]]></title>
            <link>https://medium.com/geekculture/dataframe-in-python-3dcc3af43f51?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dcc3af43f51</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Tue, 05 Oct 2021 11:03:19 GMT</pubDate>
            <atom:updated>2021-10-05T11:03:19.141Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>The <a href="https://docs.python.org/3/">Python</a> programming language developed by Guido Van Rossum in the 1990s is ranked as the third most popular programming language in the Stack Overflow Developer Survey 2021. Numpy and Pandas packages of Python are the preferred choices of 33.84% and 28.12% of developers globally and are primarily used in Data Science and Machine Learning. There is so much you can do with Python and its frameworks. This blog introduces DataFrame in Python along with various examples and programs. DataFrames are the primary Data Structure of the Pandas package. It provides fast, flexible, and expressive data structures designed to make working with relational or labeled data easier; the two primary data structures of pandas, Series(1-dimensional) or simply an array of objects and DataFrame(2-dimensional), are frequently used in the fields of Finance and Statistics.</p><h3>What is a DataFrame in Python?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*saoS9PVtitr8AL_CTUGD_g.png" /><figcaption>Source: Pandas Documentation</figcaption></figure><p>A <a href="https://www.interviewbit.com/python-interview-questions/#define-pandas-dataframe">DataFrame</a> is defined as two-dimensional, size-mutable, potentially heterogeneous tabular data. (<strong><em>Mutable means columns can be inserted and deleted from DataFrame, Potentially heterogeneous data means columns may contain data of different data types</em></strong>). DataFrame is the Pandas Data Structure. They are a container for Series, and insertion and deletion of objects from these containers are done in a dictionary-like fashion.</p><blockquote>The constructor for creating of a DataFrame is:<br>DataFrame([data, index, columns, dtype, copy])</blockquote><p>The parameters of the constructor are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKewRg5khb_3ZcGQtzMT8Q.jpeg" /></figure><p>The three main components of Pandas DataFrame are the data, the index, and the columns. The Data can be a Pandas Series, a Pandas DataFramem, a Numpy ndarray, a two-dimensional ndarray, dictionaries of one-dimensional ndarray, lists, dictionaries or Series. Basic operations on a DataFrame like Creation, Insertion, Deletion, Renaming, and Sorting of DataFrame are discussed in this blog. In real-world projects, a DataFrame will be created by loading data from a database, CSV file, or an excel file. As a starting point lets see how DataFrame can be created using different ways apart from directly importing tabular data:</p><h3>Creation of DataFrame</h3><p>In real-world projects, a DataFrame will be created by loading data from a database, CSV file, or an excel file. As a starting point lets see how DataFrame can be created using different ways apart from directly importing tabular data:</p><ul><li><strong><em>Creating a DataFrame using List</em></strong><br>A DataFrame can be created using a single list or a list of lists.</li></ul><h4>Example 1</h4><p>This example uses a single list for the creation of a DataFrame.</p><pre>import pandas as pd<br> <br># This will create an empty DataFrame<br>df1 = pd.DataFrame()<br>print(df1)<br> <br> <br>listOne = [&#39;DataFrame&#39;, &#39;in&#39;,&#39;Python&#39;]<br> <br># Calling DataFrame constructor on list<br>df2 = pd.DataFrame(listOne)<br>print(df2)</pre><p>The above code when executed will generate a Pandas DataFrame as shown below</p><pre>Empty DataFrame<br>Columns: []<br>Index: []<br>          0<br>0 DataFrame<br>1        in<br>2     Python</pre><h4>Explanation</h4><p>In the above example, a Python list is created. The list is then converted to a DataFrame, using the DataFrame() constructor of pandas Package. The DataFrame is then printed. Note that as we didn’t specify the column name and indices for the row, Python does it by default and gives zero-based indexing to the various rows of the DataFrame.<br>You can also specify index and column names by doing a minor change in the code above.</p><h4>Example 2</h4><pre><em>import</em> pandas <em>as</em> pd</pre><pre>listOne = [&#39;DataFrame&#39;, &#39;in&#39;,&#39;Python&#39;]</pre><pre>#<em> Calling DataFrame constructor on list</em></pre><pre>df = pd.DataFrame(listOne, index=[&#39;i1&#39;,&#39;i2&#39;,&#39;i3&#39;], columns=[&#39;Names&#39;])</pre><pre>print(df)</pre><p>The above code when executed will generate a Pandas DataFrame as shown below:</p><pre>import pandas as pd<br>       Names<br>i1 DataFrame<br>i2        in<br>i3    Python</pre><h4>Explanation:</h4><p>In the above example, a Python List, listOne, is created. The list is then converted to a Pandas DataFrame using the DataFrame() constructor. In the above example the index=[‘i1’,’i2&#39;,’i3&#39;] is used to specify the row indices and the columns=[‘Names’] is used to specify the column name. The DataFrame is then printed. Note that the DataFrame has now the column indices and the row indices as we specified while calling the DataFrame constructor.</p><h4>Example 3</h4><p>This example uses a multi-dimensional list with column names and index specified.</p><pre>import pandas as pd<br> <br>listTwo = [[‘Alexa’, 10], [‘Siri’, ‘20’],[‘Echo’, 30]]<br> <br># Calling DataFrame constructor on list<br>df2 = pd.DataFrame(listTwo, index=[‘a’,’b’,’c’], columns=[‘Name’, ‘Score’])<br>print(df2)</pre><p>Its output is as follows:</p><pre> Name Score<br>a Alexa 10<br>b Siri 20<br>c Echo 30</pre><h4>Explanation:</h4><p>In the above example, a list of lists is used. Each list is then treated as an individual row of the DataFrame. The column names, columns=[‘Name’, ‘Score’], and the indices, index=[‘a’,’b’,’c’], are also used in the above example.</p><h4>Example 4</h4><p>This example uses a multi-dimensional list with column name, index and dtype specified.</p><pre>import pandas as pd<br> <br>listTwo = [[‘Alexa’, 10], [‘Siri’, ‘20’],[‘Echo’, 30]]<br> <br># Calling DataFrame constructor on list<br>df2 = pd.DataFrame(listTwo, index=[‘a’,’b’,’c’], columns=[‘Name’, ‘Score’],dtype=float)<br>print(df2)</pre><p>Its output is as follows:</p><pre>   Name Score<br>a Alexa 10.0<br>b Siri  20.0<br>c Echo  30.0</pre><p>Notice that the dtype parameter changes the type of Score column to floating-point.</p><h4>Explanation:</h4><p>In the above example, a list of lists is used, the row indices and column names are also specified when calling the constructor. In addition a new parameter, dtype=float,is also used. This specified that the Data type of the score is float.</p><ul><li><strong><em>Creating a DataFrame from dictionary of lists</em></strong></li></ul><p>Dictionaries are used to store data in Key, Value pairs. In the examples below, key will be the column names and the values will be the data inside those columns.</p><h4>Example 1</h4><pre>import pandas as pd<br> <br>data = {‘Name’:[‘ABC’,’DEF’,’GHI’], ‘Age’:[12, 13, 14]}<br> <br>df = pd.DataFrame(data)<br>print(df)</pre><p>The output of the above code is</p><pre>  Name Age<br>0 ABC  12<br>1 DEF  13<br>2 GHI  14</pre><h4>Explanation</h4><p>In the above example, a dictionary of lists is created. Note that the values corresponding to the keys are in list format. The dictionary of lists is then converted to a DataFrame using the, DataFrame() constructor. The DataFrame is then printed.</p><h4>Example 2:</h4><p>The above example was quite straight-forward. Let’s consider another example wherein we will be given 3 lists, we will convert those lists to a dictionary and then the dictionary to a DataFrame.</p><pre># Three Lists<br>name = [&#39;ABC&#39;,&#39;DEF&#39;,&#39;GHI&#39;,&#39;JKL&#39;]<br>age = [20, 22, 26, 28]<br>qualifications = [&#39;BA&#39;, &#39;B.Tech&#39;,&#39;B.Tech + MBA&#39;, &#39;CA&#39;]<br> <br># Defining a dictionary containing the name, age <br># and qualifications <br>data_persons = {<br>    &#39;Name&#39;: name,<br>    &#39;Age&#39; : age,<br>    &#39;Qualifications&#39; : qualifications<br>}<br> <br># Converting the dictionary into a DataFrame<br>df = pd.DataFrame(data_persons)<br>print(df)</pre><p>The output of the above code is:</p><pre>Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA</pre><h4>Explanation:</h4><p>In the above example, firstly three lists are created, name, age, and qualifications respectively. A dictionary is then created with the Keys, ‘Name’, ‘Age’ and ‘Qualifications’. The values corresponding to these keys are the lists, name, age, and qualifications respectively. A dictionary of lists is thus created. This is then converted to a DataFrame using the DataFrame() constructor and printed. Note that each key of the dictionary is a column in a DataFrame. The row indexing is zero-based.</p><ul><li><strong><em>Creating a DataFrame from List of Dictionaries</em></strong></li></ul><p>A list of dictionaries can be passed as input data to create a DataFrame. By default, the dictionary keys will be taken as the column names.</p><h4>Example 1</h4><pre>import pandas as pd<br> <br># {&#39;a&#39;: 1, &#39;b&#39;: 2} is first dictionary<br># {&#39;a&#39;: 3, &#39;b&#39; : 4, &#39;c&#39; : 7} is second dictionary<br>data = [{&#39;a&#39;: 1, &#39;b&#39;: 2}, {&#39;a&#39;: 3, &#39;b&#39; : 4, &#39;c&#39; : 7}]<br> <br># Converting the list of dictionaries to a DataFrame<br>df = pd.DataFrame(data)<br> <br>print(df)</pre><p>Its output is as follows:</p><pre>   a  b    c<br>0  1  2  NaN<br>1  3  4  7.0</pre><h4>Explanation:</h4><p>In the above example, a list of dictionaries is created. The key-value pair is separated using the: in each dictionary. The list of dictionaries is then converted to a DataFrame using the DataFrame() constructor. <br>Note that on conversion to a DataFrame, each key becomes the column name and the values corresponding to it are the rows of the DataFrame. Also, it is worth noticing that in the first dictionary, {‘a’: 1, ‘b’: 2}, unlike the second dictionary, {‘a’: 3, ‘b’ : 4, ‘c’ : 7}, there are only two key-value pairs. So in the resultant DataFrame, the value corresponding to the third column is treated as NaN. NaN stands for Not A Number and is one of the common ways to represent the missing value in the data</p><p>It’s always recommended to specify the row indices. The row indices and column indices are very handy in other manipulation operations.</p><h4>Example 2</h4><p>The below example shows how to create a DataFrame with a list of dictionaries, row indices, and column indices.</p><pre>import pandas as pd<br> <br># {‘a’: 1, ‘b’: 2} is first dictionary<br># {‘a’: 3, ‘b’ : 4, ‘c’ : 7} is second dictionary<br>data = [{‘a’: 1, ‘b’: 2}, {‘a’: 3, ‘b’ : 4, ‘c’ : 7}]<br> <br># Converting the list of dictionaries to a DataFrame<br>df = pd.DataFrame(data,index=[‘first’,’second’] , columns=[‘a’,’b’,’c’])<br> <br>print(df)</pre><p>Its output is as:</p><pre>        a  b    c</pre><pre>first   1  2  NaN</pre><pre>second  3  4  7.0</pre><h4>Explanation:</h4><p>In the above example, a list of dictionaries is created. The list of dictionaries is then converted to a DataFrame using the DataFrame() constructor. We have also specified the row indices using the, index=[‘first’,’second’], and the column names using the columns=[‘a’,’b’,’c’]. Note that on conversion to a DataFrame, each key becomes the column name and the values corresponding to it are the rows of the DataFrame. The DataFrame is then printed, note that now the column names and the row-indices are the one that we specified and not the default zero-based ones.</p><h3>Fundamental DataFrame Operations</h3><ul><li><strong>Dimensions of DataFrame</strong><br>The shape() method is used to get the height and width of DataFrame.</li><li><strong>Head of DataFrame</strong><br>The head() method is used to get the first five rows of the DataFrame and the tail() method is used to get the last five rows.</li><li><strong>Locate Row</strong><br>The loc attribute is used to return one or more specified rows.</li><li><strong>Get the Column Names</strong><br>You can get the list of column names by using columns in a DataFrame object.</li><li><strong>Get the Data types of all the columns</strong><br>To fetch the Data Type of each column in DataFrame use dtypes.</li></ul><p>There are many other fundamental DataFrame operations as well. The below program illustrates the fundamental operations discussed above.</p><pre>import pandas as pd<br> <br># Three Lists<br>name = [&#39;ABC&#39;,&#39;DEF&#39;,&#39;GHI&#39;,&#39;JKL&#39;,&#39;MNO&#39;,&#39;PQR&#39;]<br>age = [20, 22, 26, 28, 29, 30]<br>qualifications = [&#39;BA&#39;, &#39;B.Tech&#39;,&#39;B.Tech + MBA&#39;, &#39;CA&#39;, &#39;Intermediate&#39;, &#39;MBBS&#39;]<br> <br># Defining a dictionary containing the name, age <br># and qualifications <br>data_persons = {<br>    &#39;Name&#39;: name,<br>    &#39;Age&#39; : age,<br>    &#39;Qualifications&#39; : qualifications<br>}<br> <br># Converting the dictionary into a DataFrame<br>df = pd.DataFrame(data_persons)<br>print(df)<br> <br># Shape<br>print(&quot;\n\nPrinting the shape of dataframe&quot;)<br>print(df.shape)<br> <br># Head<br>print(&quot;\n\nPrinting the head of dataframe&quot;)<br>print(df.head())<br> <br># Tail<br>print(&quot;\n\nPrinting the tail of dataframe&quot;)<br>print(df.tail())<br> <br># Location of row<br>print(&quot;\n\nPrinting the third row of dataframe&quot;)<br>print(df.loc[2])<br> <br># Column Names<br>print(&quot;\n\nPrinting the column names of dataframe&quot;)<br>print(df.columns)<br> <br># Data types<br>print(&quot;\n\nPrinting the Data Types of dataframe&quot;)<br>print(df.dtypes)</pre><p>The output of the above program is:</p><pre>Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA<br>4  MNO   29   Intermediate<br>5  PQR   30           MBBS</pre><pre>Printing the shape of dataframe<br>(6, 3)</pre><pre>Printing the head of dataframe<br>  Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA<br>4  MNO   29   Intermediate</pre><pre>Printing the tail of dataframe<br>  Name  Age Qualifications<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA<br>4  MNO   29   Intermediate<br>5  PQR   30           MBBS</pre><pre>Printing the third row of dataframe<br>Name                       GHI<br>Age                         26<br>Qualifications    B.Tech + MBA<br>Name: 2, dtype: object</pre><pre>Printing the column names of dataframe<br>Index([&#39;Name&#39;, &#39;Age&#39;, &#39;Qualifications&#39;], dtype=&#39;object&#39;)</pre><pre>Printing the Data Types of dataframe<br>Name              object<br>Age                int64<br>Qualifications    object<br>dtype: object</pre><h4>Explanation</h4><p>In the above example, the process of creation of a DataFrame is the same as the one discussed above in the example 2 of creating a DataFrame from a dictionary of lists. The sequence of output is explained below:</p><ul><li>Firstly the DataFrame is printed, then its shape i.e. the number of rows and columns in a tuple.</li><li>The head() of the DataFrame is the first five rows of the DataFrame.</li><li>The tail() of the DataFrame is the last five rows of the DataFrame.</li><li>The df.loc[2] is used for printing the third row of the DataFrame. Note that we specify 2 in the loc[] because by default zero-based indexing is used unless explicitly specified.</li><li>The df.columns are used to print the column labels of the DataFrame.</li><li>The df.dtypes is used to print the Data types of all the columns in the DataFrame.</li></ul><h3>Operations on Columns in a DataFrame</h3><p>In an existing DataFrame, we can rename column names, add columns, and delete columns very easily. All the three basic operations on columns are explained below:</p><h4>Addition of Columns</h4><p>To add a new column to a DataFrame, create a Series and assign it as a new column to the original DataFrame. The following example demonstrates this:</p><pre>import pandas as pd<br> <br>listTwo = [[‘Alice’, 10], [‘Bob’, ‘20’],[‘Charlie’, 30]]<br> <br># Calling DataFrame constructor on list<br>df = pd.DataFrame(listTwo, index=[‘a’,’b’,’c’], columns=[‘Name’, ‘Age’],dtype=float)<br> <br>print(“Printing the original DataFrame”)<br>print(df)<br> <br># Creating a pandas Series<br>states = pd.Series([‘New York’,’Seattle’,’Washington’])<br># Assigning the pandas Series as a new column<br>df[‘state’] = states<br>print(“\n\n Printing the modified DataFrame”)<br>print(df)</pre><p>The output of the above program is:</p><pre>Printing the original DataFrame<br>      Name   Age<br>a    Alice  10.0<br>b      Bob  20.0<br>c  Charlie  30.0</pre><pre>Printing the modified DataFrame<br>      Name   Age state<br>a    Alice  10.0   NaN<br>b      Bob  20.0   NaN<br>c  Charlie  30.0   NaN</pre><h4>Explanation:</h4><p>In the above example, firstly a DataFrame is created using a list of lists, the row indices and column names are specified along with the Data types in the DataFrame() constructor. The DataFrame() is then printed.</p><p>A pandas Series, named as series is created. This pandas series is assigned as a new column to the DataFrame. Then the modified DataFrame is printed.</p><h4>Renaming of Columns</h4><p>We can change the name of a single column as well as multiple columns using the .rename() method of Pandas. The following example illustrates the renaming of single and multiple columns</p><pre>import pandas as pd<br> <br>df = pd.DataFrame({<br>        &#39;Name&#39; : [&#39;Alice&#39;,&#39;Bob&#39;,&#39;Charlie&#39;],<br>        &#39;Age&#39; : [12, 13, 14]<br>     })<br> <br>print(&quot;Printing the original DataFrame&quot;)<br>print(df)<br> <br># Renaming of single column &#39;Name&#39;<br>df.rename(columns={&#39;Name&#39;:&#39;FirstName&#39;}, inplace=True)<br>print(&quot;\n\nPrinting the DataFrame after changing a single column\n&quot;)<br>print(df)<br> <br># Renaming of multiple columns<br>df.rename(columns={&#39;FirstName&#39;:&#39;fName&#39;, &#39;Age&#39;:&#39;Years&#39;}, inplace=True)<br>print(&quot;\n\nPrinting the DataFrame after changing multiple column names\n&quot;)<br>print(df)</pre><p>The output is as follows:</p><pre>Printing the original DataFrame<br>      Name  Age<br>0    Alice   12<br>1      Bob   13<br>2  Charlie   14</pre><pre>Printing the DataFrame after changing a single column</pre><pre>   FirstName Age<br>0     Alice   12<br>1       Bob   13<br>2   Charlie   14</pre><pre>Printing the DataFrame after changing multiple column names</pre><pre>     fName  Years<br>0    Alice     12<br>1      Bob     13<br>2  Charlie     14</pre><h4>Explanation:</h4><p>In the above example, firstly a DataFrame is created using the Dictionary of Lists. The original DataFrame is then printed.</p><p>The df.rename() method is used for renaming column names, by passing the original and modified column names as key:value pairs of a dictionary, columns={‘Name’:’FirstName’}. The inplace=True, is used to specify that the data is modified in place, which means it will return nothing and the original DataFrame is now modified. The modified DataFrame is then printed.</p><p>Again the df.rename() method is used.This time two column names will be renamed. Both the original and modified column names are passed as key:value pairs in the dictionary, columns={‘FirstName’:’fName’, ‘Age’:’Years’}. The modified DataFrame is then printed.</p><p>The above method is quite handy when renaming a single column or few columns. However, in the case of large datasets containing 100s of columns, specifying the old and new names becomes tedious. In such cases, renaming can be done by assigning a list of new column names.</p><pre>import pandas as pd<br> <br>df = pd.DataFrame({<br> ‘Name’ : [‘Alice’,’Bob’,’Charlie’],<br> ‘Age’ : [12, 13, 14]<br> })<br> <br>print(“Printing the DataFrame column names”)<br>print(df.columns)<br> <br># Modifying the column names by passing a list of new column names.<br>df.columns = [‘FName’, ‘Years’]<br>print(“Printing the DataFrame column names after modification”)<br>print(df.columns)</pre><p>The output is as:</p><pre>Printing the DataFrame column names<br>Index([‘Name’, ‘Age’], dtype=’object’)<br>Printing the DataFrame column names after modification<br>Index([‘FName’, ‘Years’], dtype=’object’)</pre><h4>Explanation:</h4><p>In the above example, a DataFrame is created using a dictionary of lists. The print(df.columns) is used to print the column names of the DataFrame.</p><p>The column names are modified by passing a list of new column names, df.columns = [‘FName’, ‘Years’]. The modified column names are then printed.</p><h4>Deletion of Columns</h4><p>A column can be deleted using the del and pop() function. The following example illustrates the deletion of columns.</p><pre>import pandas as pd<br> <br># Three Lists<br>name = [&#39;ABC&#39;,&#39;DEF&#39;,&#39;GHI&#39;,&#39;JKL&#39;]<br>age = [20, 22, 26, 28]<br>qualifications = [&#39;BA&#39;, &#39;B.Tech&#39;,&#39;B.Tech + MBA&#39;, &#39;CA&#39;]<br> <br># Defining a dictionary containing the name, age <br># and qualifications <br>data_persons = {<br>    &#39;Name&#39;: name,<br>    &#39;Age&#39; : age,<br>    &#39;Qualifications&#39; : qualifications<br>}<br> <br># Converting the dictionary into a DataFrame<br>df = pd.DataFrame(data_persons)<br>print(df)<br> <br># Using the del function<br>print(&quot;\n\nDeleting the first column&quot;)<br>del df[&#39;Name&#39;]<br>print(df)<br> <br># Using the pop function<br>print(&quot;\n\nDeleting the second column&quot;)<br>df.pop(&#39;Age&#39;)<br>print(df)</pre><p>Its output is as follows:</p><pre>   Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA</pre><pre>Deleting the first column<br>   Age Qualifications<br>0   20             BA<br>1   22         B.Tech<br>2   26   B.Tech + MBA<br>3   28             CA</pre><pre>Deleting the second column<br>  Qualifications<br>0             BA<br>1         B.Tech<br>2   B.Tech + MBA<br>3             CA</pre><h4>Explanation:</h4><p>In the above example, first, the DataFrame is created using a Dictionary of lists. The original DataFrame is printed.<br>A single column is then deleted using the del df[‘Name’], by passing the column name. Again the DataFrame is printed.<br>Another column is then deleted using df.pop[‘Age’] by passing the column name. Again the DataFrame is printed.</p><p>Apart from the syntax difference, between the del and pop methods, another difference is pop returns the deleted value from the list and del does not return anything.</p><h3>Operation on rows in a DataFrame</h3><p>In an existing DataFrame, we can add and delete a row very easily. All the three basic operations are discussed below:</p><h4>Insertion of Rows</h4><p>We can add a new row to the dataframe using the append function. This function is used to insert the rows at the end. This is illustrated in the below example:</p><pre>import pandas as pd<br> <br>df1 = pd.DataFrame([[1, 2], [3, 4]], columns = [&#39;col1&#39;,&#39;col2&#39;])<br>print(&quot;Original DataFrame&quot;)<br>print(df1)<br> <br> <br>df2 = pd.DataFrame([[5, 6],[7, 8]], columns=[&#39;col1&#39;,&#39;col2&#39;])<br>df1 = df1.append(df2)<br>print(&quot;\n\nDataFrame df1 after concatenation with df2&quot;)<br>print(df1)</pre><p>The output is as follows:</p><pre>Original DataFrame<br>   col1  col2<br>0     1     2<br>1     3     4</pre><pre>DataFrame df1 after concatenation with df2<br>   col1  col2<br>0     1     2<br>1     3     4<br>0     5     6<br>1     7     8</pre><h4>Explanation</h4><p>In the above example, a DataFrame, df1, is created using a list of lists, the column names are also specified. The original DataFrame is then printed.</p><p>A new DataFrame, df2, is created in a similar manner. The Append considers the calling dataframe as the main object and adds rows to that dataframe from the data frames that are passed to the function as argument df1.append() is used to insert df2 inside df1. The modified DataFrame is then printed.</p><p>In addition to the append() method, concat() method can also be used for insertion/addition of rows in a DataFrame. This is shown in the example below:</p><pre>import pandas as pd<br> <br>df1 = pd.DataFrame([[1, 2], [3, 4]], columns = [&#39;col1&#39;,&#39;col2&#39;])<br>print(&quot;Original DataFrame&quot;)<br>print(df1)<br> <br> <br>df2 = pd.DataFrame([[5, 6],[7, 8]], columns=[&#39;col1&#39;,&#39;col2&#39;])<br>df1 = pd.concat([df2, df1]).reset_index(drop = True)<br>print(df1)</pre><p>The output is as follows:</p><pre>Original DataFrame<br>   col1  col2<br>0     1     2<br>1     3     4<br>   col1  col2<br>0     5     6<br>1     7     8<br>2     1     2<br>3     3     4</pre><h4>Explanation</h4><p>In the above example, first, a DataFrame, df1, is created using a list of lists. The column names are also specified. The original DataFrame is then printed. Another DataFrame, df2, is created in a similar manner. <br>The concat() method is used to Concatenate pandas objects along a particular axis. The two dataframes, df1 and df2 are concatenated using the concat() method. The modified DataFrame is then printed.</p><h4>Deletion of Rows</h4><p>Rows can be deleted from a DataFrame using index labels, the rows corresponding to those labels are dropped using the .drop() method. This is illustrated in the below example</p><pre>import pandas as pd<br> <br># Three Lists<br>name = [&#39;ABC&#39;,&#39;DEF&#39;,&#39;GHI&#39;,&#39;JKL&#39;,&#39;MNO&#39;,&#39;PQR&#39;]<br>age = [20, 22, 26, 28, 29, 30]<br>qualifications = [&#39;BA&#39;, &#39;B.Tech&#39;,&#39;B.Tech + MBA&#39;, &#39;CA&#39;, &#39;Intermediate&#39;, &#39;MBBS&#39;]<br> <br># Defining a dictionary containing the name, age <br># and qualifications <br>data_persons = {<br>    &#39;Name&#39;: name,<br>    &#39;Age&#39; : age,<br>    &#39;Qualifications&#39; : qualifications<br>}<br> <br># Converting the dictionary into a DataFrame<br>df = pd.DataFrame(data_persons)<br>print(df)<br> <br># Drop row with label 2<br>df = df.drop(2)<br>print(&quot;\n\n Printing DataFrame after deletion of a row&quot;)<br>print(df)</pre><p>The output is as follows:</p><pre>Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>2  GHI   26   B.Tech + MBA<br>3  JKL   28             CA<br>4  MNO   29   Intermediate<br>5  PQR   30           MBBS</pre><pre>Printing DataFrame after deletion of a row<br>  Name  Age Qualifications<br>0  ABC   20             BA<br>1  DEF   22         B.Tech<br>3  JKL   28             CA<br>4  MNO   29   Intermediate<br>5  PQR   30           MBBS</pre><h4>Explanation</h4><p>In the above example, first, the DataFrame is created using the dictionary of lists, the DataFrame is then printed.<br>The df.drop() method is used to delete a row based on the row number, which in this example is the default zero-based indexing. The modified DataFrame is then printed.</p><h3>Conclusion</h3><p>This article discusses the dataframe in python, its implementation, and various operations on it with examples. It is highly recommended to study these operations and practically implement them on your own. <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html">Learn More</a>.</p><p>Explore other operations as well. The more you explore, the more knowledge you gain!!</p><p>If you are confused about what type of questions related to Pandas are asked in an interview, you must refer to Structure Wise Interview Questions List. They are curated by experts and cover almost all the important concepts which are asked in an interview.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dcc3af43f51" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/dataframe-in-python-3dcc3af43f51">Dataframe in Python</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 10 Data Scientist Skills You Should Know]]></title>
            <link>https://medium.easyread.co/top-10-data-scientist-skills-you-should-know-f22a90c3e4f2?source=rss-6522d17e4247------2</link>
            <guid isPermaLink="false">https://medium.com/p/f22a90c3e4f2</guid>
            <category><![CDATA[data-science-courses]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technical-interview]]></category>
            <category><![CDATA[skills-development]]></category>
            <dc:creator><![CDATA[sonia jessica]]></dc:creator>
            <pubDate>Wed, 29 Sep 2021 02:03:10 GMT</pubDate>
            <atom:updated>2021-09-29T02:03:10.223Z</atom:updated>
            <content:encoded><![CDATA[<h4>Required skills you need to know to become a data scientist</h4><h4>Who is data science for?</h4><p>Data science is an interdisciplinary approach to obtaining useful insights from today’s organizations’ massive and ever-increasing volumes of data. Preparing data for analysis and processing, undertaking advanced data analysis, presenting the results to expose trends, and allowing stakeholders to make educated decisions are all part of data science. Data science is a discipline that combines domain knowledge, programming abilities, and math and statistics knowledge to extract useful insights from data.</p><h4>Data science is one of today’s most fascinating subjects. But, why is it so crucial?</h4><p>Because businesses are sitting on a gold mine of data. Data volumes have expanded as contemporary technology has facilitated the creation and storage of ever-increasing amounts of data. 90 percent of the world’s data was created in the last two years, according to estimates. Every hour, for example, Facebook users post 10 million images.</p><p>The vast amounts of data collected and saved by these technologies have the potential to revolutionize businesses and communities all around the world — but only if we can understand it. This is where data science enters the picture.</p><p>Data science identifies patterns and generates insights that businesses may utilize to make more informed decisions and develop more innovative products and services. Perhaps most crucially, it allows machine learning (ML) models to learn from the massive volumes of data that they are fed, rather than depending solely on business analysts to figure out what they can from the data.</p><p><a href="https://www.oracle.com/in/data-science/what-is-data-science/">Data science</a> remains one of the most promising and in-demand career pathways for qualified individuals. As a result, it is the most lucrative employment of the twenty-first century.</p><h4>What does a data scientist do?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBUlMUeGDOuyXVYWd4pvdw.png" /><figcaption>Data Scientist Skills</figcaption></figure><p>Data scientists have become indispensable assets in almost every corporation during the last decade. These professionals are well-rounded, data-driven individuals with advanced technical capabilities who can construct complicated quantitative algorithms to organize and synthesize vast amounts of data in order to answer questions and drive strategy in their company. This is combined with the communication and leadership skills required to provide tangible results to numerous stakeholders throughout a company or organization.</p><p>Data scientists collaborate closely with business stakeholders to learn about their objectives and how data may help them achieve them. They construct algorithms and prediction models to extract the data that the business needs, as well as help, evaluate the data, and share findings with peers. While each project is unique, data scientists carry out the following steps:<br>To get a better understanding of the problem, they ask the appropriate questions.<br>Gathering business requirements and related data from various sources.<br>Process, clean, integrate and store the data.<br>Exploratory data analysis (EDA) to figure out how to deal with missing data and to seek trends and/or possibilities.<br>Following the exploratory phases, the cleansed data is exposed to a variety of algorithms, such as predictive analysis, regression, text mining, pattern recognition, and so on, depending on the requirements.<br>Use excellent data visualizations and reports to communicate predictions and findings to management and IT teams.<br>Changes to existing procedures and techniques that are cost-effective are recommended.</p><h3>Required skills to become a data scientist</h3><p>Today’s effective data professionals recognize that they must go beyond the traditional abilities of large-scale data analysis, data mining, and programming. Effective data scientists are able to develop relevant questions, acquire data from a variety of sources, organize the data, translate results into solutions, and present their findings in a way that favorably influences business decisions. Because these talents are required in practically every industry, skilled data scientists are becoming increasingly valuable to businesses.</p><p>So, in this article, I am mentioning the top 10 <a href="https://www.interviewbit.com/data-science-interview-questions/#what-is-data-science">data scientist skills</a> that you must know.</p><h4>1. Fundamentals of data science</h4><p>Understanding the principles of data science, machine learning, and artificial intelligence as a whole is the first and most crucial talent you’ll need. Understand issues such as the difference between deep learning and machine learning, terminologies, and terms that are most commonly used, the difference between supervised and unsupervised learning, and others. To work as a Data Scientist, you’ll need knowledge of popular data science technologies like Microsoft Excel, Python or R, Hadoop, Spark, Tableau, and others.</p><h4>2. Machine learning</h4><p>Machine learning is a must-have ability for any data scientist. Predictive models are created using machine learning. If you want to forecast how many clients you’ll have in the upcoming month based on the previous month’s data, for example, you’ll need to employ machine learning techniques.</p><p>A vast number of data scientists lack expertise in machine learning techniques and topics. Neural networks, reinforcement learning, adversarial learning, time series, natural language processing, outlier detection, computer vision, recommendation engines, and other techniques are examples of this. If you want to set yourself apart from other data scientists, you need to be familiar with machine learning techniques including supervised machine learning, decision trees, and logistic regression, among others. These abilities will aid you in solving a variety of data science challenges based on important organizational outcomes projections.</p><h4>3. Probability and statistics</h4><p>Data Science is the process of extracting knowledge, insights, and making educated decisions from data using various methods, algorithms, or systems. Making conclusions, estimating, and predicting are all crucial aspects of Data Science in this scenario.</p><p>Before you can create high-quality models, you need to understand statistics. Machine Learning begins with statistics and progresses. Even the concept of linear regression is a statistical analysis concept that has been around for a long time.</p><p>It is necessary to understand the concepts of descriptive statistics such as mean, median, mode, probability distributions, sample and population, CLT, skewness and kurtosis, and inferential statistics, such as hypothesis testing and confidence intervals.</p><h4>4. Programming knowledge</h4><p>It is one of the requisite skills for Data Scientist positions. Writing computer programs and analyzing vast datasets to find solutions to complicated issues is what programming is all about. Data scientists must be able to write code in a range of languages, including Java, R, Python, and SQL.</p><p>Python, R, and Julia each have their own set of advantages and disadvantages. R is a statistical analysis and visualization language, whereas Python is a general-purpose programming language with various data science packages and rapid prototyping. Julia combines the finest of both worlds while also being speedier.</p><p>All of the core skills needed to transform raw data into useful insights are gathered in Programming Skills for Data Science.</p><h4>5. Data visualization</h4><p>One of the most significant aspects of data analysis is data visualization. It has always been critical to convey information in a way that is both understandable and pleasant to the eye. One of the skills that Data Scientists must acquire in order to connect more effectively with end-users is data visualization.</p><p>To begin, you must be comfortable with basic plots such as histograms, bar charts, and pie charts, before moving on to more advanced charts. During the exploratory data analysis stage, these graphs are extremely useful. Colorful graphics make univariate and bivariate studies much easier to comprehend.</p><p>As a data scientist, you’ll need to be able to visualize data using tools like ggplot, d3.js, and Matplotlib, as well as Tableau. These tools will assist you in converting complex project outcomes into a format that is easy to understand.</p><p>It helps in determining what influences customer behavior, quarterly sales mapping, client reporting, personnel performance, and creating a marketing plan that is tailored to specific user groups, and so on.</p><h4>6. Big data tools</h4><p>One should have a working knowledge of Big Data tools like Apache Spark, Hadoop, Talend, and Tableau, which are utilized to deal with massive and complex data that typical data processing applications can’t handle.</p><p>Organizations have been overwhelmed by such a big volume of data, and they are attempting to deal with it by fast embracing Big Data Technology so that it can be properly stored and used when needed, thereby giving them an advantage over their competitors.</p><h4>7. Deep learning</h4><p>It is a type of Machine Learning that is more advanced. Deep Learning models are being used by every company nowadays since they have the capacity to overcome the constraints of standard Machine Learning methodologies. Fundamentals of Neural Networks, the libraries used to create Deep Learning models such as Tensorflow or Keras, and how Convolutional Neural Networks, Recurrent Neural Networks, RBM, and Autoencoders function are among the other abilities required for Data Scientist positions.</p><p>Deep Learning has made all of this feasible. Because of advances in data storage capacities and computational advancement, it is a high-growth area in the field of Artificial Intelligence.</p><p>To succeed in this sector, you must have a strong understanding of programming (ideally Python) as well as linear algebra and mathematics. You can begin by developing basic models and progress to more complicated models such as CNN, RNN, and others.</p><h4>8. Data manipulation</h4><p>Data manipulation is one of the most important abilities for a Data Scientist. It entails the process of altering and organizing material in order to make it more readable.</p><p>Data manipulation, often known as wrangling, is the process of cleaning and transforming data into a format that may be properly evaluated in subsequent phases.</p><p>Data processing and wrangling, on the other hand, can take a long time but can ultimately help you make better data-driven judgments. Missing value imputation, outlier treatment, correcting data types, scaling, and transformation are some of the common data manipulation and wrangling techniques used.</p><h4>9. Soft skills</h4><p>Companies looking for a competent data scientist want someone who can communicate their technical findings to a non-technical team, such as the Marketing or Sales departments, in a clear and fluent manner. In order to manage the data effectively, a data scientist must enable the company to make decisions by providing them with quantitative insights, as well as knowing the demands of their non-technical colleagues.</p><p>A data scientist’s most important acquired talent is storytelling. It is the skill of constructing a coherent storey around numbers that transmit logic, strike the proper chord with stakeholders, and persuade them with sufficient arguments to drive a choice.</p><p>Data Science is still evolving, and let me tell you something important: in this profession, learning never ends. One day you master the tool, and the following day it is trampled by a more complex instrument. A data scientist must be inquisitive and eager to learn.</p><h4>10. Business acumen</h4><p>While Python programming, SQL querying, and data visualization are the essential technical abilities required of a data scientist, the need for excellent business acumen cannot be overstated. To obtain a thorough grasp of the business challenge and build a solution, it is necessary to have industry-specific knowledge. Basic business knowledge on rules such as minimum age criteria for credit cards, loan quantum for a mortgage as defined by regulatory authorities, compliance, and regulations, knowledge of accounting standards and risk management, and so on are industry-specific knowledge if you work in the finance domain.</p><p>You must fully comprehend the company’s primary objectives and goals, as well as how they affect your work. You must also be able to develop solutions that achieve those objectives in a cost-effective, simple-to-implement and widely adopted manner.</p><h4>What do recruiters look for when hiring</h4><p>A recruiter looks for a specific set of abilities while looking for a Data Scientist who will be with the organization for a long time. The goal of any recruitment process, whether it includes unique rounds, a live project, or a standardized interview, is to find a Data Scientist who can demonstrate extraordinary skills. These data scientist talents will define the scope of future challenging assignments he can tackle. As a candidate for Data Science, you must demonstrate streaks of your knowledge and skills in the most effective yet subtle way possible.</p><p>A data scientist is someone who has worked in a variety of fields. They use artificial intelligence and machine learning to find patterns and trends and generate data-driven forecasts. They must have a good foundation in artificial intelligence, machine learning, statistics, and data engineering, among other areas.</p><p>Data scientists must be inquisitive and results-driven, with great industry-specific expertise and communication abilities that enable them to convey highly technical outcomes to non-technical colleagues. To create and analyze algorithms, they have a solid quantitative background in statistics and linear algebra, as well as programming experience with a focus on data warehousing, mining, and modeling.</p><h4>How to become a data scientist</h4><p>To become a data scientist, follow these three steps:</p><ul><li>Obtain a bachelor’s degree in information technology, computer science, mathematics, physics, or a related discipline;</li><li>Obtain a master’s degree in data science or a closely related discipline;</li><li>Obtain experience in the field in which you wish to work (ex: healthcare, physics, business).</li></ul><p>If you want to work in a senior leadership role, you’ll need to get a master’s or doctorate degree.</p><p>Data science degrees are available at several schools, which is an obvious choice. This degree will teach you how to process and analyze a large amount of data and will include a lot of technical material on statistics, computers, and analysis methodologies, among other things. Most data science programs will also have a creative and analytical component, which will help you to make decisions based on your results.</p><p>While a data science degree is the most obvious approach, technical and computer-based degrees can also help you get started in data science. The examples of degrees that can help you learn data science are Computer science, Statistics, Physics, Mathematics, Economics, and others.</p><h3>Conclusion</h3><p><em>Scope of data science and making a career in it</em></p><p>The world is changing in response to current trends, and Data Scientists are one such trend in the modern world. It’s one of the most popular professional choices among today’s youth. Every business, from large corporations to small startups, requires a Data Scientist to make appropriate use of the massive amounts of data it generates and keeps. Data Science has a wide range of applications in both current and future circumstances. The following are a handful of the most prevalent job titles for data scientists: business intelligence analyst, data mining engineer, data architect, data scientist, and senior data scientist.</p><p>Artificial intelligence, machine learning, and robots, among other innovative technologies, are likely to rule the world in the coming decade. The coronavirus epidemic has accelerated the digitalization of businesses, altered labor dynamics, and made space for remote working, which has become the new normal across industries.</p><p>Companies of all sizes and industries are looking for expertise to help them wrestle big data into submission, from Google, Linked In, and Amazon to the basic retail store. In some companies, “new look” data scientists may be in charge of financial planning, ROI evaluation, budgeting, and a variety of other management-related responsibilities.</p><p>Since 2012, the Data Science industry has grown rapidly. As more companies turn to machine learning, big data, and AI, the demand for data scientists is growing. By monitoring items around one’s house or workplace, improving the quality of online shopping, enabling safe online financial transactions, and many other things, data science has made everyday life easier.</p><p>Data science is a vast professional path that is always evolving, promising a plethora of options in the future. Job responsibilities in data science are projected to become more specialized, leading to specialties in the subject. People who are interested in this field can take advantage of their opportunities and pursue what best suits them by using these standards and specialties.</p><p>Businesses and enterprises collect data on a daily basis for transactions and online interactions. Many businesses have the same problem: analyzing and categorizing the data they collect and store. In a case like this, a data scientist becomes the savior. Professionals with insight into how a business may thrive with data-driven ideas and implementation have a particular niche and need. Experts in data science are needed and valued in practically every sector. Big data is used by many organizations and even governments to provide efficient services to its clients. The data science craze isn’t going anywhere anytime soon.</p><p>As a data scientist, you’ll never be bored if you appreciate tackling complicated, real-world problems. Your major role is to analyze and process massive amounts of raw data in order to find answers and insights.</p><p>As a data scientist, you’ll have a bright professional outlook if you have the necessary qualifications. Individuals with these talents will continue to be in high demand, and those now working in data science will see their incomes rise in the future. As the need for qualified people to fill these positions grows, so will the incomes offered — even the lowest-paying data scientist employment will still provide a comfortable living.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f22a90c3e4f2" width="1" height="1" alt=""><hr><p><a href="https://medium.easyread.co/top-10-data-scientist-skills-you-should-know-f22a90c3e4f2">Top 10 Data Scientist Skills You Should Know</a> was originally published in <a href="https://medium.easyread.co/">Easyread</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>