0

Problem solving

Phython

24th Feb 2021, 6:09 PM
Nemezio Lopezperez
Nemezio Lopezperez - avatar
6 Answers
+ 1
Do you have a code to attach as your attempt That way, we can help easier
24th Feb 2021, 6:29 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Nemezio Lopezperez I sent you a DM with a code that reflects the challenge line for line. I hope it helps you understand the underlying concept of the challenge
24th Feb 2021, 8:48 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Last part of if has to be ... or year%400==0: With and it can never be true Code with testing: def leap(year): if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print("Leap year") else: print("Not a leap year") for y in range(395,405): print(y, end=' ') leap(y) for y in range(495,505): print(y, end=' ') leap(y)
24th Feb 2021, 7:47 PM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar
+ 2
Thanks Benjamin that corrected it !!
24th Feb 2021, 8:45 PM
Nemezio Lopezperez
Nemezio Lopezperez - avatar
0
Hi guys! Trying to solve this problem for Phython but not finding a way to get through it, maybe someone could help? Much appreciated 🙏đŸ’Ș👌 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.
24th Feb 2021, 6:10 PM
Nemezio Lopezperez
Nemezio Lopezperez - avatar
0
Hey yes this was my attempt: if year % 4 == 0 and year % 100 != 0 and year % 400 == 0: print("Leap year") else: print("Not a leap year")
24th Feb 2021, 6:56 PM
Nemezio Lopezperez
Nemezio Lopezperez - avatar