Q. A year is a leap year if it is divisible by 100 are not leap year unless they are also divisible by 400. Write a program that asks the user for a year and print out weather it is a leap year or not.
You can understand by Watching video :-
Answer :-
year = int(input("Enter a year = ")) if year % 100 == 0 : if year % 400 == 0 : print("Leap year ") else : print("It is not leap year") elif year % 4 == 0 : print("Leap year 4 ") else : print("It is not leap year ")
Output :-
Enter a year = 2000
Leap year
>>>
Enter a year = 2016
Leap year 4
>>>
Enter a year = 2022
It is not leap year
>>>
you can use 'and' instead of nested if,
ReplyDeleteno problems with the code
Yes, we can use 'and' operator in place of nested if.
DeleteI did not use 'and' operator because many students are not able to understand such type of program.
hii pathwallah moderator, how are you, hope you have a better day, i will greet you everyday except thursday and sunday. so talk what you want with me
ReplyDeletemr pathwallah moderator this is giri_free, want to be friends with you
DeleteAnonymous=giri_free
DeleteThank you : )
DeletePlease send me message on telegram or instagram.
Telegram ( recommended )
what is your a telegram id
DeletePathWalla https://t.me/Pathwalla
Deletethank you very much for replying me, may i know what is your work as a pathwallah moderator, i wish you best for your future endeavours
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )