【Python Practice】Day 19 Question 75-79

'''
@Author: your name
@Date: 2020-07-25 14:31:56
@LastEditTime: 2020-07-25 14:43:50
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day19.py
'''
import random

# Question 75
# 生成随机数
def Q75():
    ans=random.randrange(7,16)
    print (ans)

# 编码/解码
# Question 76
# Please write a program to compress and decompress the string "hello world!hello world!hello world!hello world!".
# Use zlib.compress() and zlib.decompress() to compress and decompress a string.
def Q76():
    import zlib
    s='hello world!hello world!hello world!hello world'
    s=bytes(s,'utf-8')
    r=zlib.compress(s)
    print(r)
    print(zlib.decompress(r))

# Question 77
# 计时
def Q77():
    import datetime
    s=datetime.datetime.now()
    for i in range(100):
        x=1+1
    e=datetime.datetime.now()
    print("time spend:{}".format((e-s).microseconds))

# Question 78
# Please write a program to shuffle and print the list [3,6,7,8].
def Q78():
    l=[3,6,7,8]
    random.shuffle(l)
    print(l)


# Question 79
# Please write a program to generate all sentences where subject is in ["I", "You"] and verb is in ["Play", "Love"] and the object is in ["Hockey","Football"].
def Q79():
    who=["I", "You"] 
    how=["Play", "Love"]
    what=["Hockey","Football"]
    for i in who:
        for j in how:
            for t in what:
                # print("sentences:{}".format(i+" "+j+" "+t))
                print("{} {} {}".format(i,j,t))



if __name__ == "__main__":
    # Q75()


    # Q76()

    # Q77()

    # Q78()

    Q79()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tech沉思录

点赞加投币,感谢您的资瓷~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值