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

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

1.第一行代码

[root@zabbix_server ~]# ipython

Python 3.6.8 (default, Apr 25 2019, 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有最基础的了解,然后上手练习,逐渐精进。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值