import datetime
day1 = datetime.datetime(year=2000, month=4, day=11)
day2 = datetime.datetime(year=2001, month=1, day=1)
delta = datetime.timedelta(days=3, hours=5)
day3 = day1 + delta
print(day3)
import datetime
day1 = datetime.datetime(year=2000, month=4, day=11)
day2 = datetime.datetime(year=2001, month=1, day=1)
delta = datetime.timedelta(days=3, hours=5)
day3 = day1 + delta
print(day3)
import datetime
birthday = datetime.datetime(year=2000, month=4, day=11)
birthday_formatted = birthday.strftime(“%B %d %A, %Y”)
print(birthday_formatted)
import datetime
birthday = datetime.datetime.strptime(“2000-04-11”, “%Y-%m-%d”)
print(birthday)
import math
from math import pi as PI
print(math.cos(math.radians(180)))
import math
print(0.1 * 3 == 0.3)
print(math.isclose(0.1 * 3, 0.3))
import random
names = [“Taro”, “Jiro”, “Saburo”, “Shiro”, “Goro”]
names = list(set(names))
winners = random.sample(names, 3)
print(winners)
from random import randint
n = randint(1,6)
print(n)
scores = [
{“name”: “Taro”, “math”: 70, “english”: 82},
{“name”: “Jiro”, “math”: 67, “english”: 61},
{“name”: “Saburo”, “math”: 81, “english”: 58},
]
print(“Name Math English”)
print(“——– ——– ——–“)
scores.sort(key=lambda score: score[“math”], reverse=True)
for score in scores:
for value in score.values():
print(f”{value:8} “, end=””)
print()
scores = [
{“name”: “Taro”, “math”: 70, “english”: 82},
{“name”: “Jiro”, “math”: 67, “english”: 61},
{“name”: “Saburo”, “math”: 81, “english”: 58},
]
print(“Name Math English”)
print(“——– ——– ——–“)
for score in scores:
for value in score.values():
print(f”{value:8}”, end=””)
print()
keys = [“math”, “english”, “physics”]
values = [62, 91, 84]
scores = {}
for key, value in zip(keys, values):
scores[key] = value
scores ={key: value for key, value in zip(keys, values)}
print(scores)