误删代码

#双色球程度未升级版
'''red = []
blue = []
while len(red) < 6:
user_red = input('红色球数字:')
if user_red.isdigit(): #判断输入的数字是否为整数
user_red = int(user_red)
else:
print('请输入数字')
if 0 < user_red < 33 and user_red not in red:
red.append(user_red)
else:
print('请输入正确数字')
while len(blue) < 2:
user_blue = input('蓝色球数字:')
if user_blue.isdigit():
user_blue = int(user_blue)
else:
print('请数字数字')
if 0 < user_blue < 17 and user_blue not in blue:
blue.append(user_blue)
else:
print('请输入正确数字')
else:
print('选择的红色球数字:',red,'\n''选择的蓝色球数字:',blue)'''




#升级双色球升级版 一个while循环
red = []
blue = []
while True:
if len(red) < 6:
user_red = input('红色球数字:')
if user_red.isdigit():
user_red = int(user_red)
else:
print('请输入数字')
if 0 < user_red < 33 and user_red not in red:
red.append(user_red)
else:
print('请输入正确数字')
if len(red) == 6:
user_blue = input('蓝色球数字:')
if user_blue.isdigit():
user_blue = int(user_blue)
else:
print('请输入数字')
if 0 < user_blue < 17 and user_blue not in blue:
blue.append(user_blue)
else:
print('请输入正确数字')
if len(blue) == 2:
break
print('红色球数字:',red,'\n''蓝色球数字:',blue)









创建文件
# f = open(file = '创建文件.txt',mode='w')
# f.write('xifeng it 4000\n')
# f.write('qiangzi it 2000\n')
# f.close()

f = open(file = '双色球程序.py',mode = 'r')
# print(f.readline())#只读取一行
data = f.read()#读所有,或者剩下的所有
print(data)
f.close()


# f = open(file='创建文件.txt',mode= 'a')
# f.write('longzong ceo 100000\n')
# f.close()
xifeng it 4000
qiangzi it 2000
longzong ceo 100000
longzong ceo 100000


Day3
# names = ['qiangzi', 'shaohua', 'xifeng', 'egon', 'alex', 'seven', 'yuan']
# print(names)
# names.reverse() #翻转 列表顺序倒序
# print(names)


# names = input('Your name:')
# age = input('Your age:')
# salary = int(input('Your salary:'))
# person = {'names':names,
# 'age':age,
# 'salary':salary
# }
# # print(person)
# person.setdefault('job','it')
# print(person)



第一章练习
#用户输入用户名为seven密码为123时显示登陆成功,否则失败
'''username = "seven"
password = "123"
_username = input("username:")
_password = input("password:")
if _username == username and _password == password:
print("登陆成功!")
else:
print("登录失败!")'''



#用户输入用户名为seven密码为123时显示登陆成功,否则失败。失败后允许重复三次
'''username = "seven"
password = "123"
count = 0
while count < 3:
_username = input("username:")
_password = input("password:")
if _username == username and _password == password:
print("登陆成功!")
break
else:
print("登录失败!")
count += 1
if count == 3:
key = input("do you want to mang times?")
if key != "n":
count = 0
else:
exit()'''



#用户输入用户名为seven或alex密码为123时显示登陆成功,否则失败。失败后允许重复三次
'''username = ['seven','alex']#列表
password = "123"
count = 0
while count < 3:
_username = input("username:")
_password = input("password:")
if _username in username and _password == password:#in表示在不在列表里
print("登陆成功!")
break
else:
print("登录失败!")
count += 1
if count == 3:
countine = input("do you want to mang times?")
if countine != "n":
count = 0
else:
exit()'''



#用while循环实现2-3+4-5+6-7+8...+100的和
#count的存在是为了输出直接为偶数之和减奇数之和。在这种问题解决上 count必为0
'''i = 2
count = 0
while i <= 100:
if i % 2 == 0: #如果i是偶数
count += i #count等于 0+i
else: #如果i为奇数
count -= i #count等于 0-i
i += 1 #i=每次循环的次数+1
print(count)


#for循环实现.....
count = 0
i = 2
for i in range(2,101):
if i % 2 ==0:
count += i
# print(i,count)
else:
count -= i
i += 1
print(count)'''



#用while循环输出1,2,3,4,5,7,8,9,11,12,
'''
count = 1
while count <= 12:
if count != 6 and count != 10:
print(count)
count += 1
else:
exit()
'''



#使用while循环实现输出1-100的所有偶数
'''count = 1
while count <= 100:
if count % 2 == 0:
print("偶数是:",count)
count += 1
else:
exit()'''



#使用while循环实现输出1-100内的所有奇数
'''count = 1
while count <= 100:
if count % 2 == 1:
print("奇数是:",count)
count += 1
else:
exit()'''



#用列表输出1-100内的偶数和奇数
'''odd_number = []
even_number = []
count = 1
while count <= 100:
if count % 2 == 0: #and count not in odd_number:
odd_number.append(count)
else:
even_number.append(count)
count += 1
else:
print("偶数是:",odd_number)
print("奇数是:",even_number)'''



#等待用户输入名字、地点、爱好,根据用户的名字和爱好进行任意显示
'''username = input("姓名:")
site = input("地点:")
hobby = input("爱好:")
msg = 三引号
敬爱可爱的%s,最喜欢在%s%s
三引号 %(username,site,hobby)
print(msg)'''



#输入一年份,判断该年份是否为闰年并输出结果(1)能被4整除但不能被100整除(2)能被400整除
'''count = 0
while count < 3:
year = input("请输入任意年份:")
if year.isdigit():
year = int(year)
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print(year, "是闰年")
else:
print(year, "不是闰年")
break
else:
print("请输入正确年份!!")
count += 1
while count == 3:
continue_key = input("do you wang to many times?")
if continue_key != "n" or "N":
count = 0
else:
exit()'''
# if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
# print(year,"是闰年")
# else:
# print(year,"不是闰年")
# def get_year():
# year = int(input("请输入年份:"))
# if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
# print("%s 年是闰年" % year)
# else:
# print("%s 年不是闰年" % year)
# get_year()'''


#计算共需多少年,一万元的一年定期存款连本带息能翻番。
#不是所有循环都要比较输出值,也可以比较其他变量来循环输出输出值。此题比较money实现输出years
'''money = 10000
rate = 0.0325
years = 0
while money <= 20000:
years += 1
money = money*(1+rate)
print(str(years))'''
#抄袭
'''money = 10000
rate = 0.0325
years = 0
while money <= 20000:
years += 1
money = money*(1+rate)
print(str(years),"年")'''



Day1
#name = "Hello world"
name = "你好,世界"
name2 = name
print(name2)
name = "Hello world"
print(name2,name)
name = "qiangzi"
name1 = name
print(name)
posted @ 2020-05-21 13:54  烂泥扶不上墙  阅读(161)  评论(0编辑  收藏  举报