Mode Gelap

Recent in Fashion

Best Seller Books

Indian Zodiac

  • Problem Description

    The Indian zodiac assigns animals to years in a 12 year cycle. One 12 year cycle is shown in the table below. The pattern repeats from there, with 2012 being another year of the dragon, and 1999 being another year of the hare. 

    2000 Dragon
    2001 Snake
    2002 Horse
    2003 Sheep
    2004 Monkey
    2005 Rooster
    2006 Dog
    2007 Pig
    2008 Rat
    2009 Ox
    2010 Tiger
    2011 Hare 

    Write a program that reads a year from the user and displays the animal associated with that year. Your program should work correctly for any year greater than or equal to zero, not just the ones listed in the table.


    Mandatory:

    Use if and elif
  • CODING ARENA
  • year = int(input())
    if (year - 2000) % 12 == 0:
        sign = 'Dragon'
    elif (year - 2000) % 12 == 1:
        sign = 'Snake'
    elif (year - 2000) % 12 == 2:
        sign = 'Horse'
    elif (year - 2000) % 12 == 3:
        sign = 'sheep'
    elif (year - 2000) % 12 == 4:
        sign = 'Monkey'
    elif (year - 2000) % 12 == 5:
        sign = 'Rooster'
    elif (year - 2000) % 12 == 6:
        sign = 'Dog'
    elif (year - 2000) % 12 == 7:
        sign = 'Pig'
    elif (year - 2000) % 12 == 8:
        sign = 'Rat'
    elif (year - 2000) % 12 == 9:
        sign = 'Ox'
    elif (year - 2000) % 12 == 10:
        sign = 'Tiger'
    else:
        sign = 'Hare'

    print(sign)


                                                                                     
  • Test Case 1

    Input (stdin)
    1998

    Expected Output
    Tiger
  • Test Case 2

    Input (stdin)
    2017

    Expected Output
    Rooster

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

0 Comment

Post a Comment

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads