开发基础 - 考核题

# 1. 列表['alex','egon','yuan','wusir','666'](编程)
#
# - 1.把666替换成999
# - 2.获取"yuan"索引
# - 3.假设不知道前面有几个元素,分片得到最后的三个元素
# li[-1] = '999'
# li[li.index('666')] = '999'
# print(li.index('yuan'))
# print(li[-3:])

# 2. 将字符串“www.luffycity.com”给拆分成列表:li=['www','luffycity','com']
# li = "www.luffycity.com"
# li = li.split(".")


# 3. 对字典进行增删改查(编程题)
# dic = {"Development":"开发小哥","OP":"运维小哥","Operate":"运营小仙女","UI":"UI小仙女"}
# dic.pop("Development")
# del dic["Development"]
# print(dic.pop("Development","error"))
# dic["Development"] = "开发小哥"
# Development --> 开发小哥
# for i in dic:
# print("%s---->%s" % (i, dic[i]))

# 4. 计算1+2+3...+98+99+100
# sun = 0
# for i in range(1,101):
# sun += i
# print(sun)


# 5. 制作趣味模板程序(编程题)
#   需求:等待用户输入名字、地点、爱好,根据用户的名字和爱好进行任意现实
# 如:敬爱可爱的xxx,最喜欢在xxx地方干xxx
# while True:
# name = input("name:")
# addr = input("addr:")
# s = """
# 可爱的 %s 喜欢在
# %s 待着
# """ % (name, addr)
# print(s)

# 6.写一个三次认证(编程) 实现用户输入用户名和密码, 当用户名为seven 或alex且密码为123时, 显示登陆成功, 否则登陆失败, 失败时允许重复输入三次

# _name1 = "seven"
# _name2 = "alex"
# _password = "123"
#
# count = 0
#
# while count < 3:
# name = input("name:")
# password = input("password:")
# if name == _name1 or name == _name2 and password == _password:
# print("欢迎登录")
# break
# else:
# print("失败")
# count += 1

# 7. 切割字符串"luffycity"为"luffy","city"(编程)
# s = "luffycity"
# s1 = s[:5]
# s2 = s[-4:]
# print(s1,s2)

# 8. 深浅copy  字符编码

# 9. 有如下字符串:n = "路飞学城"(编程题)
#
# - 将字符串转换成utf-8的字符编码的字节,再将转换的字节重新转换为utf-8的字符编码字符串
# n = "路飞学城"
# print(n.encode("UTF-8").decode("UTF-8"))

# 10. 将列表['alex', 'steven', 'egon'] 中的每一个元素使用 ‘\_’ 连接为一个字符串(编程)
# s = ['alex', 'steven', 'egon']
#
# print("\_".join(s))

# int,字符串,列表, 元组,字典,集合 它们支持的方法,字符编码 练练

posted @ 2018-02-09 12:18  Alice的小屋  阅读(413)  评论(0编辑  收藏  举报