python基础
2021-06-23 21:06
标签:分享图片 ide img 优秀 false 技术 划线 continue 条件控制语句 python基础 标签:分享图片 ide img 优秀 false 技术 划线 continue 条件控制语句 原文地址:https://www.cnblogs.com/liuhongshuai/p/9671316.html#第一个python程序
#第一个python程序
# print(‘hello world‘)
# print(‘你好,世界‘)
# print(‘alex‘,‘wusir‘,sep=":")
# print(‘alex‘,end="\t")
# print(‘wusir‘)
# print(‘hello world‘,file=open(‘hello.txt‘,‘w‘,encoding=‘utf-8‘))
#变量的命名规范
#变量的命名规范
# AgeOfAlex=18#驼峰体
# age_of_alex=18#下划线
#查看数据类型type
#查看数据类型type
# print(type(12))
# print(type(‘hello‘))
# print(type([1,2]))
# print(type((1,2,3)))
# print(type({"1":"2"}))
# print(type({‘1‘,2}))
# print(type(True))
# print(type(range))
# def hello():
# print(‘hello‘)
# print(type(hello))
# class Student():
# pass
# a=Student()
# print(type(a))
#引号
#引号
# print(‘I am a student‘)
# print("I‘m a student")
# msg="""
# 会当凌绝顶,
# 一览众山小。
# """
# print(msg)
#用户交互input
#用户交互input
#input得到的是字符串
# name=input(‘请输入你的名字:‘)
# age=input(‘请输入你的年龄:‘)
# print(name,age)
# print(type(name),type(age))
#条件控制语句if elif else
#条件控制语句if elif else
# score=int(input(‘请输入你的成绩:‘))
# if score>90:
# print(‘优秀‘)
# elif score>80:
# print(‘良好‘)
# elif score>70:
# print(‘一般‘)
# elif score>60:
# print(‘及格‘)
# else:
# print(‘不及格‘)
#条件语句的嵌套
# name=input(‘name:‘)
# age=int(input(‘age:‘))
# if name==‘alex‘:
# if age==18:
# print(‘welcome‘)
# else:
# print(‘age error‘)
# else:
# print(‘name error‘)
#循环语句 while for
#循环语句 while for
# count=1
# s=0
# while count
# s+=count
# count+=1
# print(s)
# s=0
# for i in range(1,101):
# s+=i
# print(s)
#break continue else
#break continue else
# count=0
# while count
# count+=1
# if count==3:
# break
# print(count)
# else:
# print(‘循环正常结束后执行‘)
# count=0
# while count
# count+=1
# if count==3:
# continue
# print(count)
# else:
# print(‘循环正常结束后执行‘)
#标志位
#标志位
# flag=True
# count=1
# while flag:
# print(count)
# count+=1
# if count>100:
# flag=False
上一篇:list 去重并保持原来排序