HackerRank – Write a Python function In Hindi – Is Post Me HackerRank Ke Python Programming Language Se Related Competitive Questions Ka Answer Hai. Is Post Me HackerRank – Write a function No 6 Ko Solve Kiya Gaya Hai.
HackerRank – Python Solution Series Ke Sabhi Questions Ka Solution Codes Ko Diya Jayega. Saath Hi Hindi Me Explain Bhi Kiya Jayega.
Yadi Aapne Abhi Tak Python Full Course In Hindi Read Nhi Kiya Hai To Aap Pahle Wo Kare Nhi To Aapko HackerRank- Python Solution Ke Tutorial Ko Understand Karne Main Dikkat Ho Sakti Hai.
HackerRank – Write a function
Contents
Leap Year
Leap Year 4 years par aata hai. For example 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, leap years
3 Rules for Leap year
- Leap year 400 se divisible hota hai. Unless wo leap year nahi hai.
- Agar year 100 se divisible hai then leap year hai. lekin
- Leap year ko 100 and 4 dono se divisible hona chahiye.
Iska matlab hai the years 2000 and 2400 leap years hai.
Aur1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years.
Task
User se ek Year ke liye input lena hai.
function create karna hai and check karna hai Leap year hai ya nahi hai.
Input
user se integer input lena hai as year. For example 2000,2003,2004 etc.
Constraints
1900 <= year <= 105
Output
Function ek (True / False) return karna chaiye.
Sample Input 0
1990
Sample Output 0
False
Explanation 0
1990, 4 se divisible nahi hai. Isliye ye ek Leap year nahi hai.
Solution
def is_leap(year): leap = False if year%400==0 : leap = True elif year%4 == 0 and year%100 != 0: leap = True return leap year = int(input()) print(is_leap(year))
STEP 1 – def ka use karke is_leap function banaya.
STEP 2 – year ko function is_leap me pass kiya.
STEP 3 – leap ko initial value False diya.
STEP 4 – if year % 400==0 ka use karke check kiya year 400 se divisible hai ya nahi.
STEP 5 – Agar year 400 se divide hone ke baad 0 remainders hai, then leap ka value True me convert karenge
STEP 6 – elif statement ka use kare and two condition ko check kare.
STEP 7 – First Condition, year%4 == 0. year ko 4 se divide karne par 0 remainder hona chaiye. Second Condition, year%100 != 0. year ko 100 se divide karne ke baad 0 remainder hona chaiye.
STEP 8 – Agar First and Second Condition True hota hai, then leap ke value ko True me convert karde.
STEP 9 – Ab leap ke value ko return karde.
STEP 10 – year = int(input()), year ke liye intger input liya.
STEP 11 – is_year function ko print kiya and year ko pass kiya and leap ko check kare. DONE.
Upar Diye Hue Code Ko Aap Apne Code Editor Me Use Kar Sakte Hai And Practice Kar Sakte Hai.
DISCLAIMER
The Above Whole Problem Statement Is Given By Hackerrank.Com But The Solution Is Generated By The masterprograming.com Authority If Any Of The Query Regarding This Post Or Website Fill The Contact Us Form.
-Masterprogramming
Friends Mujhe Umeed Hai Ki Aapko HackerRank – Write a function In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mujhse Se Contact Kar Sakte Hai |