Python programming tutorial 1 — (Installing Python, getting user Inputs and running basic programs)

in steemiteducation •  7 years ago  (edited)

Hello everyone! In my last article I announced my new project I will be starting on Steemit, for those of you who missed it, don't worry as there's no problem with that as you can always check it out. In that article I talked about how I intend to run my free Python programming class here on Steemit. To get an overview of my days of lecture, check out my previous post.
$_20 (1).JPG

Installing Python:

Now first of all before we jump into coding, we have to install the language into our computer system. And Python is not different.
To install Python, go to Python.org and download the latest version of Python (python 3.5 as of this writing). It shouldn't be stressful to install !. There's a probability that You may already have Python in your system, but I'll advice you download the latest version, because most of the programs in my proceeding classes won't run well in an older version.

IDLE:

IDLE is a simple integrated development environment (IDE), that comes with Python. It's a platform that allows you to type in your codes and run them. There are many other IDEs for Python that you can use to write your codes e.g Pycharm, Notepad, Notepad++ etc.

Oh! I don't have a laptop, I will start learning to program when I get one! SILLY EXCUSE!

If you don't have a laptop or a desktop computer don't worry as developers out there have made it possible for anyone to code on the go by creating Android IDEs that runs your codes. There are many out there, but I will recommend you try QPYTHON, as that's what I used to start my programming journey, and it's what I'm currently using to practice now that my system is out for repair.

Done installing python? Let's move on. Else drop a comment below and either I or any other programmer in the house will help you out.

Typing things in Python.

Case:

Python is a case sensitive programming language. In Python hello, Hello and HELLO are three different things. I will advice you stick to lowercase as most of pythons statements are in lowercase.

Spaces:

Spaces in Python matters at the beginning of lines and not anywhere else. For example the code below won't work.
IMG_20180402_205847_149.jpg
Python uses indentation of lines for things, i.e paragraphs as been taught I English language. But in programing we don't call it paragraph, instead we call it indentation. Don't worry! We will learn about that soon.

On the other hand, spaces elsewhere don't matter. For instance the programs below prints exactly the same thing.
IMG_20180402_210647_823.jpg

Getting user input:

This “input” function is a simple way for your program to request for data from the users of your program. E.g
IMG_20180402_212000_096.jpg
The basic structure is.
variable name = input("message to user ")
The above only works for getting strings(texts) from users. But if you want to get an integer(number) and use for calculation later in the program, you need to do something extra. Here is an example.
IMG_20180402_212402_249.jpg
Let's examine how the program does what it does. The input function's job is to instruct the user to type in something. The part in quotes is the prompt which the user sees, and it is referred to as a string and it appears to the user exactly as written in the program. The int function is what we use when we are getting an integer i.e a numerical value.

The "name" at the left hand side of the code is called a variable name it can be anything except commands/functions in Python which will be treated soon.

The second line uses the “print” function to print out the output. The part in quotes is another string that appears to the user exactly as it appears in quotes here.

The following program may appear to be too short and simple to be of much use, but there are lots of websites that do similar conversions and their code is not much complicated than this.

Exercises to try:

  1. Ask the user to enter a number, then print out the square of the number.
  2. Write a program that asks the user for a weight in kilograms, then convert it to pounds. There are 22 pounds in a kilogram.

P.S:

Please ensure you try all the codes in this article for a better understanding. And also attempt all the exercises as well. If you are confused or stuck anywhere fell free to comment below and I or any other programmer in the house will give you a hint.

Thanks for reading patiently! I hope you enjoyed it? Please share your class experience with us. And know that your ideas to make this class a success is also appreciated, just feel free 🙂.

My articles that will be of help to you.

  1. My new project in steemit and how I intend to run it
  2. Top 3 reasons why everyone should learn programming
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase https://
3. Type re
Get Featured Instantly & Featured Posts are voted every 2.4hrs
Join the Curation Team Here | Vote Resteemable for Witness

WARNING - The message you received from @muhammadsyahril is a CONFIRMED SCAM!
DO NOT FOLLOW any instruction and DO NOT CLICK on any link in the comment!
For more information, read this post:
https://steemit.com/steemit/@arcange/phishing-site-reported-uppervotes-dot-ml
Please consider to upvote this warning if you find my work to protect you and the platform valuable. Your support is welcome!

Resteemed by @resteembot! Good Luck!
Curious? Read @resteembot's introduction post
Check out the great posts I already resteemed.

ResteemBot's Maker is Looking for Work

Hi @edywill
Excellent article. I subscribed to your blog. I will follow your news.
I will be grateful if you subscribe to my blog @user2627
Good luck to you!