自学Python第六天:实战练习——机选双色球

Python85

Python自学第六天:实战练习——机选双色球

我是一个编程小白,目前从事运维工作。
对于运维相关的技术,基本上都是了解点皮毛。
因为最近接触自动化运维工具,看到很多工具都需要用到Python来写脚本。
于是,利用业余时间,开始自学Python。
目标不是学习熟练,而是对别人写的代码有一个大致的了解,你也可以自己写一些简单的代码。

[En]

The goal is not to learn to be proficient, but to have a general understanding of the code written by others, and you can also write some simple code yourself.

下面是我结合最近几天的学习成果,又通过网络简单查询学习了一下:random.sample 的功能和使用方法,编写的一段代码。
一般的功能是,可以根据用户的选择随机生成双色球彩票号码,并计算出购买这些彩票所需的金额。

[En]

The general function is that the two-color ball lottery numbers can be randomly generated according to the user's choice, and the amount of money needed to buy these lottery tickets can be calculated.

不多不少,正好200行。
一方面,相对于这六天的学习时间来说,
我对这次实战演练的效果相当满意,也坚定了我继续学习的信心。

[En]

I am quite satisfied with the effect of this actual combat exercise, and it has strengthened my confidence to continue to study.

另一方面,在写代码的过程中,我可以感觉到这个代码非常臃肿,这应该受到我目前所知不足的限制。

[En]

On the other hand, in the process of writing the code, I can feel that this code is very bloated, which should be limited by the lack of knowledge I have so far.

希望日后可以有所改善,
也希望有资深人士,有机会看到我的博客,可以毫不犹豫地给出学习结束的建议,我将在这里感激!

[En]

Also hope that if any senior person, chance to see my blog, can not hesitate to give advice on the end of learning, I would appreciate it here!

OK,废话不多少,直接上代码。

```python

!/var/bin/env python

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长