学习打卡:Python

今日学习

Python

明天要去奶茶店打工,要早点休息,只贴代码不写具体知识点了就。

  1. MOOC北理老师的一个小案例
#TempConvert.py

TempStr = input(" 请输入带有符号的温度值: ")
if TempStr[-1] in ['F', 'f']:
    C = (eval(TempStr[0 : -1]) - 32) / 1.8
    print(" 转化后的温度是 {:.2f}C".format(C))
elif TempStr[-1] in ['C' , 'c']:
    F = 1.8 * eval(TempStr[0 : -1]) + 32
    print(" 转化后的温度是{:.2f}".format(F))
else:
    print("输入格式错误!")

  1. 课本第二章的一部分样例
    仁川人,集合
# Practice_2.py

message = "Hello Python Programming Languages"
print(message)

# 单引号 和 双引号 都可以表示 字符串
string_1 = "This is a string"
string_2 = 'This is a string, too'
print(string_1)
# 这里直接给我提示string_2 好聪明的pycharm
print(string_2)

# a.title() - 首字母大写 (如果有多个单词,每个单词都首字母大写)
name_title = "the shy"
print(name_title.title())
# The Shy

# a.upper() - 全部大写
name_upper = "the shy"
print(name_upper.upper())
# THE SHY

# a.lower() - 全部小写
name_lower = "THE Shy"
print(name_lower.lower())
# the shy

# 字符串中的空白处理
name = "  Rookie  "
# 1. a.strip() - 去除掉 前后段的空格
test_strip = name.strip()
print(test_strip)
# Rookie

# 2. a.rstrip() - 去除掉 后端的空格
test_rstrip = name.rstrip()
print(test_rstrip)
# /  Rookie

# 3. a.lstrip() - 去除掉 前段的空格
test_lstrip = name.lstrip()
print(test_lstrip)
# Rookie  /

# Python 中的 指数
mathNum = 3 ** 2
print(mathNum)
# 结果是 9

  1. 课本第三章的一些样例,知识点不完全
    翻山队,出发
# Practice_3

# 列表 也就是数组
members = ["Rookie", "The Shy", "Ning", "Jacklove", "Baolan"]
numbers = [1, -3, 5, 22, -99, 10]

# 输出中只写数组名 会连着 括号和引号 输出
print(members)
print(numbers)

# 正常 遍历输出
for a in members:
    print(a)
for b in numbers:
    print(b)

# 输出 列表中某个元素
print(members[1])
print(numbers[3])

# 结合 title()
print(members[1].title())

# Python列表 可以通过 [-1] 来直接访问最后一个元素
print(members[-1])
# Python列表 同样 -1表示倒数第一, -2表示倒数第二 依次类推
print(numbers[-3])

# print 详细输出更多信息
information = "IG的中单是:" + members[0] + ",真名为 宋义进。"
print(information)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值