+ 1
Why do these three pieces of code nor fulfill a the conditions?
Hello the code bits below do not work for all situations and I can't figure it out Code bit 1 if year%4==0 and year%100==0 and year%400==0: print('Leap year') else: print ('Not a leap') Code bit 2 year = int(input()) #your code goes here if year%4==0: if year%100==0: if year%400==0: print ('Leap year') else: print ('Not a leap year')
5 Antworten
+ 3
Gemuh Hans ,
yes, you are right. these exercises are for pro members only.
+ 2
Gemuh Hans ,
here is the description of a code coach exercise from the tutorial "python for beginners: try to follow it to get the correct logic:
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.
happy coding!
BTW: since you have solved the python for beginners tutorial to 100%, you must have solve this "end of module" exercise.
+ 2
* If the year is divisible by 100 and 400 it is a leap year..
*If the year is divisible by 4 it is a leap year..
*Else not a leap year..
Take a look here...
https://code.sololearn.com/codax0CQPMQW/?ref=app
+ 1
Lothar not necessarily. I didn't do all the exercises because I didn't have a Pro subscription
0
Send the code url