标签:表示 one add 多行注释 put coding app 初识 xxx
1.初识python
print("hello haha")
2.注释
#-*- coding:utf-8 -*-【常用】
‘‘‘#coding=utf-8‘‘‘
注意:
①#号是一个单行注释,提醒的内容不能换行,如果换了行,那么,需要在新的一行的行首添加一个#
②#多行注释
"""
print("hello world")
print("hello world")
"""
3.变量
applePrice = 3.5 #定义变量,变量名为applePrice,存储值为3.5
weight = 7.5
注意:
money = applePrice * weight #如果money=xxxx是第一次的话,那么就表示定义了一个变量
money = money - 10 #如果 money=xxxx不是第一次出现,那么就不是定义变量,而是变量赋值
4.用户主动输入
high = input("请输入你的身高:")
5.打印
print("hello world")
age = 18
print("age变量里的值是%d",%age)
name = "东哥"
print("名字是:%s",%name)
6.if-else判断
age = input("请输入你的年龄:") #input获取的所有数据,都当做 字符串类型 20--->age-->"20"
age_num = int(age) #----->整形,,,,去除了双引号之后的值 20
#if 如果年龄大于18:
if age_num>18:
print("已成年,可以去网吧嗨皮.....")
else:
print("未成年,回家写作业吧......")
7.输出
①:输出多个
#1. 使用input获取必要的信息
name = input("请输入名字:")
QQ = input("请输入QQ:")
#2. 使用print来打印名片
print("="*50)
print("姓名:%s"%name)
print("QQ:%s"%QQ)
print("="*50)
②:一次性输出多个
name = "laowang"
age = 20
addr = "山东....."
print("姓名是:%s, 年龄是:%d,地址是:%s"%(name, age, addr))
标签:表示 one add 多行注释 put coding app 初识 xxx
原文地址:https://www.cnblogs.com/loser1949/p/9193685.html