Learn python with Dhawal -2- Chapter


In the last chapter we discussed about the basics of programming and got to know about Python as a programming language a bit. I know it wasn't in much depth but I tried to bring it down to the level of a layman as much as I can. Now, as we know a bit about what Python is in general and how to go about the world of coding, we can start taking our first baby steps in the world of programming using python as a child-walker.  In this course, we will be working on Python version 3.7.

Installing Python in your computer :

There are various ways you can install Python on your computer, but as for now and for this particular course that we are going to undertake we would use the jupyter notebook which is a part of Anaconda IDE installation.

An IDE refers to an Integrated Development Environment. You can do a lot of thing using Anaconda distribution and there are other various ways to work with python but since as the name goes Jupyter notebook is very much like a notebook and quite simple to use. Hence it will make the task easier for you to learn more of coding. You can also Install python directly on your computer and use it from your terminal/cmd but that would be a little bit complex for someone who hasn't been familiar with the infamous black screen of total control.

You don't need to install python separately for this particular method, unlike for other IDEs for which you might. If you already have any other alternative like PyCharm,EMacs or just wanna use it on plain old terminal then you can surely use it but that's up to you.  I am here going to focus more on how to write a code in python than how to work with different ways of using python. Don't forget the thumb rule to learn anything new, 'if you don't understand anything or want to know more about anything, just search up the Internet. You can always comeback later and continue the course.'

Here are the steps to Install Anaconda on your system.

  1. Open and Visit the official website for Anaconda Distribution.
  2. Install the software following the instructions for your particular system.
  3. Open the Anaconda Navigator in your computer
  4. Click on the Jupyter Notebook to Launch it. Or you can also just search up straight in windows search via start menu, click Jupyter Notebook and launch, whatever is your preferable way.
Now, Once you are done installing and you have opened the Juypter Notebook, henceforth referred simply as simply as the 'notebook'. 

Note : Jupyter Notebook launches in your web browser, whichever browser you have selected as default. if it opens the terminal don't shut it close else the notebook will stop working.

Once you have launched the notebook, you'll see something like this

Jupyter Notebook Homescreen
Follow the next steps :

  1. Click on the desired folder ( for ex Desktop ) to open the folder, or you can create a new folder and enter it.
  2. Click on the new button on the top right corner.
  3. Click on the Python 3 option, that'll create a python notebook for you with the extension '.ipynb'
  4. Now you can see a different screen as shown below. You can now click on the 'Untitled' and give your notebook some name. You can explore the bunch of other options as well, they're most basic options like save, run, cut, copy, paste, etc...
  5. The notebook will autosave when you stop typing anything so you don't specifically need to save your notebook every time.
  6. For the next time you open your book, you can just open notebook and just look out for the name you just chose for your notebook with an .ipynb extension. for example, MyNotebook.ipynb
  7. Click on it to open the notebook so we can start the coding journey again.
NoteBook Front Page

Before we begin coding : 

Once you open the Jupyter Notebook, click on help and click on User Interface Tour and follow the instructions for the tour on using the UI. Next if you're a keyboard lover and love operating via shortcuts then you can also click on the next option in the help menu i.e. Keyboard Shortcuts to explore all the existing keyboard shortcuts.

How to Start Coding in Python :

Once you have explored the buttons and the Home UI of the notebook, we can surely begin the coding adventures from here on.

In this chapter we will just learn simple and very basic coding statements. As you'd see there's an In[]: Box and that's where you'd write your code or basically give your input.

Now once you write something inside that box, you need to press the Run button up as you can see on the toolbar. That will execute your code and if it's free from any errors and might give you warning if your code has some possible mistakes. You can always keep an eye out for it and google things you don't understand to get answers on the spot or you can just comment down your troubles and I'd make sure to reply to them.

Now, we will start doing the thing which almost is like a tradition while learning anything new on computer. Let's print our 'Hello World!' statement using python. All the Code snippets that you need to type will be in after the Input: label and the output will be shown after the Output: label. Also, I am showing the line number as Indentation in Python is very very important. That I will be explaining when we explore more ahead. But for now this is how the coding will be so kindly make sure you do it as it is to avoid any errors.

It's not wrong or a crime to make errors, if you make an error and you need to google what it is and try troubleshooting. Also, this website has a copy protection hence you won't be able to copy-paste code snippets directly from here and you'd need to type it, so don't be a lazy bum and type carefully. I will try to keep downloadable notebooks for your reference but in later chapters, for today's chapter there is not need for it.

To print the statement as it is we use the print keyword and the sentence needed to print is written in double quotations enclosed within the parentheses.

Code 1
Input : 
1. print ("Hello World!")

Output : 

Hello World!

Code 2
Input :
1. print (2+3)
2. print (2-1)
3. print (10-2*3)

Output :

You can write anything inside the quotations and it'll be printing it as it is. You need to click the run button to execute your code and the output will be shown below it. You can enable the line numbers by going in options as well so it makes it little bit clear to you while coding ahead. This is a sort of tiny chapter as I want you to explore the UI and print some statements of your own and see what errors do you encounter and if it works as you intended it to.

In Next chapter we will learn more about Variables, its data types, its scopes, basic algebra using variables.



This series is totally authored by me (Dhawal Joshi). Any similarities found on the text, or codes or anything is purely accidental. All the sources of reference will be mentioned, linked and will be given the proper credits. If I miss anything or there's anything wrong, feel free to comment or send me an email and I'll try to edit it out. I am not a Python expert, I am sharing whatever I have learnt on my own and with a few sources around to refer from which will be mentioned. Also feel free to share this series with others so most can benefit out of it.


Do comment and share your thoughts about it! I'd love to know what do you think. Also, I'd keep updating it quite often so do follow the Website to get all the updates by clicking here.

Also, a minor headsup.... Obsessed is free to read on Kindle Unlimited! Do check it out. I'd be glad to read your reviews!
Share :

Are you getting regular fresh content updates? If not click on the button below.


Post a Comment

Do comment and share your thoughts.