In this post we will learn something useful :).
Before proceeding with it, we need to know our basics (primitive types and the concepts of variables in Python),
if you have to remind yourself consult: https://steemit.com/science/@ai-enthusiast/learn-programming-in-python-from-scratch-getting-started
Learning objectives
- Get familiar with Control Flow (Get to know different types of loops and if-else statements)
- Put it all together, in the example which we'll use later to build upon
Thanks to omarf, who suggested changes :D
Control Flow:
Understanding Control Flow(order in which the commands are executed) is essential to programming. There are just a few ways to change it. However the way they're combined, leads to complex programs that are actually useful :D. Without these ways, order in which commands are executed is from the first line up to the last one.
Operators:
Before we proceed, I must point some other things in Operators. You can also do this:
Now, let's continue:
Loops:
When you have a piece of code you want executed multiple times, instead of copy/pasting the code, which makes it hard to read and prone to error, you would want to use loops. There are two types of loop, FOR loop (which you will use usually when you know in advance what number of iterations(passes through a loop) will be there, and WHILE loop (which will run, until some condition is met). Anything you write inside of a loop is considered it's 'body';
Scope
Make special attention to the indentation. In Python, if you indent something that means it belongs to the outer scope (area in which it is visible).
In other programming languages you wouldn't be able to acces a Variable defined in some other scope (you can, but not directly). In Python you can access it, basically directly.
IF-ELSE:
When you want you your program to have branches, meaning only one branch(path) gets executed, you would use IF-ELSE statements. Statement number == 1 returns a Truth value (True or False). If it returns True the body of the IF gets executed. If it returns False, body of ELSE gets executed.
There's also an ELIF statement, which tests another condition if the condition in IF statement is not met.
Putting it together:
We will write our first complete program. Let's say we're teachers and we want to review our students based on grades.
If they got a good grade, we will encourage them. If they got a bad one, well...
Sucks to be Mya :D
How is this learning from scratch? Control flow, operators, scope are all concepts that need more careful, in-depth explanations. One needs to start with simpler examples as well. Also, in the beginning of the post, you should state what exactly people will learn by the end of the post (the learning objectives). I am not your boss or your teacher, but I am just trying to give you helpful advice here. Hope you don't mind and understand my point.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you are right, applying your advices will make this post really amazing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I understand the point you're making. I'll change the post to include learning objectives. Thanks for your feedback. This is a continuation to the first post. in which I started from the beginning. This is how I was taught, I just like that way. :D
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello @ai-enthusiast! Would you consider being my occasional coach/consultant on Python learning? I'm an experienced programmer; but have not yet learned Python. I recently decided to do so in order to do some 'fishing around' in the Steem block chain and to prepare for another application which I will mention shortly.
I have set up a nice IDE and began following a Udemy course, which is moving too slowly for my taste. So I'm planning to more or less set up my own learning program (perhaps involving converting some of my R-language programs to Python), and for that I will need a coach when I got stuck at certain points.
Unfortunately, I do not have much time for this project because I must give higher priority to learning technical details about the Bancor protocol, and it's code which is Etheruem's Solidity. (I really hate the idea of investing valuable time in learning a language that has only one environment in which it is useful; but I have no choice because only the Bancor protocol is offering the application that is of concern.)
This is the application where you can buy and sell your token in an environment where there is no market maker. According to the SMT Whitepaper, this application is also going to be part of the SMT software, so once that software becomes available I expect I would be getting out of the Ethereum environment and coming over to Steem via Pytthon.
So, let me know if you would be available to help me. I will be happy to negotiate direct payment to you in SBD, BTC, or LTC.
P.S. I am now Following you,so don't quit Steemit just yet!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I messaged you via steemit.chat
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I have have no luck trying to find people at Steemit.chat (they tell me to go there and when I do they are 'not found'). Anyway, I will try once more! Thanks.
PS. Can I invite you to be the first visitor to my brand new Discord Channel ("Smart_Tokens")?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
my id on steemit.chat is ai.enthusiast
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Okay. TTYL!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit