Essential Programming | Control Structures

栏目: IT技术 · 发布时间: 4年前

内容简介:If you want to start programming, I must admit that the outlook is not good: different operating systems, so many programming languages, and endless ways of reaching the same results. These are the type of situations that will make you either run away (as

The backbone of programs

Essential Programming | Control Structures

If you want to start programming, I must admit that the outlook is not good: different operating systems, so many programming languages, and endless ways of reaching the same results. These are the type of situations that will make you either run away (as fast and as far as you can, hoping you’ll never bump into programming again), or face the beast. If you decide to face it, then you won’t know where to start from, or how to handle it. You’ll only have questions and probably not even one answer, but you know what? This is a great way to start. Actually this is how I started programming. I believed that if I ever wanted to understand programs I had to answer the question of:

How do programs work, and how can you build them?

Certainly not a simple issue, but come on, harder questions have been answered, right? Take a look at Marvin Minsky. Minsky, who is considered one of the fathers of AI, wrote “The Society of Mind” to answer one of the most difficult questions of our time: what is the human mind, and how does it work? With a revolutionary perspective, Minsky suggested that our minds consist of the aggregation of small-minds (or more basic components) that have evolved to perform highly specific tasks. According to him, most of these tiny-minds lack the attributes we think of as intelligence and are severely limited, and can only reach feelings, thoughts or purposeful action through the interaction with other components.

This idea contains a powerful concept: complex matters can be thought as groups of simpler subjects, that can also be partitioned into more basic things, until you reach a proper understanding. If you think about it this way, any efficient system can be explained as a set of simpler functions that when put together perform in a way that reach superior results in comparison to their individual performances.

For this reason, if I wanted to understand computer programs (and learn how to make them) I needed to understand their building blocks. You see, when a program runs, the code is read by the computer line by line (from top to bottom, and from left to right), just like you would read a book. At some point, the program may reach a situation where it needs to make a decision such as jump to a different part of the program or re-run a certain piece again. These decisions that affect the flow of the program’s code are known as a Control Structures.

Control Structures can be considered as the building blocks of computer programs. They are commands that enable a program to “take decisions”, following one path or another. A program is usually not limited to a linear sequence of instructions since during its process it may bifurcate, repeat code or bypass sections. Control Structures are the blocks that analyze variables and choose directions in which to go based on given parameters.

The basic Control Structures in programming languages are:

  • Conditionals (or Selection): which are used to execute one or more statements if a condition is met.
  • Loops (or Iteration): which purpose is to repeat a statement a certain number of times or while a condition is fulfilled.

Now let’s take a look at each one of these concepts. Down below we will deep dive using R programming language (one of the mostly used languages for data science), but the same ideas and explanations apply to any other programming language.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

scikit learn机器学习

scikit learn机器学习

黄永昌 / 机械工业出版社 / 2018-3-1 / CNY 59.00

本书通过通俗易懂的语言、丰富的图示和生动的实例,拨开了笼罩在机器学习上方复杂的数学“乌云”,让读者以较低的代价和门槛轻松入门机器学习。本书共分为11章,主要介绍了在Python环境下学习scikit-learn机器学习框架的相关知识。本书涵盖的主要内容有机器学习概述、Python机器学习软件包、机器学习理论基础、k-近邻算法、线性回归算法、逻辑回归算法、决策树、支持向量机、朴素贝叶斯算法、PCA ......一起来看看 《scikit learn机器学习》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具