700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python初体验-hello world答案_2.跟老韩学Python之hello初体验

python初体验-hello world答案_2.跟老韩学Python之hello初体验

时间:2024-01-19 00:10:21

相关推荐

python初体验-hello world答案_2.跟老韩学Python之hello初体验

学习编程需要多加练习,敲代码,下面开始我们的Python学习之旅。

1.第一行代码

[root@zabbix_server ~]# ipython

Python 3.6.8 (default, Apr 25 , 21:02:35)

Type 'copyright', 'credits' or 'license' for more information

IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: print("hello,world")

hello,world

上述代码表示进入ipython的交互式开发环境。

2.代码扩展

print函数除了可以输出字符串之外,还可以输出变量、整数运算结果、布尔运算结果,代码如下所示。

In [2]: str_1 = 'hello,world'

In [3]: print(str_1)

hello,world

In [4]: str_1

Out[4]: 'hello,world'

In [5]: print(1 + 1)

2

In [6]: print(True)

True

In [7]: print(True + False)

1

上述代码分别定义了变量str_1、并使用print函数打印该变量,接着使用print打印输出1 + 1的整数运算结果,然后使用print函数打印出布尔True的值,最后使用print函数输出布尔True 和False的整数加运算结果。

总结:先对Python有最基础的了解,然后上手练习,逐渐精进。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。