+ 2

Kindly check discription for question

You need to make a program to take a year as input and output "Leap year" if it’s a leap year, and "Not a leap year", if it’s not. To check whether a year is a leap year or not, you need to check the following: 1) If the year is evenly divisible by 4, go to step 2. Otherwise, the year is NOT leap year. 2) If the year is evenly divisible by 100, go to step 3. Otherwise, the year is a leap year. 3) If the year is evenly divisible by 400, the year is a leap year. Otherwise, it is not a leap year. Sample Input 2000 Sample Output Leap year Use the modulo operator % to check if the year is evenly divisible by a number.

6th Jul 2021, 3:50 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
32 Respuestas
+ 7
you can write it by yourself: I've give you enough hints to do so ;P year divisible by n: year % n == 0 year NOT divisible by n: year % n != 0
6th Jul 2021, 4:47 AM
visph
visph - avatar
+ 2
show your code, so we can tell you what's wrong and how to fix it ;P numbers divisible by d have remainder of number / d equals to zero...
6th Jul 2021, 4:10 AM
visph
visph - avatar
6th Jul 2021, 7:52 AM
David Ashton
David Ashton - avatar
+ 1
Vkd not putting != or == is valid, as value wich are not 0 or not empty structures are evaluated to true (false otherwise)
7th Jul 2021, 10:41 PM
visph
visph - avatar
0
where is your attempt? try first by yourself, and if you stuck, we could help you to complete by yourself... but we must see your code ^^
6th Jul 2021, 3:53 AM
visph
visph - avatar
0
Bro I am having a issue
6th Jul 2021, 4:01 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
How Python will recognise
6th Jul 2021, 4:01 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
Is there any remainder
6th Jul 2021, 4:01 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
I tried. but I don't know to make python to check it that there is any remainder or not
6th Jul 2021, 4:02 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
:I.
6th Jul 2021, 4:02 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
visph I first try by myself then only post doubts 😑
6th Jul 2021, 4:02 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
post what you have tried so far... operator to get remainder is %
6th Jul 2021, 4:05 AM
visph
visph - avatar
0
visph I know how to get remainder but how to deal with it
6th Jul 2021, 4:06 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
visph my code was giving error invalid syntax
6th Jul 2021, 4:06 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
Ohkk. Got it what you mean. Thanks😎💞 👍🏻
6th Jul 2021, 4:17 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
year = int(input()) #your code goes here x = year % 4 y = year % 100 z = year % 400 if x == 0: if y == 0: if z == 0: print ("Leap Year") else: print ("Not a Leap Year")
6th Jul 2021, 4:25 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
Kindly tell whats the problem
6th Jul 2021, 4:25 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
6th Jul 2021, 4:25 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar
0
you should put more than one space to clearly see your code blocks ;P anyway, your logic is wrong: if year divisible by 4 and if year divisible by 100 and if year divisible by 400 leap year else (if not year divisible by 4) not leap year but leap year if year divisible by 4, except if year not divisible by 100 or divisible by 400: 2000 is leap year, 1900 is not leap year... in other words: if year divisible by 400 or (year divisible by 4 and NOT divisible by 100) leap year else not leap year
6th Jul 2021, 4:37 AM
visph
visph - avatar
0
Can you tell me how to write. I am still unable to get it. Iam trying my hard visph
6th Jul 2021, 4:45 AM
Sanchit Aggarwal
Sanchit Aggarwal - avatar