• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
默默学习的凯同学
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2019年6月3日

#用户登陆(三次输错机会)且每次误时显示剩余错误次数(提示:使用字符串格式化)
摘要: #用户登陆(三次输错机会)且每次误时显示剩余错误次数(提示:使⽤字符串格式化) # i = 3 # username = "yangxiaoer" # password = "123456" # while i>=0: # name = input("请输入你的用户名:") # if name == username: # passwd = input("请输入你... 阅读全文
posted @ 2019-06-03 16:42 默默学习的凯同学 阅读(606) 评论(0) 推荐(0)
 
计算 1 - 2 + 3 ... -99 中除了88意外所有数的总和
摘要: # #计算 1 - 2 + 3 ... + 99 中除了88以外所有数的总和 # 1-2+3.。。,。+99 # i=1 # sum=0 # while i <100: # if i==88: # i += 1 # continue # elif i%2!=0: # sum=sum+i # else: # s... 阅读全文
posted @ 2019-06-03 16:04 默默学习的凯同学 阅读(927) 评论(0) 推荐(0)
 
逻辑运算
摘要: #and or not #优先级,()> not > and > or #print(2 > 1 and 1 1 and 1 6 or 2 4 or 42) # T # print(2 > 1 and 3 5 and 2 2 and 3 5 and 2 > 1 or 9 1 and 3 5 and 2 > 1 and 9 > 8 or 7 1 and 3 5 and 2 > ... 阅读全文
posted @ 2019-06-03 15:43 默默学习的凯同学 阅读(143) 评论(0) 推荐(0)
 
求1-2+3-4+5 ... 99的所有数的和
摘要: 求1-2+3-4+5 ... 99的所有数的和 # sum = 0 # count = 1 # while count < 100: # if count % 2 == 0: # sum = sum - count # else: # sum = sum + count # count += 1 # print(sum) # sum=0... 阅读全文
posted @ 2019-06-03 15:17 默默学习的凯同学 阅读(465) 评论(0) 推荐(0)
 
输出 1-100 内的所有奇数
摘要: #3、输出 1-100 内的所有奇数 #方法一: # count = 1 # while count < 101: # print(count) # count += 2 #方法二: # count = 1 # while count < 101: # if count % 2 == 1: # print(count) # count += 1 ... 阅读全文
posted @ 2019-06-03 15:13 默默学习的凯同学 阅读(1625) 评论(0) 推荐(0)
 
使用while循环输入 1 2 3 4 5 6 8 9 10
摘要: #使用while循环输入 1 2 3 4 5 6 8 9 10 count = 0 while count < 10: count += 1 # count = count + 1 if count == 7: print(' ') else: print(count) count = 0 while count < 10: ... 阅读全文
posted @ 2019-06-03 15:07 默默学习的凯同学 阅读(767) 评论(0) 推荐(0)
 
奇偶索引
摘要: content=0 s = input('请输入') for i in range(len(s)): if i%2==1 and s[i].isdigit(): content=content+1 print(content) 阅读全文
posted @ 2019-06-03 11:10 默默学习的凯同学 阅读(136) 评论(0) 推荐(0)
 
去空格
摘要: i='7 ' print(int(i))#int默认去空 s=' dsadadadfdfgd ' print(s.strip()) 阅读全文
posted @ 2019-06-03 11:04 默默学习的凯同学 阅读(101) 评论(0) 推荐(0)
 
列表小练习
摘要: li=[11,22,33,44,55,77,88,99,90] result={} for row in li: if row > 66: if 'key1' not in result: result['key1']=[] result['key1'].append(row) else: if 'key2'... 阅读全文
posted @ 2019-06-03 11:03 默默学习的凯同学 阅读(135) 评论(0) 推荐(0)
 
列表字典习题练习
摘要: #用户名时输入Q或q退出程序,在Hr输入用户名时,检测此用户名是否有board里面的非法字符,如果有,则将非法字符替换为同数量的*,然后添加到user_list中,如果没有非法字符,则直接添加,每次添加成功后,打印出刚添加的用户名,密码。 user_list=[ {'username':'barry','password':'1234'}, {'username':'alex'... 阅读全文
posted @ 2019-06-03 10:57 默默学习的凯同学 阅读(152) 评论(0) 推荐(0)
 
列表转字典
摘要: 1、现在有两个列表,list1 = ['key1','key2','key3']和list2 = ['4','5','6'],把他们转为字典:{'key1':'4','key2':'5','key3':'6'} list1 = ['key1','key2','key3'] list2 = ['4','5','6' 阅读全文
posted @ 2019-06-03 10:49 默默学习的凯同学 阅读(156) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3