how to program python(basics)

in python •  4 years ago 

This is the article you have been looking for, it goes into how to get started with python.

image.png

First, let's get into operators:

the = and == operators are a bit confusing, but they are curtail. The = operator is used to assign a value to a variable. Like x = 2. While == compares two items, like 1 + 1 == 2. The others are pretty simple, + is addition, - is subtraction, * is multiplication, / is division, ** is exponents. I think we are ready to move onto types!

When covering types, I will skip dictionaries, because they are a bit more complex, going into this, I will need to define immutable, it means unchangeable. First, let's cover the list. A list, indicated by [ "stuff", "more stuff" ] (you can replace the word stuff though) is a, well, list. It contains items, numbers or words, which I will get to later. A tuple is a list, but immutable, and faster. You can turn a list into a tuple using tuple( "name of the list, remove quotation mark" ). Next is an int, it is a round number, a float is a number with a decimal point. A string is anything in " ", and a bool is either True or False. Let's move onto using functions.

A basic function use is function(parameters), or item.funcion(parameters), like:

x = [ ]
x.append("hello world")

Now let's get onto if. If executes the code within it, but only if the parameters are true. like this:

if x == y:
print("hello world")

Now let's get onto the for and while loops. While builds on if, so it will repeat as long as the parameters are true. A for loop runs for a specific amount of runs.

While loop(do not run):

While True:
print("spam")

For loop:

for i in range(0, 100)
print(i)

Now you are ready to start reading the python documentation at https://docs.python.org/3/. hope you found this useful. consider following, Thanks

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!