GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ThinkPython2/code/double.py at master · AllenDowney/ThinkPython2

Expand file tree

/

double.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (40 loc) · 1.3 KB
/

double.py

Copy path

File metadata and controls

55 lines (40 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""This module contains a code example related to
Think Python, 2nd Edition
by Allen Downey
https://greenteapress.com/wp/think-python-2e/
Copyright 2015 Allen Downey
License: http://creativecommons.org/licenses/by/4.0/
"""
from __future__ import print_function, division
from datetime import datetime
def main():
print("Today's date and the day of the week:")
today = datetime.today()
print(today)
print(today.strftime("%A"))
print("Your next birthday and how far away it is:")
#s = input('Enter your birthday in mm/dd/yyyy format: ')
s = '5/11/1967'
bday = datetime.strptime(s, '%m/%d/%Y')
next_bday = bday.replace(year=today.year)
if next_bday < today:
next_bday = next_bday.replace(year=today.year+1)
print(next_bday)
until_next_bday = next_bday - today
print(until_next_bday)
print("Your current age:")
last_bday = next_bday.replace(year=next_bday.year-1)
age = last_bday.year - bday.year
print(age)
print("For people born on these dates:")
bday1 = datetime(day=11, month=5, year=1967)
bday2 = datetime(day=11, month=10, year=2003)
print(bday1)
print(bday2)
print("Double Day is")
d1 = min(bday1, bday2)
d2 = max(bday1, bday2)
dd = d2 + (d2 - d1)
print(dd)
if __name__ == '__main__':
main()
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.