1樓:軍尚楊是正人本
這個應該簡單了
while 1:
year=int(input("請輸入一個年:"))if (year%400==0) or (year % 100 !=0 and year % 4 == 0):
print("%d 是閏年,有366天"%year)else:
print("%d 是平年,有365天"%year)結果:
2樓:匿名使用者
python
#!/usr/bin/python
# -*- coding: utf-8 -*-n = int(input())
if n%4 == 0 and n%100 != 0 or n%400 == 0:
print(366)
else:
print(365)
3樓:努力成為不熬夜的熊貓
def leap_year_or_not(year):
# 世紀閏年:能被400整除的為世紀閏年。
# 普通閏年:能被4整除但不能被100整除的年份為普通閏年。
# 閏年共有366天,其他年只有365天。
if int(year) % 400 == 0:
return true
elif int(year) % 100 !=0 and int(year) % 4 == 0:
return true
else:
return false
def calculate_days_of_year(year):
leap = leap_year_or_not(year)if leap:
days = 366
run = "是"
else:
days = 365
run = "不是"
print("{}年{}閏年,有{}天。".format(year, run, days))
if __name__ == "__main__":
print("輸入年份:")
n = input()
calculate_days_of_year(n)
4樓:修韓餘暢
year = int(input("請輸入年份"))if year % 400 == 0 or year % 4 == 0 and year % 100 != 0:
print(f"是閏年,366天")
else:
print(f"是平年,365天")
python:輸入年月日判斷是此年的第多少天
5樓:匿名使用者
#今天日期
減去年12月31日的日期即可。
import datetime
y = int(input('請輸入
4位數字的年份:')) #獲取年內份
m = int(input('請輸入月份:')) #獲取月容份d = int(input('請輸入是哪一天:')) #獲取「日」
targetday = datetime.date(y, m, d) #將輸入的日期格式化成標準的日期
daycount = targetday - datetime.date(targetday.year - 1, 12, 31) #減去上一年最後一天
print('%s是%s年的第%s天。'% (targetday, y, daycount.days))
用python寫程式:使用者輸入一個正整數n,計算從1到n(包含1和n)相加後的結果。 求圖求圖!!
6樓:司馬刀劍
>>> def getnb(): nb = int(input('輸入一個整數:')) return nb + 1 >>> getnb()輸入一個整數:1011>>>
用python從鍵盤輸入字串,統計其中大寫小寫字母以及數字的個數
include int main char str 256 char p int upper 0 int lower 0 int space 0 int digit 0 int other 0 p str p指標指向陣列第一個元素 str 0 gets p while p p不為空的時候繼續下面du...
從鍵盤任意輸入整數程式設計判斷它的奇偶性
到開源網,你想要那種語言的程式都有的。整數對2取模,不為零的都是奇數。var s 你輸入的數 if s 2 0 else int x,y cin x y x 2 x y 2?cout 偶數 cout 奇數 input a a number if a mod 2 1 then print ji shu...
用C語言編寫程式,從鍵盤輸入正整數,輸出這個整數的所
include include 數學bai函式標頭檔案 main getchar getchar 你上機執行一下吧,結果是答對的,有不明白的地方可以再找我 include include 數學複函式標頭檔案 main getchar getchar 你上機執行一下吧,結dao果是對的,有不明白的地方...