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

news/2024/7/3 5:02:49

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/


http://lihuaxi.xjx100.cn/news/239601.html

相关文章

计算机教师简介50字,教师风采个人简介50字数.docx

教师个人简介 50 字大全例一&#xff1a;大家好&#xff0c;我叫王力央。今年 12 岁了&#xff0c;我有很多的兴趣比如&#xff1a;跳绳、游泳、看书、写字和玩耍。我 喜欢的东西也很多&#xff1a;水果、蔬菜、大螃蟹、大龙虾。大家要多吃蔬菜少吃油炸食品身体才能强壮、健康。…

yjk只算弹性的不计算弹塑性_基于ANSYS Workbench的表面裂纹计算

一、写在前面本教程使用ANSYS Workbench17.0 进行试件表面裂纹的分析&#xff0c;求应力强度因子。需要提前说明的是&#xff0c;本案例没有工程背景&#xff0c;仅为说明裂纹相的计算方法&#xff0c;因此参数取值比较随意&#xff0c;大量设置都采用了默认值。对于实际工程&a…

Vue.js slots: 为什么你需要它们?

也许你已经看过了Vue.js slots的文档。我对这个功能从“为什么你可能需要它”到“没有它我怎么可能工作”的态度转变非常快。虽然文档已经解释了它的概念&#xff0c;但是这里有一个关于slots怎么改进应用程序代码库的真实例子。在我看来&#xff0c;slots是vue最有用和最有趣的…

【iCore4 双核心板_ARM】例程十七:USB_MSC实验——读/写U盘(大容量存储器)

实验方法&#xff1a; 1、将跳线冒跳至USB_UART,通过Micro USB 线将iCore4 USB-UART接口与电脑相连。 2、打开PUTTY软件。 3、通过读U盘转接线将U盘&#xff08;或者读卡器&#xff09;与iCore4 USB-OTG接口相连。大容量存储器为FAT32格式。 实验现象&#xff1a; 核心代码&…

[附源码]计算机毕业设计springboot抗疫医疗用品销售平台

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

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 …

计算机防火墙不能启动,windows防火墙不能启动错误5

有的用户因为之前的原因关闭了防火墙&#xff0c;又因为某些原因需要打开防火墙&#xff0c;却提示防火墙不能启动&#xff0c;错误代码5。下面让学习啦小编为大家整理一些关于这个问题的解决答案&#xff0c;希望能帮到大家。Windows防火墙不能启动错误5的解决方法&#xff1a…

两个主键怎么设置tsql_索引该怎么创建?

1.2、索引 BTree 结构的特性&#xff1a;①、BTree 只有叶子节点会存储真实的数据&#xff0c;非叶子节点只会存储索引字段值&#xff1b;②、BTree的叶子节点之间使用 双向链表 链接&#xff0c;所以更加适合范围查询和排序&#xff1b;2、索引的类型&#xff1a;在平时创建的…