Snakify Python Program Solution Condition If and If else | Chetan TM
Loading ...

Snakify Python Program Solution Condition If and If else

SHARE:

Tutor Chetan

Python - Programming Language

Snakify.org - Problem Solution

Input, Print and Number


Useful Links:


1) Minimum of two numbers

Statement: Given two integers, print the smaller value. 

Model solution

  • a = int(input())
  • b = int(input())
  • if a < b:
  • print(a)
  • else:
  • print(b)

 

2) Sign function

Statement: For the given integer X print 1 if it's positive, -1 if it's negative, or 0 if it's equal to zero.

Try to use the cascade if-elif-else for it.

 Model solution

  • x = int(input())
  • if x > 0:
  • print(1)
  • elif x == 0:
  • print(0)
  • else:
  • print(-1)

 

3) Minimum of three numbers

Statement: Given three integers, print the smallest value. 

Model solution

  • a = int(input())
  • b = int(input())
  • c = int(input())
  • if b >= a <= c:
  • print(a)
  • elif a >= b <= c:
  • print(b)
  • else:
  • print(c)

OR
  • # num1 = int(input("Input: "))
  • # num2 = int(input("Input: "))
  • # num3 = int(input("Input: "))
  • # if num1 < num2 and num1 < num3:
  • # print(num1)
  • # elif num2 <num1 and num2 < num3:
  • # print(num2)
  • # else:
  • # print(num3)

 

4) Equal numbers

Statement: Given three integers, determine how many of them are equal to each other. The program must print one of these numbers: 3 (if all are the same), 2 (if two of them are equal to each other and the third is different) or 0 (if all numbers are different).

 Model solution

  • a = int(input())
  • b = int(input())
  • c = int(input())
  • if a == b == c:
  • print(3)
  • elif a == b or b == c or a == c:
  • print(2)
  • else:
  • print(0)

OR
  • #num1 = int(input("Input: "))
  • # num2 = int(input("Input: "))
  • # num3 = int(input("Input: "))
  • # if num1 == num2 and num1 == num3:
  • # print("3")
  • # elif num1 != num2 and num1 != num3 and num2 != num3:
  • # print("0")
  • # else:
  • # print("2")

 

5) Rook move

Statement: Chess rook moves horizontally or vertically. Given two different cells of the chessboard, determine whether a rook can go from the first cell to the second in one move.

The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output YES if a rook can go from the first cell to the second in one move, or NO otherwise.

  • r1 = int(input("Input: "))
  • c1 = int(input("Input: "))
  • r2 = int(input("Input: "))
  • c2 = int(input("Input: "))
  • if r1 == r2 or c1 == c2:
  • print("YES")
  • else:
  • print("NO")

 

6) Chess Board - Same color

Statement: Given two cells of a chessboard. If they are painted in one color, print the word YES, and if in a different color - NO.

The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell.

 Model solution

  • x1 = int(input())
  • y1 = int(input())
  • x2 = int(input())
  • y2 = int(input())
  • if (x1 + y1 + x2 + y2) % 2 == 0:
  • print('YES')
  • else:
  • print('NO')

 

7) Leap year

Statement: Given the year number. You need to check if this year is a leap year. If it is, print LEAP, otherwise print COMMON.

The rules in Gregorian calendar are as follows:

  • a year is a leap year if its number is exactly divisible by 4 and is not exactly divisible by 100
  • a year is always a leap year if its number is exactly divisible by 400

Warning. The words LEAP and COMMON should be printed all caps. 

Model solution

  • year = int(input())
  • if (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0):
  • print('LEAP')
  • else:
  • print('COMMON')

COMMENTS

Contact 9816585747 for Advertisement
Name

#Facebookdown,2,#InstagramDown,2,#Messengerdown,1,#WhatsAppdown,2,A-Class-Banks-in-Nepal,5,ADBL,8,ADBL-Vacancy,1,AdobePhotoshop,7,Advertisement,6,Africa,3,Agricultural-Development-Bank-Limited,1,Agricultural-Development0Bank-ADBL-Model-Question,1,AIMS-Hospital-and-Cancer-Center-Vacancy-for-Various-Health-Services,1,APF-Nepal-Final-Exam-Result,4,APF-Nepal-Medical-Exam-Result,4,APF-Nepal-Physical-Exam-Result,2,APF-Nepal-Promotion-Recommend-List,3,APF-Nepal-Salary,1,APF-Nepal-Vacancy-2078,2,APF-Nepal-Written-Exam-Result,4,APF-Nepal-Written-Exam-Schedule,8,APF-Promotion-List-From-Assistant-Head-Constable-to-Head-Constable,1,APF-Promotion-List-Recommendation,1,APFNepal,88,Asia,8,Australia,1,Australia-Oceania,3,Bagmati-Pradesh-Lok-Sewa-Aayog-Exam-Center,4,Bagmati-Pradesh-Lok-Sewa-Aayog-Exam-Result,5,Bagmati-Pradesh-Lok-Sewa-Aayog-Vacancy,5,Bakarid-Festival-Celebration-Wishes-Quotoes-and-Images,1,Balefi-Hydropower-Limited-IPO-Share,1,Ban-Rakshak-Exam-Result,1,Ban-Rakshak-Exam-Schedule,1,Ban-Rakshak-Model-Question,6,Ban-Rakshak-Old-Exam-Paper,1,Bank-of-Kathmandu-Limited,1,BanRakshak-Exam-Result,1,BanRakshak-Exam-Schedule,1,BBS-BSC-BED-BA-First-Year-Exam-Routine-2078,2,BBS-BSC-BED-Fourth-Year-Exam-Routine,1,BBS-BSC-BED-Second-YEar-Exam-Routine-2078,1,Belgium,2,Best-7-way-to-Earn-Money-Online,1,Best-Broker-In-Nepal,1,Best-Place-to-Visit-in-UAE,1,BOKL,1,Books,1,Brazil,1,British-Army-Vacancy,1,Broker-in-Nepal,1,Broker-Near-Me,1,BTS-Army-Biography,1,Buddha-Bhumi-Nepal-Hydropower-IPO-Share,1,Business-Tax-Exemptions-and-Facilities-in-Nepal,1,CAAN-Exam-Result,2,CAAN-Exam-Schedule,3,CAAN-Vacancy,3,Career,1496,CBS,14,CCVI-List-of-Committed-Workers,34,Celebrity-Biography,13,Celebrity-News,19,ComputerNotes,53,Countries-in-the-World,12,COVID19Nepal,5,CProgramming,6,Cricket,1,Cristiano-Ronaldo-Biography,1,CTEVT,10,Dairy-Development -Corporation-Exam-Result,1,Dish-Media-Network-Limited-IPO-Share,1,Domestic-Flights-in-Nepal-Resume-Operations,1,Dordi-Khola-Hydropower-Company-IPO-Share,1,DOTM-Nepal,9,DV-2022-Result,3,DV-2023-Opening-Date,3,DV-2023-Result,1,DV-2024,1,DV-2024-Opening-Date,1,DV-Lottery-America,5,DV-News,15,DV-Online-Form,5,DV-Result,5,DV-Result-2022,2,DV-Result-2023,2,EDV-2024,1,Election-in-Nepal,1,Elon-Musk-Biography,1,EnglishNotes,2,EPS,156,EPS-Flight-Schedule,56,EPS-Form-Fillup-Namelist,12,EPS-TOPIK-Test-Result,1,Esports-in-Asian-Games-2022,1,Europe,4,Everest-Hospital,1,Exam,1,ExamCenter,167,ExamPaper,41,ExamResult,417,ExamSchedule,270,Facebook,1,Facebookdown,2,Far-Western-University,1,Festival-Wishes,1,Football,3,Four-Wheeler-Driving-License-Test-New-Rules,1,Free-Skilled-Training-Program,3,Gandaki-Pradesh-Lok-Sewa-Aayog-Approved-namelist,1,Gandaki-Pradesh-Lok-Sewa-Aayog-Exam-Result,5,Gandaki-Pradesh-Lok-Sewa-Aayog-Exam-Schedule,3,Gandaki-Pradesh-Lok-Sewa-Aayog-Vacancy,3,Gandaki-Pradesh-Lok-Sewa-Exam-Result,1,GBIME,1,Geography,2,Ghana,1,Global-IME-Bank-Limited,1,Gorkhapatra,6,Government-Staff-Salary,18,Government-Teacher-Salary,1,GovernmentJobs,421,Green-Venture-Limited-Hydropower-IPO-Share,1,GuestPost,2,Gurkha Bharti,1,Happy-Bijaya-Dashami-Wishes-and-Photos,1,Happy-International-Nurse-Day,1,Himalayan-Hydropower-Limited-IPO-Share,1,Hong-Kong,1,How-to-apply-Online-Driving-License-Form,1,ICC-Mens-T20-World-Cup,1,Increase-in-Price-of-Petrol-Diesel-Kerosene-and-Aviation-Fuel-by-Nepal-Oil-Corporation,1,India,1,Indian-Army-Rank-and-Salary,1,Indian-Idol-Season-12-Winner,1,Indian-Navy-Rank-and-Salary,1,Instagramdown,2,IPL,5,IPOResult,41,IQ,6,Jeevan-Bikas-Laghubitta-Bittiya-Sanstha-Exam-Syllabus,1,Jeevan-Bikas-Laghubitta-Bittiya-Sanstha-Limited-IPO-Share,5,Jeff-Bezos-Biography,1,Justin-Bieber-Biography,1,Jyoti-Bikash-Bank,1,Karnali-Pradesh-Lok-Sewa-Aayog-Approved-Namelist,2,Karnali-Pradesh-Lok-Sewa-Aayog-Vacancy,2,Kathmandu-Upatyaka-Khanepani-Limited,1,Khabane-Lame-Biography,1,Krishi-Bikash-Bank-Limited,1,KSK,1,Kylian-Mbappe-Biography,1,Lionel-Messi-Biography,1,list-of-airlines-in-nepal,1,List-of-Ballon-dor-winners,1,List-of-Chief-of-Army-Staff-in-Nepal,1,List-of-Countries-and-their-Independence-Day,1,List-of-esport-gami-included-as-medal-events-in-asian-game,1,List-of-IGP-of-APF-Nepal,1,List-of-IGP-of-Nepal-Police,1,List-of-International-Days-in-the-World,1,List-of-Miss-Universe-Winner,2,List-of-Miss-World-Winner,1,List-of-Presidents-of-the-United-State-of-America,1,List-of-Prime-Minister-of-Belgium,1,List-of-Public-Holidays-in-Nepal,1,Live-Stream,1,Lok-Sewa-Aayog-Exam-Center,12,Lok-Sewa-Aayog-Exam-Result,9,Lok-Sewa-Aayog-Nayab-Subba-Exam-Result,1,Lok-Sewa-Aayog-Section-Officer-Exam-Result,2,Lok-Sewa-Aayog-Vacancy,4,LokSewa,220,LokSewa-Aayog-Contact-Number-and-Recruitment,2,Lumbini-Buddhist-University,1,Lumbini-Pradesh-Lok-Sewa-Aayog-Exam-Result,2,Madhya-Bhotekoshi-IPO-Result,1,Madhya-Bhotekoshi-Jalvidyut-Company-Limited-IPO-Share,2,Mahila-Laghubitta-Bittiya-Sanstha-Limited-Vacancy-for-Junior-Assistant-Trainee,1,Malung-Khola-Hydropower-Company-IPO-Share,1,Manakamana-Smart-Laghubitta-Bittiya-Sanstha-IPO-Share,1,Manushi-Laghubitta-Bittiya-Sanstha-IPO-Result,2,Manushi-Laghubitta-Bittiya-Sanstha-IPO-Share,1,MCQS,3,Messengerdown,1,Meta,1,Mid-Western-University,1,Milkha-Singh-Biography,1,Mobile,1,ModelQuestion,34,Most-Desirable-Men-On-Television,1,MSExcel,7,MSOfficePackage,19,MSPowerPoint,1,MSWord,11,Myadi-Police,10,Myadi-Prahari,10,NATHM,1,National-Cooperative-Bank-Model-Question,1,National-Skill-Resting-Board,1,NBL,3,NEA,25,NEA-Approved-Namelist,8,NEA-Exam-Notice,5,NEA-Exam-Result,8,NEA-Exam-Routine,2,NEA-Exam-Syllabus,1,NEA-Vacancy,1,NEB,5,NEB-Class-11-Exam-Result,1,NEB-Class-12-Exam-Result,2,NEB-Class-12-Exam-Routine,2,NEB-Exam-Routine,5,NEB-Postpone-Class-12-Examination,1,Nepa-Open-University-Exam-Routine,1,Nepal,2,Nepal-Administrative-Staff-College-Vacancy,1,Nepal-Army-Cadet-Vacancy,1,Nepal-Army-Exam-Routine,1,Nepal-Army-Sainya-Exam-Center,25,Nepal-Army-Sainya-Exam-Process,1,Nepal-Army-Sainya-Exam-Result,20,Nepal-Army-Sainya-Medical-Exam-Routine,1,Nepal-Army-Sainya-Physical-Exam-Routine,1,Nepal-Army-Sainya-Vacancy,1,Nepal-Army-Salary,1,Nepal-Army-Vacancy-2078,6,Nepal-Army-Vacancy-2079,2,Nepal-Army-Written-Exam-Center,1,Nepal-Army-Written-Exam-Result,4,Nepal-Army-Written-Exam-Routine,1,Nepal-Bank-Limited-Exam-Result,3,Nepal-Bank-Limited-Exam-Schedule,1,Nepal-Bank-Limited-Vacancy,1,Nepal-Driving-License-Test-Opens,1,Nepal-Electricity-Authority-Vacnacy,2,Nepal-Eye-Hospital,1,Nepal-Investment-Bank-Limited,1,Nepal-Life-Insurance-Company-Vacancy,1,Nepal-Oil-Corporation-Written-Exam-Center,3,Nepal-Oil-Corporation-Written-Exam-Schedule,3,Nepal-Police-ASI-Vacancy,1,Nepal-Police-Constable-Vacancy,1,Nepal-Police-Exam-Center,1,Nepal-Police-Exam-Result,19,Nepal-Police-Exam-Routine,1,Nepal-Police-Medical-Exam-Result,12,Nepal-Police-New-Vacany-2078-for-Technical-Group,1,Nepal-Police-Posting-List,7,Nepal-Police-Promotion-List,8,Nepal-Police-Promotion-Recommendent-List,54,Nepal-Police-Salary,2,Nepal-Police-Transfer-List,6,Nepal-Police-Vacnacy-2078,2,Nepal-Police-Written-Exam-Center,8,Nepal-Pragya-Prathisthan-Result,1,Nepal-Pragya=Prathisthan-Vacancy,1,Nepal-Reinsurance-Company-Limited,1,Nepal-Reinsurance-Company-Limited-Exam-Result,1,Nepal-Telecom,2,Nepal-Telecom-Exam-Center,1,NepalArmy,242,NepaliNotes,5,NepalPolice,274,NEPSE,149,NEPSE-Floor-Sheet-Updates,100,NEPSE-FloorSheet-Updates,72,New,3,New-Tax-Rate-in-Nepal-for-Fiscal-Year-2078-2079,1,News,2759,Neymar-Jr-Biography,1,NIBL,1,NID,29,Nijamati-Karmachari-Salary,1,NOC,8,North-America,3,Notes,38,NRB,16,NRB-Exam-Center,5,NRB-Vacancy,1,NTC,7,Nyadi-Hydropower-IPO-Result-Date,1,Nyadi-Hydropower-Limited-IPO-Share,1,Online-Earning,1,OnlineStore,4,Pradesh-No-1-Lok-Sewa-Aayog-Approved-Namelist,5,Pradesh-No-1-Lok-Sewa-Aayog-Exam-Schedule,2,Pradesh-No-1-Lok-Sewa-Aayog-Vacancy,1,PrivateBanking,173,PSC-Weekly-Notice,3,Public-Transport-New-Fare-in-Nepal,4,Puneeth-Rajkumar-Biography,1,Python,4,Questions,59,Quiz,1,Radio-Nepal,3,Radio-Nepal-Promotion-List,1,Radio-Nepal-Vacancy,1,Rastriya-Anusandhann-Bibhag-Exam-Center,1,Rastriya-Anusandhann-Bibhag-Exam-Result,20,Rastriya-Banijya-Bank-Limited,18,Rastriya-Samachar-Samiti,1,RBB,39,RBB--Exam-Paper,1,RBB-Exam-Result,14,Result,2,SAFF-Championship,1,Sahas-Urja-Limited-IPO-Share,2,Samling-Power-Company-IPO-Share,5,SEE-Exam-Routine,1,ShareNews,288,Singapore-Police-Vacancy,1,South-America,3,Sports,15,Sudurpashim-Pradesh-Lok-Sewa-Ban-Rakshak-Syllabus,1,Sudurpashim-Pradesh-Lok-Sewa-Exam-Schedule,1,Sudurpashim-Pradesh-Lok-Sewa-Vacancy,3,Swasthya-Sewa-Karmachari-Salary,1,Syllabus,10,Tally,9,Taylor-Swift-Biography,1,Teacher-Service-Commission,6,Teacher-Service-Commission-Annual-Vacancy-Schedule,1,Thiago-Silva-Biography,1,Time-Person-of-the-Year,1,TipsTricks,16,Top-10-Best-Casino-in-the-World,1,Top-10-Biggest-Casino-in-the-World,1,Top-10-Facts,30,Top-10-Highest-Paid-Actor,1,Top-10-Highest-Paid-Actress,1,Top-10-Highest-Paid-Athletes,1,Top-10-Highest-Paid-Celebrities-in-the-World,1,Top-10-Highest-Paid-Cost-Per-Click-Keywords,1,Top-10-Highest-Paid-Cricket-Player,1,Top-10-Highest-Paid-Football-Player,1,Top-10-Highest-Paid-NBA-Player,1,Top-10-Highest-Paid-Pornstar-Female,1,Top-10-Highest-Paid-Pornstar-Male,1,Top-10-Largest-Company-in-USA,1,Top-10-Most-Expensive-Keywords-in-Google-Ads,1,Top-10-Most-Luxurious-and-Expensive-Casino-in-the-World,1,Top-10-Most-Profitable-Casino-in-the-world,1,Top-10-Most-Searched-Animals-on-Google,1,Top-10-Most-Searched-Pets-and-Animals-on-Google,1,Top-10-Most-Searched-Pets-on-Google,1,Top-10-Most-Viewed-Website-in-the-World,1,Top-10-Oldest-Casino-in-the-world,1,Top-10-Payment-Gateways,1,Top-10-Payment-Gateways-in-World,1,Top-10-Richest-Actor-in-the-World,1,Top-10-Richest-Actress-in-the-World,1,Top-10-Richest-Cricket-Player-in-the-World,1,Top-10-Richest-Female-Adult-Star,1,Top-10-Richest-Female-Porn-Star,1,Top-10-Richest-Football-Player-in-the-World,1,Top-10-Richest-Person-in-the-World,1,Top-10-Richest-Women-in-the-World,1,Top-10-Smallest-Dog-Breads-in-World,1,Top-10=Most-Searched-Words-on-Google,1,Transportation,1,TSC,18,TU,38,TU-Exam-Result,2,TU-Exam-Routine,4,Two-Wheeler-Driving-License-Test-New-Rules,1,UAE-United-Arab-Emirates,2,UEFA-Euro-Cup,2,UFC,4,United-State-of-America,3,University,1,UpcomingIPO,60,Upper-Solu-Hydro-Electricity-Company-IPO-Share,1,V-Lottery-America,2,WebDesign,1,WhatsAppdown,2,World-Geography,9,World-Happiness-Index,1,Worst-Broker-in-Nepal,1,
ltr
item
Chetan TM: Snakify Python Program Solution Condition If and If else
Snakify Python Program Solution Condition If and If else
Python - Programming Language Snakify.org - Problem Solution Input, Print and Number. 1) Minimum of two numbers. 2) Sign function. 3) Minimum of three
https://1.bp.blogspot.com/-g7ZRIXe3LN4/YGFQkgTwELI/AAAAAAAAChU/Xya7gv7k0UcSHaedB15YF1e0SEXEW1fOgCLcBGAsYHQ/s16000/Capture.PNG
https://1.bp.blogspot.com/-g7ZRIXe3LN4/YGFQkgTwELI/AAAAAAAAChU/Xya7gv7k0UcSHaedB15YF1e0SEXEW1fOgCLcBGAsYHQ/s72-c/Capture.PNG
Chetan TM
http://www.chetantm.com.np/2021/03/Snakefy-condition-if-and-ifelse-python-program-solution.html
http://www.chetantm.com.np/
http://www.chetantm.com.np/
http://www.chetantm.com.np/2021/03/Snakefy-condition-if-and-ifelse-python-program-solution.html
true
5092578752892144998
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content