当前位置: 首页 > 编程日记 > 正文

为什么您不需要精通数学就可以学习编程

by Pau Pavón

通过保罗·帕文(PauPavón)

为什么您不需要精通数学就可以学习编程 (Why you don’t need to excel at math to learn how to program)

This is probably one of the greatest misconceptions I’ve ever heard.

这可能是我听过的最大的误解之一。

If you want to program, you must be good at math. It’s totally fake. Let me explain.

如果要编程,您必须精通数学。 完全是假的。 让我解释。

您无需精通数学即可学习编码 (You don’t need to excel at math to learn to code)

I started coding when I was 12 years old. The math I knew was addition, subtraction, multiplication, and division. And it was more than enough to get me into the programming world. Even today, I don’t use anything more complex than powers or square roots.

我12岁开始学习编码。 我知道的数学是加法,减法,乘法和除法。 这足以让我进入编程世界。 即使在今天,我也不会使用除幂或平方根之外的任何复杂事物。

If you have ever programmed any line of code, you have hopefully realized it has almost nothing to do with math. If you know how to count, you are pretty much good to go.

如果您曾经编写过任何代码行,您都有望意识到它几乎与数学无关。 如果您知道该如何计数,那么您的工作就非常好。

神话的起源 (The origin of the myth)

I believe I’ve figured out where this ‘myth’ comes from. You know those old (or not so old) movies about hackers and programmers. They often show computers with lots of 0s and 1s in a greenish font, flowing vertically along the screen? That’s binary code (and it doesn’t normally move around the screen, it’s just static text).

我相信我已经弄清楚了这个“神话”的来历。 您知道那些关于黑客和程序员的古老(或不太古老)电影。 它们经常以绿色字体向计算机显示大量0和1,它们沿着屏幕垂直流动吗? 那是二进制代码(并且通常不会在屏幕上四处移动,而只是静态文本)。

Computers understand binary code, but that’s not what programming languages are about. It may sound quite obvious, because if you are reading this you probably have some kind of relationship with this world. But you’d be amazed to see how many people think it’s all about binary.

计算机可以理解二进制代码,但这不是编程语言的目的。 这听起来似乎很明显,因为如果您正在阅读本文,您可能与这个世界有某种关系。 但是您会惊讶地看到有这么多人认为二进制全都与二进制有关。

But besides this misconception, I think the other factor is the relation established between the words math and logic. Programming requires logical thinking, and math also does. But golf and basketball both require a ball to be played with, and that doesn’t mean you need to know how to play basketball to take up golf.

但是除了这种误解之外,我认为另一个因素是数学逻辑之间建立的关系。 编程需要逻辑思维,数学也需要逻辑思维。 但是高尔夫和篮球都需要玩球,这并不意味着您需要了解打篮球的方法。

让你相信我刚才说的 (Making you believe what I just said)

Let’s take a proper example. Imagine you want to build a function to print out the multiplication table of a number. So, for input 2, our function will return:

让我们举一个适当的例子。 假设您要构建一个函数来打印数字的乘法表。 因此,对于输入2,我们的函数将返回:

2 x 0 = 0
2 x 0 = 0
2 x 1 = 2
2 x 1 = 2
2 x 2= 4
2 x 2 = 4
2 x 3 = 6
2 x 3 = 6
And up to 2 x 10 = 20
最多2 x 10 = 20

You will see how little math is required to do this (even though we are calculating something ‘mathematical’). For the purpose of this example, we’ll be using JavaScript.

您将看到执行此操作所需的数学运算很少(即使我们正在计算“数学”运算)。 就本示例而言,我们将使用JavaScript。

First, we declare the function. We’ll call it tableOf(n), where n is the number we want to print the table of.

首先,我们声明函数 。 我们将其称为tableOf(n) ,其中n是我们要打印表格的数字。

function tableOf(n) {
//rest of the code
}

Pretty easy for the moment. Now we’ll implement something called a for loop. This is similar to a function except for the fact that, when it reaches the end, it goes back to the beginning until some condition is true

目前非常容易。 现在,我们将实现一个称为for循环的东西 这类似于一个函数,除了以下事实:当到达终点时,它将返回到起点,直到满足某些条件为止

We want to print n times some other value (let’s call it i) until that value reaches 10. We have to also take into account that i should start from 0, as we want n x 0 = 0 to be the first line printed. The code could be as following:

我们要打印n倍于其他值(称为i ),直到该值达到10。我们还必须考虑到应该从0开始,因为我们希望nx 0 = 0是打印的第一行。 代码可能如下:

for(i = 0; i < 11; i++) {
console.log(n, 'x', i, '=', n*i);
}

Let’s review what we just did. We started the for loop with i = 0, meaning that i starts from 0 (as we wanted). Then we say i < 11, meaning that we don’t want to exit the loop until i equals 11 or, in other words, we want the loop to continue if i is less than 11. Then we do i++, which means that we increase the value of i by 1 every time the loop starts again (so it eventually reaches 11 and exits the loop).

让我们回顾一下我们刚刚做了什么。 我们从i = 0开始for循环,这意味着从0开始(如我们所愿)。 然后我们说我<11,这意味着我们不希望退出循环UNT I L i等于11,或者换句话说,我们希望循环继续I F i小于11。然后我们我++,这意味着每次循环再次开始时,我们将o f i的值增加1(因此最终达到11并退出循环)。

Then we just output n (the number we entered), ‘x’ (for the times symbol), i(the number for which n is multiplied by), ‘=’ (for the equals symbol), and finally n*i (the actual operation, n times i).

然后我们只输出n (我们输入的数字),'x'(对于时间符号), i (与n乘以的数字),'='(对于等于符号),最后输出n * i (实际操作, n次i )。

The previous code, combined:

之前的代码结合在一起:

function tableOf(n) {
for(i = 0; i < 11; i++) {
console.log(n, 'x', i, '=', n*i);
}
}
tableOf(2);

And it works. Is this difficult math? The only math we did was increasing i by one (adding), and checking if i was less than 11. For this concrete example, we also multiplied n times i. Wow.

而且有效。 这算难吗? 我们所做的唯一数学运算是将i加1(加),并检查i是否小于11。对于这个具体示例,我们还乘以n乘以i

硬币的另一面 (The other side of the coin)

Learning to code will make you better at math.

学习编码将使您的数学更好。

As I said before, programming requires logical thinking just as math does. While writing your programs, you’ll encounter a lot of problems that need to be solved. Most of the time with logic (but let’s be honest, sometimes trial and error works just fine).

正如我之前所说,编程需要逻辑思维,就像数学一样。 在编写程序时,您会遇到很多需要解决的问题。 大多数时候都使用逻辑(但老实说,有时反复试验就可以了)。

Developing the skills to solve these problems is definitely going to help you with math — not only with the concepts, but with problem-solving. You can extend this to other disciplines as well, such as physics.

开发解决这些问题的技能肯定会帮助您数学—不仅是概念上的问题,还是解决问题的方法。 您也可以将其扩展到其他学科,例如物理。

I hope this article serves to encourage people that want to give coding a try to do it. Trust me, I knew little about math and less about English, and I was still able to learn a lot. Knowledge has no limits.

我希望本文能鼓励想要尝试编码的人们。 相信我,我对数学知之甚少,对英语的了解却很少,而我仍然能够学到很多东西。 知识无止境。

翻译自: https://www.freecodecamp.org/news/why-you-dont-need-to-excel-at-math-to-learn-how-to-program-90f9697f70d9/

相关文章:

Android动态加载jar/dex

http://www.cnblogs.com/over140/archive/2011/11/23/2259367.html 加载jar boolean bool new File("/sdcard/test.jar").exists();DexClassLoader cl new DexClassLoader("/sdcard/test.jar", this.getCacheDir().getAbsolutePath(), null, this.getCla…

使用μJava进行变异体测试

一、环境配置mujava运行的是Java程序&#xff0c;Java的环境配置见EclipseJDK配置那点事。 将下载的mujava相关文件放到一个文件夹&#xff0c;文件夹放到C:\muJava 添加mujava环境变量CLASSPATH&#xff1a; C:\mujava\mujava.jar;C:\mujava\openjava.jar;C:\mujava\junit.jar…

【微信小程序之画布】一:canvas组件

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 此文章主要是对canvas组件的介绍与基本的使用。在组件中绘画了一条固定的直线。 我们先了解一下canvas组件&#xff1a; wxml: <canvas classmyCanvas canvas-id"myCanvas…

JavaScript的“ this”通过成立一个高中乐队来解释

by Kevin Kononenko凯文科诺年科(Kevin Kononenko) JavaScript的“ this”通过成立一个高中乐队来解释 (JavaScript’s “this” Explained By Starting A High School Band) If you have ever been in a band, had a friend that started a band, or seen a corny 80s movie …

Ubuntu 16.04 安装Django

> pip install django1.10.3......或者:> pip3 install django1.10.3&#xff08;我采用&#xff09;......或者:>python3 -m pip install django1.10.3......或者:pip install -i https://pypi.douban.com/simple/ django1.10.3......如果你只安装一个版本的 Python,…

【微信小程序之画布】三:手指触摸绘画椭圆

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 功能&#xff1a;根据手指触摸绘画一个椭圆路径--> 起点为手指开始触摸时的坐标&#xff0c;终点为手指触摸结束时的坐标 效果图&#xff1a; 组件属性的描述在上一节中描述过了&…

ACdream 1099——瑶瑶的第K大——————【快排舍半,输入外挂】

瑶瑶的第K大Time Limit:2000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit Status Practice ACdream 1099Description 一天&#xff0c;萌萌的妹子--瑶瑶(tsyao)很无聊&#xff0c;就来找你玩。可是你们都不知道玩什么。。。尴尬了一阵子&#xff…

开源贡献 计算_如何克服恐惧并为开源做贡献

开源贡献 计算Are you a new developer? Or maybe even just an old-timer who has been in a company for ten years, working on an in-house project, and now you’re thinking, “Hey, I’ve been in my box a long time. What’s new out there?” I have been like th…

Android学习笔记进阶十一图片动画播放(AnimationDrawable)

大家平时见到的最多的可能就是Frame动画了&#xff0c;Android中当然也少不了它。它的使用更加简单&#xff0c;只需要创建一个 AnimationDrawabledF对象来表示Frame动画&#xff0c;然后通过addFrame 方法把每一帧要显示的内容添加进去&#xff0c;并设置播放间隔时间&#xf…

JS 把url的参数解析成对象

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 实现思路&#xff1a;请看log和打印结果 // url参数解析 function getUrlkey(url) {var params {};var urls url.split("?"); console.log(1_分割url:,…

Objective-C代码的文件扩展名

转载于:https://www.cnblogs.com/123qw/p/4375299.html

公司成立两周年感言_对我的副项目成立一周年的一些反思

公司成立两周年感言by Will Abramson威尔艾布拉姆森(Will Abramson) 对我的副项目成立一周年的一些反思 (Some reflections on my side project’s first anniversary) My side project turns one this month. It has been a real learning roller coaster.我的副业这个月变成…

2017.4.18 静态代码分析工具sonarqube+sonar-runner的安装配置及使用

配置成功后的代码分析页面&#xff1a; 可以看到对复杂度、语法使用、重复度等等都做了分析&#xff0c;具体到了每一个方法和每一句代码。 四种使用方式&#xff1a; sonarqube sonar-runnersonarqube mavensonarqube eclipsesonarqube IDE IntelliJ使用方式1 &#xff1a…

c中结构体的4种定义

1、常规的标准方式&#xff1a; 1 #include <stdio.h> 2 3 struct student{ 4 int age; 5 float score; 6 char sex; 7 }; 8 9 int main(int argc, char **argv) 10 { 11 struct student studenta { 12 30, 13 79.5, 14 …

js 时间戳与日期处理集合

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 一&#xff1a;获取当前日期 使用方式&#xff1a;console.log(util.formatTime()) 打印结果&#xff1a;2018/04/24 11:06:45 // 获取当前日期 function formatTime() {var date…

超赞网站推荐_字体(更多)超赞-标志性发明

超赞网站推荐by Pubudu Dodangoda通过Pubudu Dodangoda 字体(更多)超赞-标志性发明 (Font (More) Awesome — an iconic invention) Whether you are building a website, a mobile app, or even a standalone app, there are few things you can never escape. The proper us…

JAVA中的垃圾回收机制以及其在android开发中的作用

http://blog.csdn.net/xieqibao/article/details/6707519 这篇文章概述了JAVA中运行时数据的结构&#xff0c;以及垃圾回收机制的作用。在后半部分&#xff0c;描述了如何检测和定位ANDROID程序是否内存溢出。转载于:https://www.cnblogs.com/u3shadow/p/4379336.html

微信小程序把后台传过来的数组坐标展示在地图上

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 功能实现&#xff1a; 1. 根据后台传递过来的数据&#xff0c;包括地址名字&#xff0c;经纬度坐标等都展示在map组件上&#xff1b; 2. 点击相应地址实现用户当前位置导航至点击的…

Flask-login Question

1 未登录访问鉴权页面如何处理&#xff1f; 如果未登录访问了一个作了 login_required 限制的 view&#xff0c;那么 Flask-Login 会默认 flash一条消息&#xff0c;并且将重定向到login_view&#xff0c;如果你没有指定login_view&#xff0c;那么 Flask-Login 将会抛出一个 4…

愉快的舞会c++_如何在5分钟内建立一个令人愉快的加载屏幕

愉快的舞会cFirst, here is what we will build. Set your timer!首先&#xff0c;这是我们将要建立的。 设置您的计时器&#xff01; Does this look familiar?这看起来很熟悉吗&#xff1f; If yes, that’s because you’ve seen this somewhere — Slack!如果是&#xf…

有关C/C++中,表达式计算顺序的问题,以及表达式内部变量“副作用”问题(转)...

经常可以在一些讨论组里看到下面的提问&#xff1a;“谁知道下面C语句给n赋什么值&#xff1f;”m 1; n mm;最近有位不相识的朋友发email给我&#xff0c;问为什么在某个C系统里&#xff0c;下面表达式打印出两个4&#xff0c;而不是4和5&#xff1a;a 4; cout << a &…

HDU 3001

题目中说明每个城市至少要走一次&#xff0c;至多走2次&#xff0c;因此要用到三进制压缩&#xff0c;然后就是状态转移方程了。 这道题就处理三进制的地方麻烦一点。同时注意&#xff0c;在选择最小长度时&#xff0c;一定是要每一个点都经过至少一次的&#xff0c;即是状态的…

微信小程序 侧滑效果实现

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 先看效果图&#xff1a; 源码&#xff1a; <view wx:if{{if_show}} class{{show_centent?"show":"hide"}} /> <button bindtapbtn>展示 or 隐藏&l…

im和音视频开发哪个更好_如何阅读成为更好的开发者的方式

im和音视频开发哪个更好by nolan grace通过诺兰格雷斯 如何阅读成为更好的开发者的方式 (How to read your way to becoming a better developer) If you want to get better at programming, there are two things you need to do:如果您想提高编程水平&#xff0c;则需要做两…

MVC3学习 四 EF删除操作

由于EF的框架是4.1的&#xff0c;所以现在如果想更新部分字段的话&#xff0c;只能从数据库中查出一次数据&#xff08;不用查的方法还没找到&#xff0c;需要继续研究&#xff09;&#xff0c;不能像5.1的版本可以不用查。 更新的Action需要用到[HttpGet]和[HttpPost]&#xf…

ThinkPHP5.0中Redis的使用和封装(原创)

Redis是一种常用的非关系型数据库,主要用作数据缓存,数据保存形式为key-value,键值相互映射.它的数据存储跟MySQL不同,它数据存储在内存之中,所以数据读取相对而言很快,用来做高并发非常不错. ThinkPhP5.0自带了Redis扩展,在使用之前先下载php_redis.dll 网址 http://windows.p…

【微信小程序之画布】四:手指触摸绘波浪线

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 正文&#xff1a; 功能&#xff1a;根据手指触摸绘画一条直线路径--> 起点为手指开始触摸时的坐标&#xff0c;终点为手指触摸结束时的坐标 效果图&#xff1a; 上代码&#xff1a; <canvas clas…

saas的计费数据库设计_如何构建和扩展SaaS计费解决方案

saas的计费数据库设计您需要的最低可行产品 (What you need for a Minimum Viable Product) When you are building your Software as a Service (Saas) Minimum Viable Product (MVP), there is a lot of work that needs to be done. It can be difficult to balance this wo…

关于一对多,多对多的多表查询的控制

一、一对多 以班级Classes和学生Student为例&#xff1a;回忆sql语句://内链接,两种方式效果一样,查询的是两边都有的数据SELECT c.*,s.* FROM classes c,student s WHERE s.cidc.cid;SELECT c.cname,s.sname FROM classes c INNER JOIN student s ON s.cidc.cid;//左外连接&am…

JavaScript对象,方括号和算法

by Dmitri Grabov德米特里格拉波夫(Dmitri Grabov) JavaScript对象&#xff0c;方括号和算法 (JavaScript Objects, Square Brackets and Algorithms) One of the most powerful aspects of JavaScript is being able to dynamically refer to properties of objects. In this…