-
Notifications
You must be signed in to change notification settings - Fork 0
Week 4 04 13
- Introduce the idea of searching
- Some math, arc, line, angle, the unit circle, radian, sin and cos
- Try the following code, it will get you the current time.
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second, now.microsecond)
A Microsecond is a million-th of one second.
- You can compute sin and cos function of an angle,
import math
math.cos(0.25 * math.pi) # cos (pi/4)
math.sin(2.0/12 * math.pi) # sin (pi/6)
-
Write a clock application. The clock should display an analog clock, and a digital clock beneath the analog clock. The digital clock can be just a string like '18:30:04'. The analog clock does not need to have numbers on the dial, but it need to have 3 arms (hour, minute, second, each is longer and thinner than previous one), and be careful -- the hour arm, at '18:30', should point to the middle between 6 and 7 clock position. HINT: The x, y coordinate of your clock arm, minus the coordinate of the center, is the radius times the cos and sin of some angle. Angle of 0-hr position, is actually pi/2. Is the angle theta rotating clockwise or counter clockwise?
-
You clock need to run, that is, you update your clock arms (and digital clock).