为了账号安全,请及时绑定邮箱和手机立即绑定
课程 \ Python3 入门教程

Python3 入门教程

4-1 Python之if语句
# Enter a code
age = 19
if age>18:
print('adult')
print(age)
2022-02-03 查看完整代码
3-9 Python的字符串切片
# Enter a code
a='AABCDEFGHHIJ'
print(a[1:9])
print('AABCDEFGHHIJ'[1:9])
2022-02-02 查看完整代码
3-7 Python的字符串format
# Enter a code
tem='Life is short{}you need Python{}'
res=tem.format(',','.')
print(res)
template = 'Hello {}, Hello {}'
result = template.format('World', 'China')
print(result)
template='Life is short,{}you need Python.{}'
res=template.format('','')
print(res)
print('Life is short, you need {}'.format('Python'))
2022-02-02 查看完整代码
3-6 Python中raw字符串与多行字符串
# Enter a code
print(r'''Python is created by "Guido".
It is free and easy to learn.
Let's start learn Python in imooc!''')

print(r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.''')
print('''Line 1
Line 2
Line 3''')
print('''Line 1
Line 2Line 3''')
2022-02-02 查看完整代码
3-5 Python的字符串
# Enter a code
print('Bob said \"I\'m OK\".')

print('special string:\',\",\\,\\\,\\n,\\t')
2022-02-02 查看完整代码
3-4 Python的布尔类型
# Enter a code
a='python'
print('hello,',a or 'world')
b=''
print('hello,',b and 'world')
b=''
print('hello,',b and 0)
2022-02-02 查看完整代码
3-3 Python的整数与浮点数
# Enter a code
a=3.14
b=1.57
c=a*b
print(c)
print(round(c,2))
2022-02-02 查看完整代码
3-2 Python定义变量的方法
# Enter a code
a=1
print(a)
a='abc'
print(a)
2022-02-02 查看完整代码
2-2 第一个Python程序
# coding=utf-8
print('Hello Word')
2022-02-01 查看完整代码
首页上一页123下一页尾页
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号