An Introduction to Interactive Programming in Python

An Introduction to Interactive Programming in Python (Part 1)

这个课的编程界面是rice自己做的,所以想在本地完成的话需要自己下载simplegui。
整个课程所有的代码和QUIZ题目由一个大佬总结在这里
课程大佬额外做的各种demo
一个大佬的python记录总结
github上一个神奇的所有quiz选项权值
???

一些值得记录的课程代码
1.3.2 buttons 用simplegui做界面,按按钮做数学计算
A tiny game: guess the number

1.4.1example of drawing on the canvas:123
timerstips3-events,quiz(考敏锐timer),position_controlkeyboard_echomotion_explicitmotion_implicit.2collisions_and_reflectionsposition_control(点一下动一下),velocity_control(有加速度越点越快),final1_pong_game

Week 2 Quiz

  1. What typically calls an event handler?

A. The code you write.

B. Some code that you didn’t write which generates the event.

解:B. An event handler typically is a software routine that processes actions such as keystrokes and mouse movements. 可以理解为监视器,这显然是不需要自己写的,直接用就可以。

  1. What are the three parts of a frame?

Refer to the video on SimpleGUI.

  • Refer to the video on SimpleGUI.
  • Options Area
  • Mouse
  • Canvas
  • Status Area
  • Background Area
  • Control Area
  • Border
  • Keyboard
  • Title

解:Canvas(画布)Status Area(状态区域) Control Area(控制区域)

Control area is where we have buttons, text inputs, and there are even text labels that allow you to print status information from your application back to the frame. In this application, there’s just this one button that says click me, so let’s click it. And you’ll notice over on the right hand side, which is the canvas, the message changed from welcome to good job.
Canvas, is where all the interesting things are going to happen in your program. This is where we can draw images, shapes, text, and we can even respond to keyboard and mouse events over in the canvas. So, the canvas is the interesting part of the frame.
Status area :the status area gives us feedback about keyboard and mouse events that happen in the canvas and this is critical to making the bugging a little bit simpler in SimpleGUI. So now you seen the basic application on this elements.

3.注意list a 的变化,直接将a赋给b,a是会随着b变化的。
make a new reference b to a.

a = [5, 3, 1, -1, -3, 5]
b = a
b[0] = 0
print a
print b
#[0, 3, 1, -1, -3, 5]
#[0, 3, 1, -1, -3, 5]

make a new copy b of the list a using the function list.

# The assignment b = list(a) created a copy of the list a.
# Setting b[0] = 0 only mutated the copy of the list, not
# the original list.  As a result, a[0] == 5.
a = [5, 3, 1, -1, -3, 5]
b = list(a)
b[0] = 0
print a
print b
#[5, 3, 1, -1, -3, 5]
#[0, 3, 1, -1, -3, 5]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值