挑战Python100题(9)

100+ Python challenging programming exercises 9

Question 81

Please write a program to randomly print a integer number between 7 and 15 inclusive.

Hints: Use random.randrange() to a random integer in a given range.

请编写一个程序,随机打印一个介于7和15之间的整数。

提示:对给定范围内的随机整数使用random.randrange()。

Solution:

import random
print(random.randrange(7,16))

Question 82

Please write a program to compress and decompress the string "hello world!hello world!hello world!hello world!".

Hints: Use zlib.compress() and zlib.decompress() to compress and decompress a string.

请编写一个程序来压缩和解压缩字符串“hello world!hello world!hello world!hello world!”。

提示:使用zlib.c

相关推荐

  1. python挑战10秒小程序

    2024-01-03 18:30:03       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-03 18:30:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-03 18:30:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-03 18:30:03       82 阅读
  4. Python语言-面向对象

    2024-01-03 18:30:03       91 阅读

热门阅读

  1. 第四篇 行为型设计模式 - 灵活定义对象间交互

    2024-01-03 18:30:03       56 阅读
  2. 【Manacher】LeetCode-5. 最长回文子串

    2024-01-03 18:30:03       55 阅读
  3. XAML转换器

    2024-01-03 18:30:03       48 阅读
  4. 每期一个小窍门: 重置kafka 消费者的偏移量

    2024-01-03 18:30:03       58 阅读
  5. C++零基础自学笔记

    2024-01-03 18:30:03       44 阅读
  6. Linux中find文件查找工具应用

    2024-01-03 18:30:03       60 阅读
  7. linux系统类型及分类

    2024-01-03 18:30:03       51 阅读