我写的第一期作业

Posted xg120688

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我写的第一期作业相关的知识,希望对你有一定的参考价值。

#!/use/bin/python
# -*- conding:utf-8 -*-

#
# 使用while循环输入1 2 3 4 5 6 8 9 10
# i = 1
# while i < 11:
# if i == 7:
# pass
# else:
# print(i)
# i = i + 1
#
# 求1-100的所有数的和
# i = 1
# value = 0
# while i <= 100:
# value = value + i
# i = i + 1
# print(value)
#
# 输出 1-100 内的所有奇数
# i = 1
# while i < 101:
# if i%2 == 1:
# print(i)
# i = i + 1
#
# 输出 1-100 内的所有偶数
# i = 1
# while i <101:
# if i%2 == 0:
# print(i)
# i +=1

# #求1-2+3-4+5 ... 99的所有数的和
# i = 1
# value = 0
# while i < 100:
# if i%2 == 1:
# value = value + i
# else:
# value = value - i
# i = i + 1
# print(value)


# value = ‘jagkdjklajfklnasdlkgnqwlkj‘
# a = value[0:15:3]
# print(a)

# li = [‘eric‘,‘alex‘,‘tony‘]
# for i ,ele in enumerate(li,100):
# print(i,ele)

# user_tuple = (‘alex‘,‘eric‘,‘tongy‘,[‘张三‘,‘李四‘,‘王五‘])
# user_tuple[3][1] = ‘王丽娟‘
# print(user_tuple)
# li = [‘eric‘, ‘alex‘, ‘tony‘]
# for i in range(0,len(li)):
# print(i+1,li[i])

# for i in range(1,11):
# print(i)


# for i in range(10,0,-1):
# print(i)

# li = (11,)
# print(li)

# ------dict,字典----------

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# dic.clear()
# print(dic)
# v = dic.copy()
# print(v)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# v = dic.get(‘k1‘)
# print(v)
#
# v = dic[0]
# print(v)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# v = dic.pop(‘k1‘)
# print(dic)
# print(v)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# k,v = dic.popitem()
# print(dic)
# print(k,v)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# dic.setdefault(‘k3‘,‘v3‘)
# print(dic)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# dic.update({‘k3‘:‘v3‘,‘k4‘:‘v4‘})
# print(dic)

# dic = {‘k1‘:‘v1‘,‘k2‘:‘v2‘}
# dic.update({‘k1‘:‘v24‘})
# print(dic)


# dic = dict.fromkeys([‘k1‘,‘k2‘,‘k3‘],[1,])
# print(dic)
# dic[‘k1‘] .append(222)
# print(dic)

##额外的功能,字典的k是不可变类型,元组是可以的,字典不能作为字典的key
# dic = {
# ‘k1‘:‘v1‘,
# ‘k2‘:[1,2,3],
# (1,2,):‘1111‘
# }
# print(dic)
#元组可以作为字典的kye

###############set 集合,补课重复的列表 :可变类型#########
# s1 = {"alex",‘eric‘,‘tony‘,‘李泉‘}
# s2 = {‘alex‘,‘eric‘,‘tony‘,‘六一‘}
# s1.difference_update(s2)
# print(s1)
# #
# v = s1.symmetric_difference(s2)
# print(v)
# s1 = {"alex",‘eric‘,‘tony‘,‘李泉‘}
# # s2 = {‘alex‘,‘eric‘,‘tony‘,‘六一‘}
# s1.discard(‘alex‘)
# print(s1)

# s1 = {"alex",‘eric‘,‘tony‘,‘李泉‘}
# s2 = {‘alex‘,‘eric‘,‘tony‘,‘六一‘}
# v = s1.isdisjoint(s2)
# print(v)

############周末作业##########

以上是关于我写的第一期作业的主要内容,如果未能解决你的问题,请参考以下文章

第一周作业

我写的第三个程序(进制转换器)

白话JVM垃圾回收,这是我写的第六篇JVM方面的文章

附加到片段的片段对话框不调用 onYes/No 方法

第二周作业

OO作业总结第二弹