Commit 02918d50 authored by jackfrued's avatar jackfrued

Merge branch 'master' of github.com:jackfrued/Python-100-Days

parents d8046d42 004d9d49
import sys
import mycal
def main():
if len(sys.argv) != 4:
print('Not enough arguments')
return
year = int(sys.argv[1])
month = int(sys.argv[2])
day = int(sys.argv[3])
total = 0
for m in range(1, month):
total += mycal.get_days(year, m)
total += day
print(f'{year}年{month}月{day}日是{year}年的第{total}天')
if __name__ == '__main__':
main()
#!/usr/bin/python3
# coding: utf-8
from random import randint
def main():
answer = randint(1, 100)
while True:
number = int(input('请输入: '))
if number < answer:
print('大一点')
elif number > answer:
print('小一点')
else:
print('恭喜你猜对了!')
break
if __name__ == '__main__':
main()
def main():
persons = [True] * 30
counter = 0
index = 0
number = 0
while counter < 15:
if persons[index]:
number += 1
if number == 9:
persons[index] = False
number = 0
counter += 1
index += 1
index %= len(persons)
for person in persons:
print('基' if person else '非', end='')
print()
if __name__ == '__main__':
main()
#!/usr/bin/python3
from datetime import datetime
import sys
def is_leap(year):
return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
def get_days(year, month):
days = [[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]]
return days[is_leap(year)][month - 1]
def main():
if len(sys.argv) > 1:
month = int(sys.argv[1])
year = int(sys.argv[2])
else:
current_date = datetime.now()
year = current_date.year
month = current_date.month
year2 = year if month >= 3 else year - 1
c = year2 // 100
y = year2 % 100
m = month if month >= 3 else month + 12
w = y + y // 4 + c // 4 - 2 * c + 26 * (m + 1) // 10
w %= 7
months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
print(f'{months[month - 1]} {year}'.center(20))
print('Su Mo Tu We Th Fr Sa')
print(' ' * 3 * w, end='')
total_days = get_days(year, month)
for day in range(1, total_days + 1):
print(f'{day}'.rjust(2), end=' ')
w += 1
if w == 7:
print()
w = 0
print()
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment