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

网友投稿 601 2022-05-29

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.

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

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.

+: 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.

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.

Relation1: Teacher -- Student (many-to-many) Relation2: Master - Desciple (many-to-many) What's the difference between these two relations?

老师教学生——师父带徒弟。

教——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, >)

the second result: number1 == number2 (number1 is less than number2, <)

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

How can we make the "" display on the page?

OK, we have to use > to replace ">" and < 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.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:jdk与jre的区别
下一篇:游戏开服、抢购高峰等场景下,一款好的数据库会如何应对?
相关文章