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

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

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

ChetanTMAds


Name

#Facebookdown,2,#InstagramDown,2,#Messengerdown,1,#WhatsAppdown,2,A-Class-Banks-in-Nepal,5,ADBL,12,ADBL-Exam-Center,3,ADBL-Exam-Result,2,ADBL-Vacancy,2,AdobePhotoshop,7,Advertisement,6,Africa,4,Agricultural-Development-Bank-Limited,2,Agricultural-Development-Bank-Vacancy,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,2,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,91,Application-Software,2,Asia,10,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,Bagmati-Pradesh-Loksewa-Yearly-Calendar,1,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,Ban-Rakshak-Vacancy,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,4,Canada,1,Career,1541,CBS,14,CCVI-List-of-Committed-Workers,40,CCVI-List-of-Regular-Workers,6,Celebrity-Biography,13,Celebrity-News,19,China,1,Civil-Service-Hospital,1,ComputerNotes,57,Countries-in-the-World,21,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-2025,1,DV-Lottery-America,6,DV-News,16,DV-Online-Form,5,DV-Result,5,DV-Result-2022,2,DV-Result-2023,2,EDV-2024,1,EDV-2025,1,Election-in-Nepal,1,Elon-Musk-Biography,1,EnglishNotes,2,EPF-Nepal-Result,1,EPF-Nepal-Vacancy,1,EPS,186,EPS-CBT-Candidate-Namelist,1,EPS-Flight-Schedule,71,EPS-Form-Fillup-Namelist,12,EPS-TOPIK-Test-Result,2,Esports-in-Asian-Games-2022,1,Europe,9,Everest-Hospital,1,Exam,1,ExamCenter,175,ExamPaper,41,ExamResult,454,ExamSchedule,275,Facebook,1,Facebookdown,2,Far-Western-University,1,Federal-Republic-of-Germany,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,Gandaki-Pradesh-Loksewa-Yearly-Calendar,1,GBIME,1,Geography,2,Germany,1,Ghana,1,Global-IME-Bank-Limited,1,Gorkhapatra,6,Government-Staff-Salary,21,Government-Teacher-Salary,1,GovernmentJobs,427,Green-Venture-Limited-Hydropower-IPO-Share,1,GuestPost,2,Gurkha Bharti,1,H1B-Visa,4,Happy-Bijaya-Dashami-Wishes-and-Photos,1,Happy-International-Nurse-Day,1,Hardware,4,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,ISO-File,3,Italy,1,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,3,Khabane-Lame-Biography,1,Kingdom-of-Spain,1,Koshi-Pradesh-Lok-Sewa,2,Koshi-Pradesh-Loksewa-Yearly-Calendar,1,Krishi-Bikash-Bank-Limited,1,KSK,3,KSK-Result,1,KSK-Vacancy,1,KUKUL,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-Center,1,Lok-Sewa-Aayog-Section-Officer-Exam-Result,3,Lok-Sewa-Aayog-Vacancy,6,Lok-Sewa-Yearly-Calendar,1,LokSewa,232,LokSewa-Aayog-Contact-Number-and-Recruitment,2,Lumbini-Buddhist-University,1,Lumbini-Pradesh-Lok-Sewa-Aayog-Exam-Result,3,Lumbini-Pradesh-Loksewa-Yearly-Calendar,1,Madhesh-Pradesh-Loksewa-Yearly-Calendar,1,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,Mexico,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-Forensic-Science-Laboratry-Vacancy,1,National-Skill-Resting-Board,1,NBL,3,NBL-Vacancy,2,NEA,25,NEA-Approved-Namelist,8,NEA-Exam-Notice,6,NEA-Exam-Result,8,NEA-Exam-Routine,3,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-Airlines,1,Nepal-Airlines-Vacancy,1,Nepal-Army-Cadet-Vacancy,1,Nepal-Army-Exam-Result,28,Nepal-Army-Exam-Routine,1,Nepal-Army-Sainya-Exam-Center,26,Nepal-Army-Sainya-Exam-Process,1,Nepal-Army-Sainya-Exam-Result,49,Nepal-Army-Sainya-Exam-Routine,2,Nepal-Army-Sainya-Medical-Exam-Routine,1,Nepal-Army-Sainya-Physical-Exam-Routine,1,Nepal-Army-Sainya-Vacancy,2,Nepal-Army-Salary,2,Nepal-Army-Syllabus,1,Nepal-Army-Vacancy-2078,6,Nepal-Army-Vacancy-2079,6,Nepal-Army-Vacancy-2080,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,2,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,21,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,55,Nepal-Police-Salary,3,Nepal-Police-Syllabus,5,Nepal-Police-Transfer-List,21,Nepal-Police-Vacancy-2079,1,Nepal-Police-Vacnacy-2078,2,Nepal-Police-Vacnacy-80,1,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,282,NepaliNotes,5,NepalPolice,306,NEPSE,149,NEPSE-Floor-Sheet-Updates,100,NEPSE-FloorSheet-Updates,72,New,4,New-Tax-Rate-in-Nepal-for-Fiscal-Year-2078-2079,1,News,2906,Neymar-Jr-Biography,1,NFSL-Vacancy,1,NIBL,1,NID,31,NID-Vacancy,1,Nijamati-Karmachari-Salary,1,NOC,8,North-America,5,Notes,38,NRB,17,NRB-Exam-Center,5,NRB-Vacancy,2,NTC,7,Nyadi-Hydropower-IPO-Result-Date,1,Nyadi-Hydropower-Limited-IPO-Share,1,Online-Earning,1,OnlineStore,4,Operating-System,3,Other-Software,2,Peoples-Republic-of-China,1,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,4,Radio-Nepal-Promotion-List,1,Radio-Nepal-Vacancy,2,Rastriya-Anusandhan-Bibhag-Vacancy,1,Rastriya-Anusandhann-Bibhag-Exam-Center,1,Rastriya-Anusandhann-Bibhag-Exam-Result,20,Rastriya-Banijya-Bank-Limited,18,Rastriya-Samachar-Samiti,1,RBB,40,RBB-Exam-Paper,1,RBB-Exam-Result,14,RBB-Vacancy,1,Result,2,Russia,1,SAFF-Championship,1,Sahas-Urja-Limited-IPO-Share,2,Samling-Power-Company-IPO-Share,5,SEE-Exam-Result,1,SEE-Exam-Routine,1,ShareNews,288,Singapore-Police-Vacancy,1,Software,7,South-Africa,1,South-America,3,Spain,1,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,15,Tally,9,Taylor-Swift-Biography,1,Teacher-Service-Commission,6,Teacher-Service-Commission-Annual-Vacancy-Schedule,1,The-Republic-of-South-Africa,1,The-United-Mexican-States,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,39,TU-Exam-Center,1,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,UK,1,United-Kingdom,1,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,Windows-10-32-bit,1,Windows-10-64-bit,1,Windows-11-64-bit,1,World-Geography,18,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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbLWlXRKUhXwE9_4GiuvG9mzV6xf9arKPkcpOEBDaM0rX6hNE7ihJvGmi5jcN3EMIbIdrvfwc9OrMvAW0uBDpVB81re6-C8YhsqtBLi9Yu0iqXuZEnlZIZaw6VNGKIwHWOyh6aYXmrkMNw/s16000/Capture.PNG
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbLWlXRKUhXwE9_4GiuvG9mzV6xf9arKPkcpOEBDaM0rX6hNE7ihJvGmi5jcN3EMIbIdrvfwc9OrMvAW0uBDpVB81re6-C8YhsqtBLi9Yu0iqXuZEnlZIZaw6VNGKIwHWOyh6aYXmrkMNw/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