Interactive Python:Mini-project # 3 - "Stopwatch: The Game"

本文介绍了一个使用Python交互式编程实现的迷你项目——Stopwatch游戏。玩家需要构建一个间隔为0.1秒的计时器,用整数记录时间(以十分之一秒为单位)。游戏包含“开始”、“停止”和“重置”按钮,要求在画布中央显示当前时间,并在右上角显示成功停止和总停止次数的计数器。玩家的目标是在整秒时停止计时器以获得分数。
摘要由CSDN通过智能技术生成

An Introduction to Interactive Programming in Python 

Mini-project development process

  1. Construct a timer with an associated interval of 0.1 seconds whose event handler increments a global integer. (Remember thatcreate_timer takes the interval specified in milliseconds.) This integer will keep track of the time in tenths of seconds. Test your timer by printing this global integer to the console. Use the CodeSkulptor reset button in the blue menu bar to terminate your program and stop the timer and its print statements. Important: Do not use floating point numbers to keep track of tenths of a second! While it's certainly possible to get it working, the imprecision of floating point can make your life miserable. Use an integer instead, i.e., 12 represents 1.2 seconds.
  2. Write the event handler function for the canvas that draws the current time (simply as an integer, you should not worry about formatting it yet) in the middle of the canvas. Remember that you will need to convert the current time into a string using str before drawing it.
  3. Add "
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值