专业英语笔记(Line Feed and Type Conversion)

举报
howard2005 发表于 2021/12/30 00:08:35 2021/12/30
【摘要】 Let's get started.I have some questions for you. 1. What's the difference between need and want?2. Do you think English is useful for your professional learning?The...
Let's get started.

I have some questions for you. 

1. What's the difference between need and want?
2. Do you think English is useful for your
professional learning?

The computer cannot work now, I have to find a
professional (insider) to repair (fix) it.

I have said I will call the roll before class to figure out whether everyone is here. 

Actually it's a problem of descipline. We know that nothing can be done without descipline.

A person without self-descipline has no hope to make progress in his study, life and work.

For example, if you can get up at six and do morning exercise no matter what happens, 

then I can say that you're a person with self-descipline.


No self-descipline, no true progress!


The above is just random talk. But now let's get down to the point.

Start command-line Python.


What will you do If I require you to display two lines of string on the screen using only one print funciton?

We have to use the escape character: '\n'
What does n
 mean in the escape character '\n'?

Here, 'n' stands for "new line". 
We can use the escape character '\n' to move the cursor to the beginning of the next line.

Now we practice it in Python.

Is there any other way to get the same effect?


Actually, we can get the same effect in other programming languages.

(1) VB


(2) Java


(3) VFP


(4) JavaScript


(5) C


Now let's do addition.

Assign 100 to the variable a; (a is an int variable)

Assign 150 to the variable b; (b is an int variable)

Let sum equal a plus b. Or you can say like this:

Assign the result of the expression of a + b to the variable sum.

Print the the value of the variable sum.




This is just like what VB does. Let's have a look.

VB has two ways to solve this probem. Let me demonstrate them for you.



Please take a look at this error:


Tell me what you will do to kill this error. 

If we use this expression in JavaScript, what will happen? Let me give it a try.

No error! Why? JavaSript is a weak-type language, so it will automatically convert integer to string.


<span style="font-family:'Times New Roman';font-size:16px;"><em>+: add, addition, plus 
-: subtract, subraction, minus
×: multiply, multiplication, times
÷: divide, division, divided by

Let's see some explames.

3+2=5  

Daily English: If you add two to three, you will get five.

Math English: Three plus two equals five. / Three plus two is equal to five.

5-3=2

Daily English: If you subtract three from five, you will get two.

Math English: Five minus three equals two. / Five minus three is equal to two.

3×2=6

Daily English: If you multiply three by two, you will get six.

Math English: Three times two equals six. / Three times two is equal to six.

6÷3=2

Daily English: If you divide six by three, you will get two.

Math English: Six divided by three equals two. / Six divided by three is equal to two.</em></span>

We can use type function to get the type of data in Python.


Of course we cannot add an int to a str.  

We have to do the conversion from int to str or from str to int.

Let's take a look at the example.

1. conversion from str to int  -- to do addition


2. conversion from int to str -- to do connection


Actually, VB can do these two conversions.


Can JavaScript do these two conversions?


Open the page in Chrome browser, nothing displays but an error occurs.


The error is that val function is not defined in JavaScript.

Search the Internet and figure out whether there's a built-in JavaScript function to do the conversion from string to integer. 

OK, you have found the function: parseInt(). Let me give it a try.


The webpage looks like this:


We can use the function parseFloat to convert a string to a float number.


Search the Internet, you can find only two functions which start with "parse" in JavaScript: parseInt() and parseFloat().

A student just told me another function Number() that can convert a string to a number. 

The number can either be an integer or a real number. That's great! Let's practice it! 



Now we can conclude from the above practice that the function Number() can replace parseInt() and parseFloat() functionally.

<span style="font-family:'Times New Roman';font-size:16px;"><em>Relation1: Teacher -- Student (many-to-many)
Relation2: Master - Desciple (many-to-many)

What's the difference between these two relations?</em></span>

老师学生——师父徒弟。

教——teach

带——guide, lead

All roads lead to Rome.

There is a good introductory book about Python programming that I want to recommend to you.


Python速成课程

容易上手,基于项目

从入门到实践

Task: Translate the following passage into Chinese.

That's great that the author began to write programs at age of five. 

Task: Translate the following passage into Chinese.

From the above passage, we know the author has a patient father.

This book is divided into two parts: BASICS and PROJECTS. 

There are eleven chapters in the first part and there are three projects in the second part.





After we get to know the structure of this book, we should dive into the book to start the journey of learning Python. 

First let's take a look at the INTRODUCTION of this book.


作者小时候学习编程的条件:一个主板+一个键盘+一个阴极射线管==>简陋的电脑

Let's have a look at the Jobs' APPLE I.



When two numbers are compared, there are three possible results.

the first result: number1 > number2  (number1 is greater than number2, &gt;)

the second result: number1 == number2 (number1 is less than number2, &lt;)

the third result: number1 < number2 (number1 is equal to nubmer2)


How can we make the "<Space War>" display on the page? 

OK, we have to use &gt; to replace ">" and &lt; to replace "<".


Relational operators will be used when two numbers are compared.

There are six relational operators in Python: ==、!=、>、>=、<、<=

==:  equal to

!=: not equal to

>: greater than

>=: greater than or equal to

<: less than

<=: less than or equal to


Next time, we will try to write the number-guessing game.

文章来源: howard2005.blog.csdn.net,作者:howard2005,版权归原作者所有,如需转载,请联系作者。

原文链接:howard2005.blog.csdn.net/article/details/79562703

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。