hm_01_hello.py
print("hello Python")
print("您好世界")
hm_02_第2个Python程序.py
#这是第一个单行注释内容
print("hello")
hm_03_注释.py
# 这是第一个单行注释
print("hello")
# 这是第二个单行注释内容
print("hello world") # 输出欢迎信息
'''
这是一个多行注释
在多行注释之间,可以写出很多很多的内容
'''
print("hello python")
hm_04_qq号码.py
# 定义一个变量记录QQ号码并且输出 qq_number = "1234567" print(qq_number) #顶一个变量记录QQ密码并且输出 qq_password = "123" print(qq_password)
hm_05_超市买苹果.py
# 定义苹果的单价 price = 8.5 # 定义苹果的重量 weight = 7.5 # 计算付款金额 money = weight * price # print(money) # 返5元 money = money -5 print(money)
hm_06_个人信息.py
''' 姓名:小明 年龄:18 岁 性别:是男生 身高:1.75 米 体重:75.0 公斤 ''' name = "小明" age = 18 gender = True height = 1.75 weight = 75.0 print(weight)
hm_07_买苹果增强版.py
"""
收银员输入 苹果的价格,单位:元/斤
收银员输入 用户购买苹果的重量,单位:斤
计算并且 输出 付款金额
"""
price_str = input("请输入苹果的价格:")
weight_str = input("请输入苹果的重量:")
price = float(price_str)
weight = float(price_str)
money = price * weight
print(money)
hm_08_买苹果改进.py
price = float(input("请输入苹果的价格:"))
weight = float(input("请输入苹果的重量:"))
money = price * weight
print(money)
hm_09_格式化输出.py
# 定义字符串变量 name,输出 我的名字叫 小明,请多多关照!
name = "小明a"
print("我的名字叫 %s,请多多关照!" %name)
# 定义整数变量 student_no,输出 我的学号是 000001
student_no = 1
print("我的学号是 %06d" % student_no)
# 定义小数 price、weight、money,
# 输出 苹果单价 9.00 元/斤,购买了 5.00 斤,需要支付 45.00 元
price = 9.00
weight = 5.00
money = price * weight
print("苹果单价 %.2f 元/斤,购买了 %.2f 斤,需要支付 %.2f 元" % (price,weight,money))
# 定义一个小数 scale,输出 数据比例是 10.00%
# scale =float(input("请输入一个小数:"))
# print("数据比例是 %.2f%%" % (scale * 100))
scale = 0.1
print("数据比例是 %.2f%%" % (scale * 100))
# 课后练习 —— 个人名片
# 在控制台依次提示用户输入:姓名、公司、职位、电话、邮箱
# 按照以下格式输出:
# **************************************************
# 公司名称
#
# 姓名 (职位)
#
# 电话:电话
# 邮箱:邮箱
# **************************************************
name = input("请输入您的姓名:")
company = input("请输入您的公司:")
position = input("请输入您的职位:")
phone = float(input("请输入您的电话:"))
email = input("请输入您的邮箱:")
print("*" * 50)
print(company)
print()
print("姓名: %s(%s)" % (name,position))
print()
print("电话:%d" % phone)
print("邮箱:%s" % email)
print("*" * 50)
MySQL学习笔记