<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ssenyonga yasin</title>
    <description>The latest articles on DEV Community by ssenyonga yasin (@ssenyonga_yasin_codes).</description>
    <link>https://dev.to/ssenyonga_yasin_codes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F670265%2F0289ecf9-d9f6-491e-9f15-a8be7bfb7b25.jpeg</url>
      <title>DEV Community: ssenyonga yasin</title>
      <link>https://dev.to/ssenyonga_yasin_codes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ssenyonga_yasin_codes"/>
    <language>en</language>
    <item>
      <title>Pandas cheat sheet 1</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Mon, 31 Jan 2022 10:47:19 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/pandas-cheat-sheet-1-20p6</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/pandas-cheat-sheet-1-20p6</guid>
      <description>&lt;h2&gt;
  
  
  Pandas Cheat Sheet for Data Science in Python
&lt;/h2&gt;

&lt;p&gt;A quick guide to the basics of the Python data analysis library Pandas, including code samples.&lt;br&gt;
The Pandas library is one of the most preferred tools for data scientists to do data manipulation and analysis, next to matplotlib for data visualization and NumPy, the fundamental library for scientific computing in Python on which Pandas was built. &lt;/p&gt;

&lt;p&gt;The fast, flexible, and expressive Pandas data structures are designed to make real-world data analysis significantly easier, but this might not be immediately the case for those who are just getting started with it. Exactly because there is so much functionality built into this package that the options are overwhelming.&lt;/p&gt;

&lt;p&gt;That's where this Pandas cheat sheet might come in handy. &lt;/p&gt;

&lt;p&gt;It's a quick guide through the basics of Pandas that you will need to get started on wrangling your data with Python. &lt;/p&gt;

&lt;p&gt;As such, you can use it as a handy reference if you are just beginning their data science journey with Pandas or, for those of you who already haven't started yet, you can just use it as a s a guide to make it easier to learn about and use it. &lt;/p&gt;

&lt;p&gt;The Pandas cheat sheet will guide you through the basics of the Pandas library, going from the data structures to I/O, selection, dropping indices or columns, sorting and ranking, retrieving basic information of the data structures you're working with to applying functions and data alignment.&lt;/p&gt;
&lt;h3&gt;
  
  
  Python For Data Science Cheat Sheet:
&lt;/h3&gt;

&lt;p&gt;Pandas Basics&lt;br&gt;
Use the following import convention:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import pandas as pd&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Pandas Data Structures&lt;/p&gt;

&lt;h3&gt;
  
  
  Series
&lt;/h3&gt;

&lt;p&gt;A one-dimensional labeled array capable of holding any data type&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;s = pd.Series([3, -5, 7, 4],  index=['a',  'b',  'c',  'd'])&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A   3
B   5
C   7
D   4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  DataFrame
&lt;/h3&gt;

&lt;p&gt;A two-dimensional labeled data structure with columns of potentially different types&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data = {'Country': ['Belgium',  'India',  'Brazil'],&lt;br&gt;
'Capital': ['Brussels',  'New Delhi',  'Brasilia'],'Population': [11190846, 1303171035, 207847528]}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;df = pd.DataFrame(data,columns=['Country',  'Capital',  'Population'])&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Country Capital Population
1   Belgium Brussels    11190846
2   India   New Delhi   1303171035
3   Brazil  Brasilia    207847528
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please note that the first column 1,2,3 is the index and Country,Capital,Population are the Columns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Asking For Help
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; help(pd.Series.loc)
I/O
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read and Write to CSV
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; pd.read_csv('file.csv', header=None, nrows=5)
 df.to_csv('myDataFrame.csv')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read multiple sheets from the same file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; xlsx = pd.ExcelFile('file.xls')
df = pd.read_excel(xlsx,  'Sheet1')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read and Write to Excel
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; pd.read_excel('file.xlsx')
 df.to_excel('dir/myDataFrame.xlsx',  sheet_name='Sheet1')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Read and Write to SQL Query or Database Table.
&lt;/h3&gt;

&lt;p&gt;(read_sql()is a convenience wrapper around read_sql_table() and read_sql_query())&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
pd.read_sql(SELECT * FROM my_table;, engine)
pd.read_sql_table('my_table', engine)
pd.read_sql_query(SELECT * FROM my_table;', engine)
df.to_sql('myDf', engine)

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

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>FACE DETECTION IN PYTHON 2</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Fri, 05 Nov 2021 11:34:33 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/face-detection-in-python-2-f8d</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/face-detection-in-python-2-f8d</guid>
      <description>&lt;h2&gt;
  
  
  introduction
&lt;/h2&gt;

&lt;p&gt;Face Detection is the first and essential step for face recognition, and it is used to detect faces in the images. It is a part of object detection and can use in many areas such as security, bio-metrics, law enforcement, entertainment, personal safety.&lt;/p&gt;

&lt;p&gt;It is used to detect faces in real time for surveillance and tracking of person or objects. It is widely used in cameras to identify multiple appearances in the frame Ex- Mobile cameras and DSLR’s. Facebook is also using face detection algorithm to detect faces in the images and recognise them. &lt;/p&gt;

&lt;h2&gt;
  
  
  How the Face Detection Works......
&lt;/h2&gt;

&lt;p&gt;There are many techniques to detect faces, with the help of these techniques, we can identify faces with higher accuracy. These techniques have an almost same procedure for Face Detection such as OpenCV, Neural Networks, Matlab, etc. The face detection work as to detect multiple faces in an image. Here we work on OpenCV for Face Detection, and there are some steps that how face detection operates, which are as follows-&lt;/p&gt;

&lt;p&gt;Firstly the image is imported by providing the location of the image. Then the picture is transformed from RGB to Grayscale because it is easy to detect faces in the grayscale.&lt;/p&gt;

&lt;p&gt;After that, the image manipulation used, in which the resizing, cropping, blurring and sharpening of the images done if needed. The next step is image segmentation, which is used for contour detection or segments the multiple objects in a single image so that the classifier can quickly detect the objects and faces in the picture.&lt;/p&gt;

&lt;p&gt;The next step is to use Haar-Like features algorithm, which is proposed by Voila and Jones for face detection. This algorithm used for finding the location of the human faces in a frame or image. All human faces shares some universal properties of the human face like the eyes region is darker than its Neighbour pixels and nose region is brighter than eye region.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99czi17g2irh0d230qi5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99czi17g2irh0d230qi5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Face Detector in Real-Time (Webcam).
&lt;/h2&gt;

&lt;p&gt;import libraries&lt;br&gt;
&lt;code&gt;&lt;br&gt;
import cv2&lt;br&gt;
import numpy as np&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;import classifier for face and eye detection&lt;br&gt;
&lt;code&gt;&lt;br&gt;
face_classifier = cv2.CascadeClassifier(‘Haarcascades/haarcascade_frontalface_default.xml’)&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
 Import Classifier for Face and Eye Detection&lt;br&gt;
&lt;code&gt;&lt;br&gt;
face_classifier = cv2.CascadeClassifier(‘Haarcascades/haarcascade_frontalface_default.xml’)&lt;br&gt;
eye_classifier = cv2.CascadeClassifier (‘Haarcascades/haarcascade_eye.xml’)&lt;br&gt;
def face_detector (img, size=0.5):&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
 Convert Image to Grayscale&lt;br&gt;
&lt;code&gt;&lt;br&gt;
gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY)&lt;br&gt;
faces = face_classifier.detectMultiScale (gray, 1.3, 5)&lt;br&gt;
If faces is ():&lt;br&gt;
return img&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
 Given coordinates to detect face and eyes location from ROI&lt;br&gt;
&lt;code&gt;&lt;br&gt;
for (x, y, w, h) in faces&lt;br&gt;
x = x — 100&lt;br&gt;
w = w + 100&lt;br&gt;
y = y — 100&lt;br&gt;
h = h + 100&lt;br&gt;
cv2.rectangle (img, (x, y), (x+w, y+h), (255, 0, 0), 2)&lt;br&gt;
roi_gray = gray[y: y+h, x: x+w]&lt;br&gt;
roi_color = img[y: y+h, x: x+w]&lt;br&gt;
eyes = eye_classifier.detectMultiScale (roi_gray)&lt;br&gt;
for (ex, ey, ew, eh) in eyes:&lt;br&gt;
cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,0,255),2)&lt;br&gt;
roi_color = cv2.flip (roi_color, 1)&lt;br&gt;
return roi_color&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
 Webcam setup for Face Detection&lt;br&gt;
&lt;code&gt;&lt;br&gt;
cap = cv2.VideoCapture (0)&lt;br&gt;
while True:&lt;br&gt;
ret, frame = cap.read ()&lt;br&gt;
cv2.imshow (‘Our Face Extractor’, face_detector (frame))&lt;br&gt;
if cv2.waitKey (1) == 13: #13 is the Enter Key&lt;br&gt;
break&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
 When everything done, release the capture&lt;br&gt;
&lt;code&gt;&lt;br&gt;
cap.release ()&lt;br&gt;
cv2.destroyAllWindows ()&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why pitch-based funding competitions are harmful and we need to stop having them</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Mon, 18 Oct 2021 11:30:28 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/why-pitch-based-funding-competitions-are-harmful-and-we-need-to-stop-having-them-54ld</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/why-pitch-based-funding-competitions-are-harmful-and-we-need-to-stop-having-them-54ld</guid>
      <description>&lt;h2&gt;
  
  
  What's pitching
&lt;/h2&gt;

&lt;p&gt;The most extreme manifestation of this idea of “pitching” are the “Shark Tank”-style funding opportunities where leaders go on stage to give short presentations about their organizations’ work to a live audience, after which, depending on how they do and how the “judges” and people watching their presentations react, they could walk away with one of several small grant prizes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you gain from pitching.
&lt;/h2&gt;

&lt;p&gt;Like many philosophies and practices in our sector that we’ve accepted as normal, pitch-based funding opportunities can seem fine, fun, and helpful. &lt;br&gt;
Often, participants get mentorship and training on public speaking and obtain some experience. A colleague who participated in one of these competitions told me she got to know other participants and it was not at all competitive; people supported one another and everyone had a great time.&lt;/p&gt;

&lt;p&gt;These competitions can be done with a spirit of camaraderie and public awareness and not the cutthroat events they could potentially become. Plus, they are certainly more interesting for everyone than the traditional, tedious grantmaking process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is pitching Really useful
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Here are several reasons why i think it may not be
&lt;/h3&gt;

&lt;h3&gt;
  
  
  If you must use more than ten slides to explain your business, you probably don’t have a business.
&lt;/h3&gt;

&lt;p&gt;The whole idea being presented in only 10 slides sometimes given five minutes to present.&lt;/p&gt;

&lt;p&gt;The ten topics that a venture capitalist cares about are:&lt;/p&gt;

&lt;p&gt;1.Problem&lt;br&gt;
2.Your solution&lt;br&gt;
3.Business model&lt;br&gt;
4.Underlying magic/technology&lt;br&gt;
5.Marketing and sales&lt;br&gt;
6.Competition&lt;br&gt;
7.Team&lt;br&gt;
8.Projections and milestones&lt;br&gt;
9.Status and timeline.&lt;br&gt;
10.Summary and call to action.&lt;/p&gt;

&lt;p&gt;1.They entrench existing power dynamics between funders/donors and nonprofits.&lt;/p&gt;

&lt;p&gt;Why is it always nonprofits that are pitching to funders and donors? Why is it never the other way around? Simple: Because one party has money, and in our society that means they by default get to call the shots. But is this what we want to reinforce? Why should people who have money have so much power, and the people who are actually doing the work of running programs and services have to jump through hoops? How can we become equal partners in this work if we keep reinforcing the asymmetric power differentials that are already pervasive everywhere else?&lt;/p&gt;

&lt;p&gt;2.They’re inequitable, rewarding the organizations that can play the game best.&lt;br&gt;
Grant applications are usually inequitable because the organizations that can write the “best” proposals usually win, and they tend to be mainstream, white-led orgs. Pitch-based competitions have the same challenges: Those who win tend to be the best presenters, the most charismatic, and the ones with the missions that most tug at heart-strings. Participants from marginalized backgrounds, who may not be as fluent in English as others, or who may not have as much presentation skills, or whose missions are harder to explain or get people to care about, are often left behind. Also, who can participate as judges and audience members? Mostly well-off white people and others of privilege.&lt;/p&gt;

&lt;p&gt;3.They perpetuate competitiveness among different interrelated missions.&lt;br&gt;
Sure, when done thoughtfully, they can be friendly competitions. But they are competitions nonetheless. There is already so much jostling in our sector for resources: grants, donations, media coverage, even talent. We need to do a much better job understanding that all our missions are interrelated and we should be supporting one another. Funders complain about nonprofits not collaborating enough, especially to work on systemic issues, and yet every day they force nonprofits to compete with one another through their funding processes, including these pitch competitions, which my colleague Mari Kim likens to Squid Game, but less interesting.&lt;/p&gt;

&lt;p&gt;4.They turn the work of equity and justice into spectacles.&lt;br&gt;
A major reason so many of us were upset at the proposed show on CBS called “The Activist” is that it reduces critical causes into entertainment. These pitch-based competitions are basically just smaller, local versions of that show. There are already enough ingrained expectations in our sector that we manipulate our messaging to make our work emotionally resonant and easily digestible to people with money. We shouldn’t have to also simultaneously develop skills to entertain them too, as that only conditions people to pay attention to stuff that rouses their interests, not what would most be needed to build a just and equitable world (that stuff tends to be less entertaining).&lt;/p&gt;

&lt;p&gt;5.They reinforce ignorance among the public.&lt;br&gt;
Oftentimes, the people “judging” the competitions as well as those in attendance may have never worked at nonprofits addressing these causes or had any first-hand experience in these issues at all. And yet they get the microphone and ask ridiculous questions or make comments that further the public’s misperceptions of nonprofits. One colleague told me she failed to get funding because one “judge,” a dude from the tech sector, asked how her mission was going to be self-sustaining (Most nonprofits will never be self-sustaining and it is a delusion to think they will ever be). Questions on sustainability, overhead, scaling, etc. betray a complete lack of understanding of how nonprofits actually run and reinforce harmful misinformation, making nonprofits’ work even more difficult.&lt;/p&gt;

&lt;p&gt;6.They are time-consuming and distracting.&lt;br&gt;
These competitions require significant investment in time and energy. Meeting with mentors, practicing, rehearsals, etc. These competitions hosted by Health Organisations for funding to address children’s mental health, for example, requires participants to attend six weeks of trainings on pitching and other stuff. The people working hard to ensure children have mental health support do not need training on public speaking or making pitches or whatever. They need money! That’s something we need funders and donors to understand: Stop wasting our time on nonsensical stuff and making us jump through flaming hoops for your entertainment or edification and just provide money.&lt;/p&gt;

&lt;p&gt;7.They are insulting and patronizing.&lt;br&gt;
As one colleague put it regarding a competition in her community: “nonprofit staff are forced to perform for self-described ‘sharks,’ who regularly insult and belittle staff for failing to be sufficiently entrepreneurial. Be prepared to dance, monkey, dance.” If it’s not overtly insulting, it’s often patronizing. “If nonprofits develop their speaking and pitching skills, they can approach other funders; you know, teach someone to fish, etc.” This is a condescending attitude that is too prevalent among funders and donors. Do not create ridiculous and inequitable processes and think you’re doing nonprofits a favor by helping them develop skills in navigating the ridiculousness and inequity.&lt;/p&gt;

&lt;p&gt;For these and other reasons, I’d like for us to move away from pitch-based competitions altogether. Let’s phase them out completely. I know there are counter-arguments we can make, but almost any and every benefit of pitch-based competitions (getting to know other nonprofits, exposing the public to important causes, developing presentation skills) can be done in other, better ways.&lt;/p&gt;

&lt;p&gt;Let’s be more thoughtful and fund in more equitable ways. The whole concept of “pitching” is problematic and it goes way beyond these competitions. As colleague Yvonne Moore of Moore Philanthropy said during that Clubhouse discussion, and I paraphrase: “We [communities of color and other marginalized communities] are really good at pitches. People just don’t hear us.”&lt;/p&gt;

&lt;h2&gt;
  
  
  You free to give your suggestions and arguments in the comments section.
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>THINK LIKE PROGRAMMERS</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Tue, 07 Sep 2021 07:15:45 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/think-like-programmers-26h8</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/think-like-programmers-26h8</guid>
      <description>&lt;p&gt;If you’re interested in programming, you may well have seen this quote before:&lt;/p&gt;

&lt;p&gt;“Everyone in this country should learn to program a computer, because it teaches you to think.” — Steve Jobs&lt;br&gt;
You probably also wondered what does it mean, exactly, to think like a programmer? And how do you do it??&lt;/p&gt;

&lt;p&gt;Essentially, it’s all about a more effective way for problem solving.&lt;/p&gt;

&lt;p&gt;In this post, my goal is to teach you that way.&lt;/p&gt;

&lt;p&gt;By the end of it, you’ll know exactly what steps to take to be a better problem-solver.&lt;/p&gt;

&lt;p&gt;Why is this important?&lt;br&gt;
Problem solving is the meta-skill.&lt;/p&gt;

&lt;p&gt;We all have problems. Big and small. How we deal with them is sometimes, well…pretty random.&lt;/p&gt;

&lt;p&gt;Unless you have a system, this is probably how you “solve” problems (which is what I did when I started coding):&lt;/p&gt;

&lt;p&gt;Try a solution.&lt;br&gt;
If that doesn’t work, try another one.&lt;br&gt;
If that doesn’t work, repeat step 2 until you luck out.&lt;br&gt;
Look, sometimes you luck out. But that is the worst way to solve problems! And it’s a huge, huge waste of time.&lt;/p&gt;

&lt;p&gt;The best way involves a) having a framework and b) practicing it.&lt;/p&gt;

&lt;p&gt;“Almost all employers prioritize problem-solving skills first.&lt;br&gt;
Problem-solving skills are almost unanimously the most important qualification that employers look for….more than programming languages proficiency, debugging, and system design.&lt;br&gt;
Demonstrating computational thinking or the ability to break down large, complex problems is just as valuable (if not more so) than the baseline technical skills required for a job.” — Hacker Rank (2018 Developer Skills Report)&lt;br&gt;
Have a framework&lt;br&gt;
To find the right framework, I followed the advice in Tim Ferriss’ book on learning, “The 4-Hour Chef”.&lt;/p&gt;

&lt;p&gt;It led me to interview two really impressive people: C. Jordan Ball (ranked 1st or 2nd out of 65,000+ users on Coderbyte), and V. Anton Spraul (author of the book “Think Like a Programmer: An Introduction to Creative Problem Solving”).&lt;/p&gt;

&lt;p&gt;I asked them the same questions, and guess what? Their answers were pretty similar!&lt;/p&gt;

&lt;p&gt;Soon, you too will know them.&lt;/p&gt;

&lt;p&gt;Sidenote: this doesn’t mean they did everything the same way. Everyone is different. You’ll be different. But if you start with principles we all agree are good, you’ll get a lot further a lot quicker.&lt;/p&gt;

&lt;p&gt;“The biggest mistake I see new programmers make is focusing on learning syntax instead of learning how to solve problems.” — V. Anton Spraul&lt;br&gt;
So, what should you do when you encounter a new problem?&lt;/p&gt;

&lt;p&gt;Here are the steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understand
Know exactly what is being asked. Most hard problems are hard because you don’t understand them (hence why this is the first step).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to know when you understand a problem? When you can explain it in plain English.&lt;/p&gt;

&lt;p&gt;Do you remember being stuck on a problem, you start explaining it, and you instantly see holes in the logic you didn’t see before?&lt;/p&gt;

&lt;p&gt;Most programmers know this feeling.&lt;/p&gt;

&lt;p&gt;This is why you should write down your problem, doodle a diagram, or tell someone else about it (or thing… some people use a rubber duck).&lt;/p&gt;

&lt;p&gt;“If you can’t explain something in simple terms, you don’t understand it.” — Richard Feynman&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Plan
Don’t dive right into solving without a plan (and somehow hope you can muddle your way through). Plan your solution!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Nothing can help you if you can’t write down the exact steps.&lt;/p&gt;

&lt;p&gt;In programming, this means don’t start hacking straight away. Give your brain time to analyze the problem and process the information.&lt;/p&gt;

&lt;p&gt;To get a good plan, answer this question:&lt;/p&gt;

&lt;p&gt;“Given input X, what are the steps necessary to return output Y?”&lt;/p&gt;

&lt;p&gt;Sidenote: Programmers have a great tool to help them with this… Comments!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Divide
Pay attention. This is the most important step of all.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do not try to solve one big problem. You will cry.&lt;/p&gt;

&lt;p&gt;Instead, break it into sub-problems. These sub-problems are much easier to solve.&lt;/p&gt;

&lt;p&gt;Then, solve each sub-problem one by one. Begin with the simplest. Simplest means you know the answer (or are closer to that answer).&lt;/p&gt;

&lt;p&gt;After that, simplest means this sub-problem being solved doesn’t depend on others being solved.&lt;/p&gt;

&lt;p&gt;Once you solved every sub-problem, connect the dots.&lt;/p&gt;

&lt;p&gt;Connecting all your “sub-solutions” will give you the solution to the original problem. Congratulations!&lt;/p&gt;

&lt;p&gt;This technique is a cornerstone of problem-solving. Remember it (read this step again, if you must).&lt;/p&gt;

&lt;p&gt;“If I could teach every beginning programmer one problem-solving skill, it would be the ‘reduce the problem technique.’&lt;br&gt;
For example, suppose you’re a new programmer and you’re asked to write a program that reads ten numbers and figures out which number is the third highest. For a brand-new programmer, that can be a tough assignment, even though it only requires basic programming syntax.&lt;br&gt;
If you’re stuck, you should reduce the problem to something simpler. Instead of the third-highest number, what about finding the highest overall? Still too tough? What about finding the largest of just three numbers? Or the larger of two?&lt;br&gt;
Reduce the problem to the point where you know how to solve it and write the solution. Then expand the problem slightly and rewrite the solution to match, and keep going until you are back where you started.” — V. Anton Spraul&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stuck?
By now, you’re probably sitting there thinking “Hey Richard... That’s cool and all, but what if I’m stuck and can’t even solve a sub-problem??”&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First off, take a deep breath. Second, that’s fair.&lt;/p&gt;

&lt;p&gt;Don’t worry though, friend. This happens to everyone!&lt;/p&gt;

&lt;p&gt;The difference is the best programmers/problem-solvers are more curious about bugs/errors than irritated.&lt;/p&gt;

&lt;p&gt;In fact, here are three things to try when facing a whammy:&lt;/p&gt;

&lt;p&gt;Debug: Go step by step through your solution trying to find where you went wrong. Programmers call this debugging (in fact, this is all a debugger does).&lt;br&gt;
“The art of debugging is figuring out what you really told your program to do rather than what you thought you told it to do.”” — Andrew Singer&lt;br&gt;
Reassess: Take a step back. Look at the problem from another perspective. Is there anything that can be abstracted to a more general approach?&lt;br&gt;
“Sometimes we get so lost in the details of a problem that we overlook general principles that would solve the problem at a more general level. […]&lt;br&gt;
The classic example of this, of course, is the summation of a long list of consecutive integers,&lt;br&gt;
&lt;br&gt;
&lt;code&gt;1 + 2 + 3 + … + n,&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 which a very young Gauss quickly recognized was simply n(n+1)/2, thus avoiding the effort of having to do the addition.” — C. Jordan Ball&lt;br&gt;
Sidenote: Another way of reassessing is starting anew. Delete everything and begin again with fresh eyes. I’m serious. You’ll be dumbfounded at how effective this is.&lt;/p&gt;

&lt;p&gt;Research: Ahh, good ol’ Google. You read that right. No matter what problem you have, someone has probably solved it. Find that person/ solution. In fact, do this even if you solved the problem! (You can learn a lot from other people’s solutions).&lt;br&gt;
Caveat: Don’t look for a solution to the big problem. Only look for solutions to sub-problems. Why? Because unless you struggle (even a little bit), you won’t learn anything. If you don’t learn anything, you wasted your time.&lt;/p&gt;

&lt;p&gt;Practice&lt;br&gt;
Don’t expect to be great after just one week. If you want to be a good problem-solver, solve a lot of problems!&lt;/p&gt;

&lt;p&gt;Practice. Practice. Practice. It’ll only be a matter of time before you recognize that “this problem could easily be solved with .”&lt;/p&gt;

&lt;p&gt;How to practice? There are options out the wazoo!&lt;/p&gt;

&lt;p&gt;Chess puzzles, math problems, Sudoku, Go, Monopoly, video-games, cryptokitties, bla… bla… bla….&lt;/p&gt;

&lt;p&gt;In fact, a common pattern amongst successful people is their habit of practicing “micro problem-solving.” For example, Peter Thiel plays chess, and Elon Musk plays video-games.&lt;/p&gt;

&lt;p&gt;“Byron Reeves said ‘If you want to see what business leadership may look like in three to five years, look at what’s happening in online games.’&lt;br&gt;
Fast-forward to today. Elon [Musk], Reid [Hoffman], Mark Zuckerberg and many others say that games have been foundational to their success in building their companies.” — Mary Meeker (2017 internet trends report)&lt;br&gt;
Does this mean you should just play video-games? Not at all.&lt;/p&gt;

&lt;p&gt;But what are video-games all about? That’s right, problem-solving!&lt;/p&gt;

&lt;p&gt;So, what you should do is find an outlet to practice. Something that allows you to solve many micro-problems (ideally, something you enjoy).&lt;/p&gt;

&lt;p&gt;For example, I enjoy coding challenges. Every day, I try to solve at least one challenge (usually on Coderbyte).&lt;/p&gt;

&lt;p&gt;Like I said, all problems share similar patterns.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
That’s all folks!&lt;/p&gt;

&lt;p&gt;Now, you know better what it means to “think like a programmer.”&lt;/p&gt;

&lt;p&gt;You also know that problem-solving is an incredible skill to cultivate (the meta-skill).&lt;/p&gt;

&lt;p&gt;As if that wasn’t enough, notice how you also know what to do to practice your problem-solving skills!&lt;/p&gt;

&lt;p&gt;Phew… Pretty cool right?&lt;/p&gt;

&lt;p&gt;Finally, I wish you encounter many problems and solve them &lt;/p&gt;

&lt;h2&gt;
  
  
  Special  thanks to Richard Reis
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>TWITTER IMAGES INTO YOUR WEBSITE</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Fri, 03 Sep 2021 07:51:02 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/twitter-images-into-your-website-2c8a</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/twitter-images-into-your-website-2c8a</guid>
      <description>&lt;p&gt;1.Click the  icon located within the Tweet.&lt;br&gt;
2.From the menu, select Embed Tweet.&lt;br&gt;
3.This will open publish.twitter.com where you can customize the look of the embedded Tweet by clicking set customization options.&lt;br&gt;
4.If the Tweet is a reply to another Tweet, you can check Hide Conversation to hide the original Tweet.&lt;br&gt;
5.Once you like the look of the embedded Tweet, copy the code provided by clicking the Copy Code button.&lt;br&gt;
6.Paste the code into your blog or website.&lt;/p&gt;

&lt;h1&gt;
  
  
  example
&lt;/h1&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://twitter.com/hashtag/MoneyHeistSeason5?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#MoneyHeistSeason5&lt;/a&gt; must watch today &lt;a href="https://t.co/IyFpGbFLfD"&gt;pic.twitter.com/IyFpGbFLfD&lt;/a&gt;&lt;/p&gt;— computer_wizard (@MillersYasin) &lt;a href="https://twitter.com/MillersYasin/status/1433677771751010308?ref_src=twsrc%5Etfw"&gt;September 3, 2021&lt;/a&gt;
&lt;/blockquote&gt; &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;blockquote class="twitter-tweet" data-theme="dark"&amp;gt;&amp;lt;p lang="en" dir="ltr"&amp;gt;&amp;lt;a href="https://twitter.com/hashtag/MoneyHeistSeason5?src=hash&amp;amp;amp;ref_src=twsrc%5Etfw"&amp;gt;#MoneyHeistSeason5&amp;lt;/a&amp;gt; must watch today &amp;lt;a href="https://t.co/IyFpGbFLfD"&amp;gt;pic.twitter.com/IyFpGbFLfD&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;amp;mdash; computer_wizard (@MillersYasin) &amp;lt;a href="https://twitter.com/MillersYasin/status/1433677771751010308?ref_src=twsrc%5Etfw"&amp;gt;September 3, 2021&amp;lt;/a&amp;gt;&amp;lt;/blockquote&amp;gt; &amp;lt;script async src="https://platform.twitter.com/widgets.js" charset="utf-8"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;h2&gt;
  
  
  You can also edit the image as you are coding in your editor that's the height, width etc.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--foka7BK6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4m8v5w8flq7aghkxucp.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--foka7BK6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4m8v5w8flq7aghkxucp.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Make your site very light by using twitter to host the images.
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>FLASK WEB DEVELOPMENT</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Fri, 13 Aug 2021 09:44:01 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/flask-web-development-2dl7</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/flask-web-development-2dl7</guid>
      <description>&lt;h1&gt;
  
  
  Web development In Python
&lt;/h1&gt;

&lt;p&gt;So one of the application domains of Python is Web development. You can use it to make powerful and fast web applications. In so making, a number of tools and frameworks have been developed to aid web development in Python.&lt;/p&gt;

&lt;p&gt;Some of these are but not limited to;&lt;/p&gt;

&lt;p&gt;Django&lt;br&gt;
Flask&lt;br&gt;
Pyramid&lt;/p&gt;
&lt;h3&gt;
  
  
  web-frameworks-python
&lt;/h3&gt;

&lt;p&gt;Our focus will be on the Flask framework. &lt;br&gt;
And for a quick overview on how to get started with Python Web development, consider looking into, Getting Started with Python Web Development using ###FLASK&lt;/p&gt;

&lt;p&gt;Once you have mastered the basic overview of flask, we will dive into the topic of the day. &lt;br&gt;
 What an introduction !!! Hope you are enjoying the article. Let us refocus now.&lt;/p&gt;

&lt;p&gt;refocus-image&lt;/p&gt;

&lt;p&gt;Given a minimal Flask application, such as;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World, dear Friend!'


@app.route('/page/&amp;lt;int:page_num&amp;gt;')
def content(page_num):
    return f'&amp;lt;h1&amp;gt;Yoo.. It is your page {page_num}&amp;lt;/h1&amp;gt;'

`if __name__ == '__main__':
    app.run(host='',port='',debug=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The minimal application can be run following the steps below, (as you might be familiar),&lt;/p&gt;

&lt;p&gt;On Bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export FLASK_APP=app.py
flask run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other scenarios you might want to specify the host and port number, environment, debug mode etc. for which you want your flask application to run, you would have to include all that into the export command above.&lt;br&gt;
That can become tedious over time as you develop your cool project, pressing up arrow key many times to retrace the export command (bash users, you know what I mean).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;On Bash
flask run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variables that we add to the export command are known as environment variables. These variables are used by your flask application to serve your project.&lt;/p&gt;

&lt;p&gt;Examples of environment variables include;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FLASK_ENV
FLASK_DEBUG.
FLASK_RUN_EXTRA_FILES
FLASK_RUN_HOST
FLASK_RUN_PORT
FLASK_RUN_CERT
FLASK_RUN_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those are default flask environment variables defined by the framework. If not specified, they use their default values.&lt;/p&gt;

&lt;p&gt;User defined variables&lt;br&gt;
Also, if you wanted to connect your application to a database, you would have to hard code your credentials into your python code, which is not recommended.&lt;br&gt;
An example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask
app = Flask(__name__)

app.config[MYSQL_USER]="your_username"
app.config[MYSQL_HOST]="localhost"
app.config[MYSQL_DB]="my_appdb"
app.config[MYSQL_PASSWORD]="your_password"

@app.route('/')
def index():
    return {'Message': 'Hello World'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That kind of hard coding credentials is not ideal if you are working on a large project with other people&lt;/p&gt;

&lt;p&gt;Incase you do not follow Strict password policies and use one password everywhere....You are hacked!!!. You just shared your password with the world.&lt;/p&gt;

&lt;p&gt;So how do we deal with the flask environment variables?&lt;br&gt;
We are going to see how to load flask environment variables automatically. You are here because you're tired of setting environment variables every time you are running your flask app? Variables like FLASK_APP or FLASK_ENV using export command. Am going to help you do just that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: Install python-dotenv
In your virtual environment, run;
pip install python-dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I emphasize, always use virtual environments on your system to prevent corrupting your main Python installation. In case you want a recap on how to create virtual environments, refer to this guide. Creation of Virtual Environments&lt;/p&gt;

&lt;p&gt;Step 2: Create .env and .flaskenv files in your project root folder&lt;/p&gt;

&lt;p&gt;On Bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch .env
touch .flaskenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Place your flask environment variables in .flaskenv&lt;br&gt;
Depending on your use case, this will guide you on what to include.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In .flaskenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;//this is the .flaskenv file&lt;br&gt;
FLASK_ENV - Controls the environment.&lt;br&gt;
FLASK_DEBUG - Enables debug mode.&lt;br&gt;
FLASK_RUN_EXTRA_FILES - A list of files that will be watched by the re-loader in addition to the Python modules.&lt;br&gt;
FLASK_RUN_HOST - The host you want to bind your app to.&lt;br&gt;
FLASK_RUN_PORT - The port you want to use.&lt;br&gt;
FLASK_RUN_CERT - A certificate file for so your app can be run with HTTPS.&lt;br&gt;
FLASK_RUN_KEY - The key file for your cert.&lt;br&gt;
for example; FLASK_APP=app.py&lt;/p&gt;

&lt;p&gt;Boom, great work done. To run your app now, Simply do run;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That was fast,.... right?? Yes so you can now focus on programming instead of looking for which flask environment variable is missing.&lt;/p&gt;

&lt;p&gt;So how about my-secretly-defined environment variables?&lt;br&gt;
Yes getting to that now. Follow this guide.&lt;/p&gt;

&lt;p&gt;Step 1. Place your-secretly-defined environment variables in .env&lt;br&gt;
These can include;&lt;/p&gt;

&lt;p&gt;Login credentials to the database&lt;br&gt;
API keys&lt;br&gt;
SECRET_KEY (among others)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In .env
//This is the .env file
MYSQL_USER=root
MYSQL_PASSWORD=my_mysql_password
MYSQL_DB=userdb
MYSQL_HOST=localhost
SECRET_KEY=topsecretkey
API_KEY=donotsharethisapikeywithanyone
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: Create a settings.py file&lt;br&gt;
(Since these variables are not served automatically, we have to load them through this settings.py file)&lt;/p&gt;

&lt;p&gt;In settings.py&lt;br&gt;
//This is the settings.py file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from os import environ
SECRET_KEY=environ.get('SECRET_KEY)
API_KEY=environ.get('API_KEY')
MYSQL_USER=environ.get('MYSQL_USER')
//add any more variables you have
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: For consistency, it is good to keep the same variable name as the environment variable.&lt;/p&gt;

&lt;p&gt;Step 3: Add the configurations to our app&lt;br&gt;
In your app.py , the file that has your flask object.&lt;br&gt;
app.config.from_pyfile('settings.py')&lt;/p&gt;

&lt;h1&gt;
  
  
  loading all environment variables from settings.py
&lt;/h1&gt;

&lt;p&gt;So what happens is that the settings.py will read the values you placed in your .env file and store them in variables as you defined them in settings.py.&lt;/p&gt;

&lt;p&gt;When you use the flask object's config method, together with the from_pyfile sub-method, the app will have access to the secretly defined variables in a secure way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Good lck in coding
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>INTRODUCTIN TO PYTHON FUCTIONS</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Mon, 02 Aug 2021 11:57:32 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/introductin-to-python-fuctions-1ffg</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/introductin-to-python-fuctions-1ffg</guid>
      <description>&lt;h1&gt;
  
  
  What are functions?
&lt;/h1&gt;

&lt;p&gt;Functions are a set of actions that we group together, and give a name to. You have already used a number of functions from the core Python language, such as string.title() and list.sort(). We can define our own functions, which allows us to "teach" Python new behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  General Syntax
&lt;/h2&gt;

&lt;p&gt;A general function looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Let's define a function.
def function_name(argument_1, argument_2):
    # Do whatever we want this function to do,
    #  using argument_1 and argument_2

# Use function_name to call the function.
function_name(value_1, value_2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will not run, but it shows how functions are used in general.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining a function
&lt;/h3&gt;

&lt;p&gt;Give the keyword def, which tells Python that you are about to define a function.&lt;br&gt;
Give your function a name. A variable name tells you what kind of value the variable contains; a function name should tell you what the function does.&lt;br&gt;
Give names for each value the function needs in order to do its work.&lt;br&gt;
These are basically variable names, but they are only used in the function.&lt;br&gt;
They can be different names than what you use in the rest of your program.&lt;br&gt;
These are called the function's arguments.&lt;br&gt;
Make sure the function definition line ends with a colon.&lt;br&gt;
Inside the function, write whatever code you need to make the function do its work.&lt;/p&gt;
&lt;h3&gt;
  
  
  Using your function
&lt;/h3&gt;

&lt;p&gt;To call your function, write its name followed by parentheses.&lt;br&gt;
Inside the parentheses, give the values you want the function to work with.&lt;br&gt;
These can be variables such as current_name and current_age, or they can be actual values such as 'eric' and 5.&lt;br&gt;
top&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic Examples
&lt;/h2&gt;

&lt;p&gt;For a simple first example, we will look at a program that compliments people. Let's look at the example, and then try to understand the code. First we will look at a version of this program as we would have written it earlier, with no functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("You are doing good work, Adriana!")
print("Thank you very much for your efforts on this project.")

print("\nYou are doing good work, Billy!")
print("Thank you very much for your efforts on this project.")

print("\nYou are doing good work, Caroline!")
print("Thank you very much for your efforts on this project.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Functions take repeated code, put it in one place, and then you call that code when you want to use it. Here's what the same program looks like with a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def thank_you(name):
    # This function prints a two-line personalized thank you message.
    print("\nYou are doing good work, %s!" % name)
    print("Thank you very much for your efforts on this project.")

thank_you('Adriana')
thank_you('Billy')
thank_you('Caroline')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our original code, each pair of print statements was run three times, and the only difference was the name of the person being thanked. When you see repetition like this, you can usually make your program more efficient by defining a function.&lt;/p&gt;

&lt;p&gt;The keyword def tells Python that we are about to define a function. We give our function a name, thank_you() in this case. A variable's name should tell us what kind of information it holds; a function's name should tell us what the variable does. We then put parentheses. Inside these parenthese we create variable names for any variable the function will need to be given in order to do its job. In this case the function will need a name to include in the thank you message. The variable name will hold the value that is passed into the function thank_you().&lt;/p&gt;

&lt;p&gt;To use a function we give the function's name, and then put any values the function needs in order to do its work. In this case we call the function three times, each time passing it a different name.&lt;/p&gt;

&lt;h3&gt;
  
  
  A common error
&lt;/h3&gt;

&lt;p&gt;A function must be defined before you use it in your program. For example, putting the function at the end of the program would not work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;thank_you('Adriana')
thank_you('Billy')
thank_you('Caroline')

def thank_you(name):
    # This function prints a two-line personalized thank you message.
    print("\nYou are doing good work, %s!" % name)
    print("Thank you very much for your efforts on this project.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the first line we ask Python to run the function thank_you(), but Python does not yet know how to do this function. We define our functions at the beginning of our programs, and then we can use them when we need to.&lt;/p&gt;

&lt;h3&gt;
  
  
  A second example
&lt;/h3&gt;

&lt;p&gt;When we introduced the different methods for sorting a list, our code got very repetitive. It takes two lines of code to print a list using a for loop, so these two lines are repeated whenever you want to print out the contents of a list. This is the perfect opportunity to use a function, so let's see how the code looks with a function.&lt;/p&gt;

&lt;p&gt;First, let's see the code we had without a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;students = ['bernice', 'aaron', 'cody']

# Put students in alphabetical order.
students.sort()

# Display the list in its current order.
print("Our students are currently in alphabetical order.")
for student in students:
    print(student.title())

# Put students in reverse alphabetical order.
students.sort(reverse=True)

# Display the list in its current order.
print("\nOur students are now in reverse alphabetical order.")
for student in students:
    print(student.title())
Here's what the same code looks like, using a function to print out the list:

def show_students(students, message):
    # Print out a message, and then the list of students
    print(message)
    for student in students:
        print(student.title())

students = ['bernice', 'aaron', 'cody']

# Put students in alphabetical order.
students.sort()
show_students(students, "Our students are currently in alphabetical order.")

#Put students in reverse alphabetical order.
students.sort(reverse=True)
show_students(students, "\nOur students are now in reverse alphabetical order.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is much cleaner code. We have an action we want to take, which is to show the students in our list along with a message. We give this action a name, show_students().&lt;/p&gt;

&lt;p&gt;This function needs two pieces of information to do its work, the list of students and a message to display. Inside the function, the code for printing the message and looping through the list is exactly as it was in the non-function code.&lt;/p&gt;

&lt;p&gt;Now the rest of our program is cleaner, because it gets to focus on the things we are changing in the list, rather than having code for printing the list. We define the list, then we sort it and call our function to print the list. We sort it again, and then call the printing function a second time, with a different message. This is much more readable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of using functions
&lt;/h2&gt;

&lt;p&gt;You might be able to see some advantages of using functions, through this example:&lt;/p&gt;

&lt;h3&gt;
  
  
  We write a set of instructions once.
&lt;/h3&gt;

&lt;p&gt;We save some work in this simple example, and we save even more work in larger programs.&lt;br&gt;
When our function works, we don't have to worry about that code anymore. Every time you repeat code in your program, you introduce an opportunity to make a mistake. Writing a function means there is one place to fix mistakes, and when those bugs are fixed, we can be confident that this function will continue to work correctly.&lt;br&gt;
We can modify our function's behavior, and that change takes effect every time the function is called. This is much better than deciding we need some new behavior, and then having to change code in many different places in our program.&lt;br&gt;
For a quick example, let's say we decide our printed output would look better with some form of a bulleted list. Without functions, we'd have to change each print statement. With a function, we change just the print statement in the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def show_students(students, message):
    # Print out a message, and then the list of students
    print(message)
    for student in students:
        print("- " + student.title())

students = ['bernice', 'aaron', 'cody']

# Put students in alphabetical order.
students.sort()
show_students(students, "Our students are currently in alphabetical order.")

#Put students in reverse alphabetical order.
students.sort(reverse=True)
show_students(students, "\nOur students are now in reverse alphabetical order.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can think of functions as a way to "teach" Python some new behavior. In this case, we taught Python how to create a list of students using hyphens; now we can tell Python to do this with our students whenever we want to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Returning a Value
&lt;/h2&gt;

&lt;p&gt;Each function you create can return a value. This can be in addition to the primary work the function does, or it can be the function's main job. The following function takes in a number, and returns the corresponding word for that number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_number_word(number):
    # Takes in a numerical value, and returns
    #  the word corresponding to that number.
    if number == 1:
        return 'one'
    elif number == 2:
        return 'two'
    elif number == 3:
        return 'three'
    # ...

# Let's try out our function.
for current_number in range(0,4):
    number_word = get_number_word(current_number)
    print(current_number, number_word)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's helpful sometimes to see programs that don't quite work as they are supposed to, and then see how those programs can be improved. In this case, there are no Python errors; all of the code has proper Python syntax. But there is a logical error, in the first line of the output.&lt;/p&gt;

&lt;p&gt;We want to either not include 0 in the range we send to the function, or have the function return something other than None when it receives a value that it doesn't know. Let's teach our function the word 'zero', but let's also add an else clause that returns a more informative message for numbers that are not in the if-chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_number_word(number):
    # Takes in a numerical value, and returns
    #  the word corresponding to that number.
    if number == 0:
        return 'zero'
    elif number == 1:
        return 'one'
    elif number == 2:
        return 'two'
    elif number == 3:
        return 'three'
    else:
        return "I'm sorry, I don't know that number."

# Let's try out our function.
for current_number in range(0,6):
    number_word = get_number_word(current_number)
    print(current_number, number_word)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use a return statement in one of your functions, keep in mind that the function stops executing as soon as it hits a return statement. For example, we can add a line to the get_number_word() function that will never execute, because it comes after the function has returned a value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_number_word(number):
    # Takes in a numerical value, and returns
    #  the word corresponding to that number.
    if number == 0:
        return 'zero'
    elif number == 1:
        return 'one'
    elif number == 2:
        return 'two'
    elif number == 3:
        return 'three'
    else:
        return "I'm sorry, I don't know that number."

    # This line will never execute, because the function has already
    #  returned a value and stopped executing.
    print("This message will never be printed.")

# Let's try out our function.
for current_number in range(0,6):
    number_word = get_number_word(current_number)
    print(current_number, number_word)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>PYTHON BASICS</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Thu, 22 Jul 2021 11:31:24 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/python-basics-3l51</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/python-basics-3l51</guid>
      <description>&lt;p&gt;Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation.&lt;br&gt;
&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common Feature Provided By python
&lt;/h2&gt;

&lt;p&gt;Simplicity-&amp;gt; Think less of the syntax of the language and more of the code.&lt;/p&gt;

&lt;p&gt;Open Source-&amp;gt; A powerful language and it is free for everyone to use and alter as needed.&lt;/p&gt;

&lt;p&gt;Portability-&amp;gt;Python code can be shared and it would work the same way it was intended to. Seamless and hassle-free.&lt;/p&gt;

&lt;h1&gt;
  
  
  Applications of Python.
&lt;/h1&gt;

&lt;p&gt;Artificial Intelligence&lt;br&gt;
Desktop Application&lt;br&gt;
Automation&lt;br&gt;
Web Development&lt;/p&gt;

&lt;p&gt;Python Hello World.&lt;br&gt;
Launch the VS code ,create a new python file, let say hello.py file and enter the following code and save the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print('Hello, World!')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The print() is a built-in function that displays a message on the screen. In our case, it’ll show the message 'Hello, Word!'.&lt;/p&gt;

&lt;h2&gt;
  
  
  Executing the Python program.
&lt;/h2&gt;

&lt;p&gt;To execute the file we created above, you launch the Command Prompt  or Terminal on vascode.&lt;/p&gt;

&lt;p&gt;After that, type the following command,&lt;br&gt;
Python3 hello.py&lt;/p&gt;
&lt;h3&gt;
  
  
  output
&lt;/h3&gt;


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

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

&lt;/div&gt;

&lt;h3&gt;
  
  
  Comments
&lt;/h3&gt;

&lt;p&gt;A comment is text in a program's code, script, or another file that is not meant to be seen by the user .&lt;/p&gt;

&lt;p&gt;Comments help make code easier to understand by explaining what is happening in the code&lt;/p&gt;
&lt;h1&gt;
  
  
  single line comment
&lt;/h1&gt;

&lt;p&gt;'''&lt;br&gt;
multiline comment&lt;/p&gt;

&lt;p&gt;Using  docstring&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;Arithmetic Operators.&lt;br&gt;
print(46 + 2)  # 48 (addition)&lt;br&gt;
print(10 - 9)  # 1 (subtraction)&lt;br&gt;
print(3 * 3)  # 9 (multiplication)&lt;br&gt;
print(84 / 2)  # 42.0 (division)&lt;br&gt;
print(2 ** 8)  # 256 (exponent)&lt;br&gt;
print(11 % 2)  # 1 (remainder of the division)&lt;br&gt;
print(11 // 2)  # 5 (floor division)&lt;/p&gt;
&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;
&lt;h4&gt;
  
  
  What is a Variable in Python?
&lt;/h4&gt;

&lt;p&gt;A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing.&lt;/p&gt;
&lt;h4&gt;
  
  
  Python Variable Types
&lt;/h4&gt;

&lt;p&gt;Every value in Python has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc. Variables in Python can be declared by any name or even alphabets like a, aa, abc, etc.&lt;/p&gt;
&lt;h4&gt;
  
  
  How to Declare and use a Variable
&lt;/h4&gt;

&lt;p&gt;Let see an example. We will define variable in Python and declare it as "a" and print it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
a=100 
print (a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Re-declare a Variable
&lt;/h4&gt;

&lt;p&gt;You can re-declare Python variables even after you have declared once.&lt;/p&gt;

&lt;p&gt;Here we have Python declare variable initialized to f=0.&lt;/p&gt;

&lt;p&gt;Later, we re-assign the variable f to  any value &lt;/p&gt;

&lt;h3&gt;
  
  
  Python 2 Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Declare a variable and initialize it

f = 0
print f
# re-declaring the variable works
f = 'new'
print f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python 3 Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Declare a variable and initialize it
f = 0
print(f)
# re-declaring the variable works
f = 'new'
print(f)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Python String Concatenation and Variable
&lt;/h4&gt;

&lt;p&gt;Let's see whether you can concatenate different data types like string and number together. For example, we will concatenate "new" with the number "version".&lt;/p&gt;

&lt;p&gt;For the following code, you will get undefined output -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a="new"
b = "version"
print a+b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the integer is declared as string, it can concatenate both&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a="new"
b = "version"
print(a+str(b))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python Variable Types: Local &amp;amp; Global&lt;/p&gt;

&lt;p&gt;There are two types of variables in Python, Global variable and Local variable. When you want to use the same variable for rest of your program or module you declare it as a global variable, while if you want to use the variable in a specific function or method, you use a local variable while Python variable declaration.&lt;/p&gt;

&lt;p&gt;Let's understand this Python variable types with the difference between local and global variables in the below program.&lt;/p&gt;

&lt;p&gt;Let us define variable in Python where the variable "f" is global in scope and is assigned value 101 which is printed in output&lt;br&gt;
Variable f is again declared in function and assumes local scope. It is assigned value "I am learning Python." which is printed out as an output. This Python declare variable is different from the global variable "f" defined earlier&lt;br&gt;
Once the function call is over, the local variable f is destroyed. &lt;/p&gt;
&lt;h1&gt;
  
  
  What are Logical Operators in Python?
&lt;/h1&gt;

&lt;p&gt;Logical Operators in Python are used to perform logical operations on the values of variables. The value is either true or false. We can figure out the conditions by the result of the truth values. There are mainly three types of logical operators in python : logical AND, logical OR and logical NOT. Operators are represented by keywords or special characters.&lt;/p&gt;

&lt;p&gt;Arithmetic Operators&lt;br&gt;
Comparison Operators&lt;br&gt;
Python Assignment Operators&lt;br&gt;
Logical Operators or Bitwise Operators&lt;br&gt;
Membership Operators&lt;br&gt;
Identity Operators&lt;br&gt;
Operator precedence&lt;/p&gt;
&lt;h2&gt;
  
  
  Arithmetic Operators
&lt;/h2&gt;

&lt;p&gt;Arithmetic Operators perform various arithmetic calculations like addition, subtraction, multiplication, division, %modulus, exponent, etc. There are various methods for arithmetic calculation in Python like you can use the eval function, declare variable &amp;amp; calculate, or call functions.&lt;/p&gt;

&lt;p&gt;Example: For arithmetic operators we will take simple example of addition where we will add two-digit 4+5=9&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x= 4    
y= 5
print(x + y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, you can use other arithmetic operators like for multiplication(*), division (/), substraction (-), etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Operators
&lt;/h2&gt;

&lt;p&gt;Comparison Operators In Python compares the values on either side of the operand and determines the relation between them. It is also referred to as relational operators. Various comparison operators in python are ( ==, != , &amp;lt;&amp;gt;, &amp;gt;,&amp;lt;=, etc.)&lt;/p&gt;

&lt;p&gt;Example: For comparison operators we will compare the value of x to the value of y and print the result in true or false. Here in example, our value of x = 4 which is smaller than y = 5, so when we print the value as x&amp;gt;y, it actually compares the value of x to y and since it is not correct, it returns false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 4
y = 5
print(('x &amp;gt; y  is',x&amp;gt;y))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Likewise, you can try other comparison operators (x &amp;lt; y, x==y, x!=y, etc.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Assignment Operators
&lt;/h2&gt;

&lt;p&gt;Assignment Operators in Python are used for assigning the value of the right operand to the left operand. Various assignment operators used in Python are (+=, - = , *=, /= , etc.).&lt;/p&gt;

&lt;p&gt;Example: Python assignment operators is simply to assign the value, for example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num1 = 4
num2 = 5
print(("Line 1 - Value of num1 : ", num1))
print(("Line 2 - Value of num2 : ", num2))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example of compound assignment operator&lt;/p&gt;

&lt;p&gt;We can also use a compound assignment operator, where you can add, subtract, multiply right operand to left and assign addition (or any other arithmetic function) to the left operand.&lt;/p&gt;

&lt;p&gt;Step 1: Assign value to num1 and num2&lt;br&gt;
Step 2: Add value of num1 and num2 (4+5=9)&lt;br&gt;
Step 3: To this result add num1 to the output of Step 2 ( 9+4)&lt;br&gt;
Step 4: It will print the final result as 13&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num1 = 4
num2 = 5
res = num1 + num2
res += num1
print(("Line 1 - Result of + is ", res))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Logical Operators
&lt;/h2&gt;

&lt;p&gt;Logical operators in Python are used for conditional statements are true or false. Logical operators in Python are AND, OR and NOT. For logical operators following condition are applied.&lt;/p&gt;

&lt;p&gt;For AND operator – It returns TRUE if both the operands (right side and left side) are true&lt;br&gt;
For OR operator- It returns TRUE if either of the operand (right side or left side) is true&lt;br&gt;
For NOT operator- returns TRUE if operand is false&lt;br&gt;
Example: Here in example we get true or false based on the value of a and b&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = True
b = False
print(('a and b is',a and b))
print(('a or b is',a or b))
print(('not a is',not a))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Membership Operators
&lt;/h2&gt;

&lt;p&gt;These operators test for membership in a sequence such as lists, strings or tuples. There are two membership operators that are used in Python. (in, not in). It gives the result based on the variable present in specified sequence or string&lt;/p&gt;

&lt;p&gt;Example: For example here we check whether the value of x=4 and value of y=8 is available in list or not, by using in and not in operators.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 4
y = 8
list = [1, 2, 3, 4, 5 ];
if ( x in list ):
   print("Line 1 - x is available in the given list")
else:
   print("Line 1 - x is not available in the given list")
if ( y not in list ):
   print("Line 2 - y is not available in the given list")
else:
   print("Line 2 - y is available in the given list")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declare the value for x and y&lt;br&gt;
Declare the value of list&lt;br&gt;
Use the "in" operator in code with if statement to check the value of x existing in the list and print the result accordingly&lt;br&gt;
Use the "not in" operator in code with if statement to check the value of y exist in the list and print the result accordingly&lt;br&gt;
Run the code- When the code run it gives the desired output&lt;/p&gt;
&lt;h2&gt;
  
  
  Identity Operators
&lt;/h2&gt;

&lt;p&gt;Identity Operators in Python are used to compare the memory location of two objects. The two identity operators used in Python are (is, is not).&lt;/p&gt;

&lt;p&gt;Operator is: It returns true if two variables point the same object and false otherwise&lt;br&gt;
Operator is not: It returns false if two variables point the same object and true otherwise&lt;br&gt;
Following operands are in decreasing order of precedence.&lt;/p&gt;

&lt;p&gt;Operators in the same box evaluate left to right&lt;/p&gt;

&lt;p&gt;Operators (Decreasing order of precedence)  Meaning&lt;br&gt;
**  Exponent&lt;br&gt;
&lt;em&gt;, /, //, % Multiplication, Division, Floor division, Modulus&lt;br&gt;
+, -    Addition, Subtraction&lt;br&gt;
&amp;lt;= &amp;lt; &amp;gt; &amp;gt;=   Comparison operators&lt;br&gt;
= %= /= //= -= += *= *&lt;/em&gt;=    Assignment Operators&lt;br&gt;
is is not   Identity operators&lt;br&gt;
in not in   Membership operators&lt;br&gt;
not or and  Logical operators&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = 20
y = 20
if ( x is y ): 
    print("x &amp;amp; y  SAME identity")
y=30
if ( x is not y ):
    print("x &amp;amp; y have DIFFERENT identity")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declare the value for variable x and y&lt;br&gt;
Use the operator "is" in code to check if value of x is same as y&lt;br&gt;
Next we use the operator "is not" in code if value of x is not same as y&lt;br&gt;
Run the code- The output of the result is as expected&lt;br&gt;
Operator precedence&lt;br&gt;
The operator precedence determines which operators need to be evaluated first. To avoid ambiguity in values, precedence operators are necessary. Just like in normal multiplication method, multiplication has a higher precedence than addition. For example in 3+ 4*5, the answer is 23, to change the order of precedence we use a parentheses (3+4)&lt;em&gt;5, now the answer is 35. Precedence operator used in Python are (unary + - ~, *&lt;/em&gt;, * / %, + - , &amp;amp;) etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v = 4
w = 5
x = 8
y = 2
z = 0
z = (v+w) * x / y;   
print("Value of (v+w) * x/ y is ",  z)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Declare the value of variable v,w…z&lt;br&gt;
Now apply the formula and run the code&lt;br&gt;
The code will execute and calculate the variable with higher precedence and will give the output&lt;br&gt;
Python 2 Example&lt;br&gt;
Above examples are Python 3 codes, if you want to use Python 2, please consider following codes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Arithmetic Operators
x= 4    
y= 5
print x + y

#Comparison Operators
x = 4
y = 5
print('x &amp;gt; y  is',x&amp;gt;y)

#Assignment Operators
num1 = 4
num2 = 5
print ("Line 1 - Value of num1 : ", num1)
print ("Line 2 - Value of num2 : ", num2)

#compound assignment operator
num1 = 4
num2 = 5
res = num1 + num2
res += num1
print ("Line 1 - Result of + is ", res)

#Logical Operators
a = True
b = False
print('a and b is',a and b)
print('a or b is',a or b)
print('not a is',not a)

#Membership Operators
x = 4
y = 8
list = [1, 2, 3, 4, 5 ];
if ( x in list ):
   print "Line 1 - x is available in the given list"
else:
   print "Line 1 - x is not available in the given list"
if ( y not in list ):
   print "Line 2 - y is not available in the given list"
else:
   print "Line 2 - y is available in the given list"

#Identity Operators
x = 20
y = 20
if ( x is y ):
    print "x &amp;amp; y  SAME identity"
y=30
if ( x is not y ):
    print "x &amp;amp; y have DIFFERENT identity"

#Operator precedence
v = 4
w = 5
x = 8
y = 2
z = 0
z = (v+w) * x / y;   
print "Value of (v+w) * x/ y is
pi = 3.14 # float
total = age + pi # float
print(type(age), type(pi), type(total)) # &amp;lt;class 'int'&amp;gt; &amp;lt;class 'float'&amp;gt; &amp;lt;class 'float'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Windows 10 out windows 11 in</title>
      <dc:creator>ssenyonga yasin</dc:creator>
      <pubDate>Mon, 19 Jul 2021 19:15:48 +0000</pubDate>
      <link>https://dev.to/ssenyonga_yasin_codes/windows-10-out-windows-11-in-5e93</link>
      <guid>https://dev.to/ssenyonga_yasin_codes/windows-10-out-windows-11-in-5e93</guid>
      <description></description>
    </item>
  </channel>
</rss>
