Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Determining a leap year This program first prompts the user to enter a year as an int value and checks if it is a leap

Determining a leap year
This program first prompts the user to enter a year as an int value and checks if it is a leap year.
A year is a leap year if it is divisible by 4 but not by 100, or it is divisible by 400.
Use input() to take the user input (the year, i.e.2016) and convert it with int()
Use % to see if a number x is divisible by an other number y, if x%y returns 0, then x is divisible by y
Check if the year is divisible by 4 AND not divisible by 100
OR check if the year is divisible by 400.
Use print()
Exercise 2:
Display leap years
Write a program that displays, ten per line, all the leap years in the twenty-first century (from year 2001 to 2100). The years are separated by exactly one space.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

16. What makes them unique? (special features of the group)

Answered: 1 week ago