【个人使用】

# Time: 2021/9/25 10:23
# Actor: WRT
# Name: demo1_lesson
'''

a = int(input("请输入你想要的乘法表的阶数(99乘法表为9阶):"))
for i in range(1, a+1):
    for j in range(1, i+1):
        print('%d×%d=%2d\t' % (j, i, i*j), end='')
    print()
'''
'''
from turtle import *

a = 100*3
b = 61.8*3

up()
goto(-150, 50)
down()

for i in range(5):
    forward(a)
    right(144)
left(36)
for i in range(5):
    forward(b)
    right(72)

done()




'''
'''
tel = {"Tom": "1888888888",
       "Jake": "133333333"}
key_list = tel.keys()
print(tel["Jake"])
for i in key_list:
    if i == 'Jake':
        print(i)
'''
'''
tel = [("Tom", "1888888888"),
       ("Jake", "133333333")]

print(tel)
telDict = dict(tel)

print(telDict)
print(telDict["Tom"])


student = dict(name="Tom", age=28)
print(student)
print(student["age"])

'''
'''
list_1 = []
while True:
    print('-' * 20)
    print('欢迎使用通讯录:\n1.添加联系人\n2.查看通讯录\n3.删除联系人\n4.修改联系人信息\n5.查找联系人\n6.退出')
    print('-' * 20)
    option = int(input('请输入你的选项:'))
    if option == 1:
        list_2 = {}
        name = input('请输入联系人的名字:')
        Telephone = input('请输入电话号码:')
        mailbox=input('请输入邮箱:')
        address = input('请输入住址:')
        list_2['name'] = name
        list_2['Telephone'] = Telephone
        list_2['mailbox'] = mailbox
        list_2['address'] = address
        list_1.append(list_2)
        print('添加成功')
    elif option == 2:
        for i in list_1:
            print(f'姓名:{i["name"]}\n电话号码:{i["Telephone"]}\n邮箱:{i["mailbox"]}\n住址:{i["address"]}  ')
    elif option == 3:
        name1 = input('请输入你要删除的联系人:')
        for j in list_1:
            if j['name'] == name1:
                list_1.remove(j)
                print('删除完成')
    elif option == 4:
        name2 = input('请输入你要修改联系人的姓名:')
        for k in list_1:
            if k['name'] == name2:
                new_name = input('请输入新的姓名:')
                new_Telephone = input('请输入新的电话号码:')
                new_mailbox = input('请输入新的邮箱:')
                new_address = input('请输入新的住址:')
                k['name'] = new_name
                k['Telephone'] = new_Telephone
                k['mailbox'] = new_mailbox
                k['address'] = new_address
                print('修改成功')
    elif option == 5:
        name3 = input('请输入你要查找的联系人姓名:')
        for l in list_1:
            if l['name'] == name3:
                print(f'姓名:{l["name"]}\n电话号码:{l["Telephone"]}\n邮箱:{l["mailbox"]}\n住址:{l["address"]}  ')
    elif option == 6:
        print("退出成功")
        break
    else:
        print('当前没有该选项,请重新输入')
'''
'''
# python最新作业
from math import sqrt
a = int(input("请输入系数a:"))
b = int(input("请输入系数b:"))
c = int(input("请输入系数c:"))
value = -b/(2*a)
value1, value2 = 0, 0
delta = b*b-4*a*c
if delta < 0:
    print("方程没有实根!")
elif delta == 0:
    print("方程有两个相等的实根,为:", value)
else:
    value3 = sqrt(delta)/(2*a)
    value1 = value - value3
    value2 = value + value3
    print("方程有两个不等的实根,分别为:{},{}".format(value1, value2))
'''
# 11.2
# for i in range(100, 1000):
#     a = i % 10
#     b = i // 10 % 10
#     c = i // 100 % 10
#     if a ** 3 + b ** 3 + c ** 3 == i:
#         print(i)

# a = [(i%10)**3+(i//10%10)**3+(i//100)**3 for i in range(100, 1000)]
# print(a)


# 接收灵活数目的参数 : *nums 数  **p
# def demo(*nums):

'''
# import turtle
# turtle.up()
# turtle.goto(-950, -300)
# turtle.down()
# turtle.speed(0)
# def fun(x, j):
#     if j != 1:
#         fun(x,  j - 1)
#     turtle.forward(x)
#
#     turtle.left(60)
#     if j != 1:
#         fun(x,  j - 1)
#     turtle.forward(x)
#
#     turtle.right(120)
#     if j != 1:
#         fun(x,  j - 1)
#     turtle.forward(x)
#
#     turtle.left(60)
#
#     if j != 1:
#         fun(x,  j - 1)
#
# fun(5, 5)
# turtle.mainloop()
'''
# import turtle
#
#
# turtle.penup()
# turtle.goto(-650, -50)
# turtle.pendown()
#
#
# def koch(size, n):
#     if n == 0:
#         turtle.forward(size)
#     else:
#         for angle in [0, 60, -120, 60]:
#             turtle.left(angle)
#             koch(size/3, n-1)
#
#
# koch(1200, 5)
# turtle.mainloop()
'''
def a():
    b = {'wq': "123123", 'er': "312412"}
    return b


c = a()
ad = c.values()
cd = c.keys()
d = list(c)
e = '123123'
f = list(ad).index(e)
dm = a().items()
print(dm)
'''
'''
people = {"张三":"123","lisi":"131241"}
n_name =input("请输入")
l_name = input("")
# people[n_name] = people.pop(l_name
# people.update({n_name:people.pop(l_name)})
people[n_name]

print(people)
'''

# people = {"张三": ["13333333333", "北京市朝阳区"], "李四": ["14444444444", "安徽凤阳小岗村"], "陈坤萌": ["15555555555", "盐山县陈地主家"]}
# key_list = people.keys()
# # print(key_list)
# value_list = people.values()
# # print(value_list)
# # for i in value_list:
# #     for j in i:
# #         print(j)
# #     print(i)
# '''
# sv = {}
# qv = {}
# for i in range(len(value_list)):
#     sv[i] = list(value_list)[i]
#     print(sv[i])
# a = sv[0]
# print(a)
#
# print(a[0])
# '''
# dice = {'1': {"name": "陈坤萌", "tel": "13843854188", "add": "傻逼村"}, '2': {"name": "陈恐龙", "tel": "13785211", "add": "花梨"}}
# key = dice.keys()

# import os  # 引用os模块
# import pickle  # 应用pickle模块
#
# Path = '\\text.txt'  # 全局变量,这里是通讯录物理路径
# # 判断通讯录是否存在,不存在则创建空通讯录
# # if not os.path.exists(Path):  # 判断通讯录是否存在
# f = open(Path, 'wb')  # 以二进制写模式打开通讯录
# temp = {'total': 0}  # 局部变量,用于计算通讯录的人数
# pickle.dump(temp, f)  # 将对象temp保存到f中
# f.close()  # 关闭f
# # else:
# #     pass  # 空函数
#
#
# # 添加联系人
# def add():  # 自定义添加函数
#     f = open(Path, 'rb')  # 以二进制读模式打开通讯录
#     a = pickle.load(f)  # 从f中读取信息为数组的形式
#     f.close()  # 关闭f
#     b = 0  # 自定义局部变量
#     name = input('请输入要添加联系人的姓名:')  # 获取输入,这里是姓名
#     for key in a.keys():  # 循环key为自定义,a.keys()为从通讯录读出来所有key
#         b += 1  # 自定义变量自增
#         if key == name and b <= a['total'] + 1:  # 判断,满足条件执行
#             print("联系人已存在,添加失败!")
#             break  # 跳出循环
#         if b == a['total'] + 1 and key != name:  # 判断,满足条件执行
#             number = input('请输入号码:')  # 获取输入
#             information = {name: number}  # 附值
#             a['total'] += 1  # total+1
#             a.update(information)  # 更新a对象
#             f = open((Path), 'wb')  # 以二进制写模式打开通讯录
#             pickle.dump(a, f)  # 把a对象写入f
#             f.close()  # 关闭f
#             print('添加成功')
#             break  # 跳出循环
#
#
# # 显示所有联系人
# def showall():
#     f = open(Path, 'rb')
#     a = pickle.load(f)
#     print("一共有{}个联系人.".format(a['total']))
#     for key in a.keys():
#         if key != 'total':
#             print("{}:{}".format(key, a[key]))
#     f.close()
#
#
# # 查找
# def search(name):
#     f = open(Path, 'rb')
#     a = pickle.load(f)
#     b = 0
#     for key in a.keys():
#         b += 1
#         if key == name and b <= a['total'] + 1:
#             print("{}的号码是:{}".format(name, a[key]))
#             break
#         if b == a['total'] + 1 and key != name:
#             print("联系人不存在")
#             break
#
#
# # 删除
# def deleate(name):
#     f = open(Path, 'rb')
#     a = pickle.load(f)
#     f.close()
#     b = 0
#     for key in a.keys():
#         b += 1
#         if key == name and b <= a['total'] + 1:
#             a.pop(name)
#             a['total'] -= 1
#             f = open(Path, 'wb')
#             pickle.dump(a, f)
#             f.close()
#             print("删除成功!")
#             break
#         if b == a['total'] + 1 and key != name:
#             print("联系人不存在!无法删除!")
#             break
#
#
# # 修改
# def change():
#     x = input("请输入所要修改的联系人姓名:")
#     f = open(Path, 'rb')
#     a = pickle.load(f)
#     f.close()
#     b = 0
#     for key in a.keys():
#         b += 1
#         if key == x and b <= a['total'] + 1:
#             y = input("请输入修改后的号码:")
#             a[key] = y
#             f = open(Path, 'wb')
#             pickle.dump(a, f)
#             f.close()
#             print("修改成功!")
#             break
#         if b == a['total'] + 1 and key != name:
#             print("联系人不存在")
#             break
#
#
# # 界面
# def point():
#     print("*****************************")
#     print("显示提示信息:*")
#     print("显示所有联系人:0")
#     print("查找联系人:1")
#     print("添加联系人:2")
#     print("删除联系人:3")
#     print("更改联系人资料:4")
#     print("退出通讯录:5")
#     print("*****************************")
#
#
# point()
# # 主进程
# while True:  # 循环
#     x = input("请输入您的选择:")  # 获取输入
#     if x == '2':  # 判断输入
#         add()  # 调用添加函数
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '0':
#         showall()  # 调用显示全部函数
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '5':
#         exit()  # 调用推出函数
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '1':
#         name = input("请输入所要查找的联系人姓名:")
#         search(name)  # 调用查找函数,需要传一个参数:姓名
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '3':
#         name = input("请输入所要删除的联系人姓名:")
#         deleate(name)  # 调用删除函数,需要传一个参数:姓名
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '4':
#         change()  # 调用修改函数
#         continue  # 结束本次循环,重新开始下一轮循环
#     if x == '*':
#         point()
#     else:
#         print("输入选项不存在,请重新输入!")
#         continue  # 结束本次循环,重新开始下一轮循环
a = [1, 23, 45]
b = a.copy()
a.append(66)
b.extend(a)
a.append(123)
print(a)
print(b)

上一篇:python用turtle画夏日海边


下一篇:用 Python 给微信头像加个圣诞老人(平安果)小图标