【Python】学习笔记1

# # python 第一天笔记


# #一、概要
# 编译型语言
# 代码在编译之后,编译成2进制的文件,然后计算机就可用运行了。
# c、c + +、c #
# 解释型语言
# 它是在运行的时候才编译的。
# python、php、shell、ruby、js、java
# print('hello world!')
# 脚本语言
# 指这个语言只有一个单一的功能。
# shell、js、
# 数据挖掘(爬虫)、数据分析、自动化运维、自动化测试、后台服务接口、ai、人工智能、嵌入式、web开发



# # 二、注释
# print("Hello Word!")
# # 快捷键注释ctry+/
# # 字符串里面有单引号,外面就用双引号
# # 字符画里面有双引号,外面就用单引号
# # 里面既有单引又有双引,外面用三个引号
# # 三个引号也有多行注意的作用
# # python2 中文要加utf-8,输入函数是raw
# txz = "Let's Go"
# txz1 = '我是"紫丁香"!'
# txz2 = '''我是"紫丁香"!Let's Go'''
# print (txz,txz1,txz2)
#
#
#
# #
# # 三、输入input
# name = input("请输入你的名字:")
# print("你的名字是:",name)
#
#
#
# # 四、条件判断 if else 注意后面加冒号
# # python通过缩进来判断层级
# username = input("请输入你的用户名:")
# passwd = input("请输入你的密码:")
# if username == "zidingxiang" and passwd == "123456" :
# print("欢迎光临!")
# else:
# print("账户密码不正确!")


# 条件判断分数 == != <= >= < >
# 且用and
# score = int(input("请输入你的分数:"))
# if score < 60 :
# print("不及格")
# elif score >= 60 and score < 80:
# print("及格")
# elif score >= 80 and score <=90:
# print("良好")
# else:
# print("优秀")
#
#
# sex = input("请输入你的性别:")
# if sex =="男" or sex == "女":
# print("正常性别")
# else:
# print("不正常性别")


# 五、循环 迭代 遍历--计数器
#for while
#continue 结束本地循环,跳转到下次循环
# break 结束循环
# # 快速复制一行ctry+D
# count = 0
# while count<10:
# print("sss",count)
# count+=1
# # break
# # continue
# # print("bbbb")
# # else:循环结束后执行
# print('done')


# 循环3次
# while else中的else只有在while不符合条件时才执行
# count = 0
# while count<3:
# username = input("Enter your name:")
# pwd = input("Enter your password:")
# if username == "zidingxiang" and pwd == "123456":
# print("Welcome")
# # continue 会一直执行下去
# break
# else:
# print("The name or the password is wrong!")
# count+=1
# else:
# print("错误次数过多")


#
# 猜数字
# import random
# random_num =random.randint(1,20)
# print(random_num)
# random_num =random.randint(1,20)
# print(random_num)
# count = 0
# while count < 7:
# # while True: # 直到成功才结束
# count+=1
# num = int(input("Enter the num what you want guss:"))
# if num>random_num:
# print("Too big")
# continue # 可以去掉
# elif num <random_num:
# print("Too small")
# continue # 可以去掉
# else:
# print("Congratulation!",random_num)
# break




#六、 不同的输出
# 通过%s字符串,模拟输出,可以输出一个变量,可以输出多个变量
# # %d 整数 %f float类型 %.2f保留2位小数
# for i in range(5):
# username = input("Enter your name:")
# time ="2017-12-17"
# print(username+",Welcome,time is "+time)
# print("%s,welcome,time is %s"%(username,time))
# print(
# '{},welcome,time is {}'.format(username,time)
# )
# print(
# '{name},welcome,time is {date}'.format(name=username, date=time)
# )
原文地址:https://www.cnblogs.com/amengmeng/p/8094608.html