Python learning by case study@[April] (跟着April用真实案例学Python) Lesson one "PRINT()"

Python learning by case study@[April]
(跟着April用真实案例学Python)

Lesson one 第一讲

Python is one of the most popular programming languages in the world. It is necessary to grasp it before entering the workplace.

Python是世界上最流行的编程语言之一。 在进入职场前大家都有必要掌握这门语言。

The installation of Python
安装Python

https://www.python.org/downloads/

  1. for windows: https://www.python.org/downloads/windows/

  2. for mac:https://www.python.org/downloads/mac-osx/

Online Python IDE, without installation of Python
在线环境,无需安装Python

https://repl.it/languages/python3
Python learning by case study@[April] (跟着April用真实案例学Python) Lesson one IDE:(An Integrated Development Environment)

TODAY’S FOCUS–“PRINT”

今日学习:打印功能

Case1: How to output “1%”?
问题:如何输出“1%”

First, look at the following code, why is it wrong?
首先,看看下面的代码,哪里有问题?
Python learning by case study@[April] (跟着April用真实案例学Python) Lesson one
Python learning by case study@[April] (跟着April用真实案例学Python) Lesson one
Debug: How to solve the problem?
调试:如何解决这个问题?
Python learning by case study@[April] (跟着April用真实案例学Python) Lesson one
correct output
What do we learn from the case1?
从案例1里学到了什么?

The types of these two variables are different, one is int (ggd=1), another is string(per_syb="%"). These two types of variables could not print together. We need to add ‘str()’ to change the int to string.
这个案例里ggd这个变量是整数类型的,而per_syb是字符串类型的,因此输出时不能简单用二者相加输出。而应该加上‘str()’,使得ggd变量也变成字符串,那么就可以二者相加输出了。

unsupport operand types for +: ‘int’ and ‘str’
错误代码:不支持整数类型与字符串类型相加。

So, you have learnt python ‘print()’ and ‘str()’ in today’s lesson. See you next time.
今天,这节课里你学会了用print(),str()。下节课再见啦~
print example 2
在这里插入图片描述

你可能感兴趣的:(python)