notebooklm 學習卡 1. Project structure text leap-year-checker/ ├── leap_year.py └── README.md 2. Python program — leap_year.py python # Leap Year Checker year = int ( input ( "Enter a year: " )) if year % 400 == 0 : print ( f " { year } is a leap year." ) elif year % 100 == 0 : print ( f " { year } is not a leap year." ) elif year % 4 == 0 : print ( f " { year } is a leap year." ) else : print ( f " { year } is not a leap year." ) How it works A year is a leap year if: It is divisible by 400, or It is divisible by 4 but not divisible by 100. Examples: text Enter a year: 2024 2024 is a leap year. text Enter a year: 1900 1900 is not a leap year. text Enter a year: 2000 2000 is a leap year. 3. GitHub README — README.md Create a file named README.md in your project folder and copy the following content. 寫作 🗓️ Leap Year Checker A simple Python program ...
發表文章
目前顯示的是 10月, 2026的文章
- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
notebooklm 學習卡 測驗: Python Script ( converter.py ) def main(): print("=== Weight Converter (Kg to Lbs & Tonnes) ===") try: # Read the weight in kilograms from the user kg = float(input("Enter the weight in Kilograms (kg): ")) # Perform calculations based on the conversion factors # 1 Kg = 2.20 pound # 1 Kg = 0.001 Tonne pounds = kg * 2.20 tonnes = kg * 0.001 # Print the results formatted to 4 decimal places for precision print(f"\nResults for {kg} kg:") print(f"- Weight in Pounds (lbs): {pounds:.4f} lbs") print(f"- Weight in Tonnes (t): {tonnes:.4f} t") ...