《Python编程从入门到实践》1-2

第1-2章
这是B站UP主Master_lisa对书本进行讲解的视频链接

#2.1————运行hello world
print("Hello Python world!")


#2.2————变量
message = "Hello python world!"
print(message)
message = "Hello python world!"
print(message)
message = "Hello python Crash Course world!"
print(message)
message = "Hello"
print(messag)


#2.3.1————使用方法修改字符串的大小写
name = "ada lovelace"
print(name.title())#首字母大写
print(name.upper())#全部字母大写
name="ADA LOVELACE"
print(name.lower())#全部字母小写
#2.3.2————在字符串中使用变量
first_name = "ada"
last_name = "lovelace"
full_name = first_name + ""+ last_name
print(full_name)
#2.3.3————使用制表符或换行符来添加空白
print("Python")
print("\tPython")
print("Python")
print("\nPython")
print("Languages:\n\tPython\n\tC\n\tJavaScript")
#2.3.4————删除空白
favorite_language = ' python '
print(favorite_language.rstrip())
print(favorite_language.lstrip())
print(favorite_language.strip())
#2.3.5————使用字符串时避免语法错误
#message = 'One of Python's streangths is its diverse community.'
#print(message)
message = "One of Python's streangths is its diverse community."
print(message)


#2.4————数
x, y, z = 0, 1, 2
print(x,y,z)
#2.4.6常量一般用大写字母定义
MAX_CONNECTIONS=5000
print(MAX_CONNECTIONS)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值