import datetime
birthday = datetime.datetime.strptime(“2000-04-11”, “%Y-%m-%d”)
print(birthday)
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))
using namespace std;
int fibonacci(int n) {
if (n < 3) return 1;
return fibonacci(n – 1) + fibonacci(n – 2);
}
int main() {
for (int n = 1; n <= 10; ++n) {
cout << “f(” << n << “) = ” << fibonacci(n) << endl;
}
}
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)
nums = [10, 20, 30]
nums_bak = nums.copy()
nums[0] = 100
print(nums)
print(nums_bak)