HackerRank – Python If-Else Solution In Hindi – Is Post Me HackerRank Ke Python Programming Language Se Related Competitive Questions Ka Answer Hai. Is Post Me HackerRank – Python Ka Question No 2 Ko Solve Kiya Gaya Hai.
HackerRank – Python Solution Series Ke Sabhi Questions Ka Solved Codes Ko Diya Jayega. Saath Hi Unko 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 HakcerRank- Python Solution Ke Tutorial Ko Understand Karne Main Dikkat Ho Sakti Hai.
HackerRank – Python If-Else In Hindi
Contents
HackerRank Ke Python Series Ka First Question HackerRank – Python If-Else In Hindi Ka Full Solution With Explanation In Hindi Hai.
Task
Aapko Interger n, Par Niche Diye Hue Contditional Operation Ko Apply Karna Hai.
- agar n ek odd number hai, then Weird print kare.
- agar n ek even number hai, aur 2 se 5 ke between me aata hai, then Not Weird print kare.
- agar n ek even number hai, aur 6 se 20 ke between me aata hai, then Weird print kare.
- agar n ek even number hai, aur 20 se bada number hai, then Not Weird print kare.
Input
Variable n ke liye ek integer value input karna hai.
Constraints
1 <= n <= 100
n ka value 1 se bada aur 100 se less hona chahiye.
Output
Upar diye hue conditions ke anusar Weird or Not Weird print kare.
Sample Input 0
3
Sample Output 0
Weird
Explanation 0
n ka value 3 hai.
n ek odd number hai, and odd number ke liye Weird print karna hai.
Sample Input 1
24
Sample Output 1
Not Weird
Explanation 1
n ka value 24 hai, aur 24 ek even number hai.
n ka value 20 se bada hai, aur even hai, isliye Not Weird print hoga.
Solution
import math import os import random import re import sys if __name__ == '__main__': n = int(input()) if n%2 != 0: print("Weird") else : if(n>=2 and n<=5): print("Not Weird") elif(n>=6 and n<=20): print("Weird") elif(n>20): print("Not Weird")
STEP 1 = Sabse pahle n me int(input()) ka use karke integer input liya.
STEP 2 = Agar n ka 2 se divide hone par remainder 0 milta hai, then Weird print kare.
STEP 3 = Agar upar wala statement True nahi hota hai, then else statement ka use kare.
STEP 4 = else statement me sabse pahle if statement ko check karenge. agar n ka value 2 se bada ya 2 hai and n ka value 5 ya 5 se less hoga, then if statement True hoga and “Not Weird” print kare.
STEP 5 = Agar if statement True nahi hua to elif statement ko check karenge. agar n ka value 6 ya 6 se jyada ho and n ka value 20 ya 20 se kam hoga, then “Weird” print kare.
STEP 6 = Agar elif statement True nahi hua to next elif statement ko check karenge. agar n ka value 20 se jyada hua then “Not Weird” print kare.
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 – Python Say “Hello, World!” With Python Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |