Learn Programming in Python From Scratch Getting Started

in #science7 years ago (edited)

Everyone can, and should learn programming. This is why I'm doing this posts.

Firstly we need IDE (Integrated Development Environment ), which we will use to write and execute our code. There are many choices, however I've found out Spyder, works best, 'cause it comes with pre-installed libraries.
Visit : https://www.anaconda.com/download/
Choose your OS (Operating System), and download Python 3.6 version.
Installation is standard, nothing special, just like any program, so I'm not including photos.
After Installation, search for Spyder on your computer, start it, and you'll be presented with a screen like this:
screen.png
Start a new project by going Projects>New Project. Give it a name (anything you want).
In project explorer tab, right click on a project folder and select New>Module. Give it a name you like.
In the middle of the screen you have tab, named Editor. This is where you type your code. On the right, you have a console, this is where your code gets executed. To start executing. Press the Play Button. That's all you need to know for now.


After that, we can get started with Python.

Comments:

Comments are essential to programming, as they give perspective, about the code being run. To declare a comment
you start a line with #, and everything you write after it in the line will we ignored by compiler.


Primitive types:

In Python, you have couple of primitive types that are built into language:
Integers (whole numbers), Floats (decimal numbers), Booleans(True or False, used for conditionals), Strings(arrays of characters), Lists(ordered gathering of elements), Sets(unordered gathering of elements), Dictionaries(key-value pairs).
examples of them:
Types.png
Special attention should be given to lists, sets, and dictionaries.
Lists:
Elements of a list can be of any type, you can have even heterogeneous list(in which not all elements have the same type). You can nest lists inside other lists. To access the elements of a list you type the name of the list followed with brackets, and an index of the element needed. (Indices start from 0, meaning the index of the first element is 0). Same goes for strings. You can think of them as deprecated lists of characters.
list indexing.png
Sets:
Elements of a set are unique to the set, it cannot be, that two elements are the same in set. That can happen only with lists. You cannot index a set.
Dictionaries:
Keys of a dictionary are unique, while the values can be same for two different keys. Keys and values can be of any type.


Constants vs. Variables:

Variables as it's name suggests changes over time. More specifically, It's associated Value is being changed during time.
To declare a Variable you start a line with it's name, followed by =, and you give it a value.
Vars.png
Constants in Python do not really exist, after declaring a Variable, you have to watch as to not change it's value.

Conversions:
After giving a variable it's value, obviously you can change it. But not only that, you can change it's type as well:
conversions.png


Operators:

Operators are needed to make the code intuitive and simple. There are math and logical operators
operators.png

That's it for the first post :D

Sort:  

Congratulations @ai-enthusiast! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes received
You published 4 posts in one day

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @ai-enthusiast, this post is the eighth most rewarded post (based on pending payouts) in the last 12 hours written by a Dust account holder (accounts that hold between 0 and 0.01 Mega Vests). The total number of posts by Dust account holders during this period was 3697 and the total pending payments to posts in this category was $500.26. To see the full list of highest paid posts across all accounts categories, click here.

If you do not wish to receive these messages in future, please reply stop to this comment.