- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to display Astrological sign or Zodiac sign for a given data of birth.
Given date of birth, our task is to display astrological sign or Zodiac sign.
Examples
Input : Day = 13, Month = November Output : Scorpio.
Algorithm
Step 1 : input date of birth. Step 2 : checks month and date within the valid range of a specified zodiac. Step 3 : display zodiac sign.
Example Code
def zodiac_sign(day, month): # checks month and date within the valid range # of a specified zodiac if month == 'december': astro_sign = 'Sagittarius' if (day < 22) else 'capricorn' elif month == 'january': astro_sign = 'Capricorn' if (day < 20) else 'aquarius' elif month == 'february': astro_sign = 'Aquarius' if (day < 19) else 'pisces' elif month == 'march': astro_sign = 'Pisces' if (day < 21) else 'aries' elif month == 'april': astro_sign = 'Aries' if (day < 20) else 'taurus' elif month == 'may': astro_sign = 'Taurus' if (day < 21) else 'gemini' elif month == 'june': astro_sign = 'Gemini' if (day < 21) else 'cancer' elif month == 'july': astro_sign = 'Cancer' if (day < 23) else 'leo' elif month == 'august': astro_sign = 'Leo' if (day < 23) else 'virgo' elif month == 'september': astro_sign = 'Virgo' if (day < 23) else 'libra' elif month == 'october': astro_sign = 'Libra' if (day < 23) else 'scorpio' elif month == 'november': astro_sign = 'scorpio' if (day < 22) else 'sagittarius' print(astro_sign) # Driver code if __name__ == '__main__': d = int(input("Enter Day ::>")) m = input("Enter the Month ::>") zodiac_sign(d, m)
Output
Enter Day ::>13 Enter the Month ::>november scorpio
- Related Articles
- Java program to display Astrological sign or Zodiac sign for given date of birth
- Python Program to get indices of sign change in a list
- How to display positive sign for X-axis labels in R using ggplot2?
- Program to find sign of the product of an array using Python
- How to display star/asterisk sign (*) inside a base R plot?
- What sign (+ve or −ve) has been given to the following on the basis of Cartesian Sign Convention?(a) Height of a real image.(b) Height of a virtual image.
- How to display square root sign in base R plot?
- How to remove dollar sign in R data frame?
- Program to find length of longest sign alternating subsequence from a list of numbers in Python
- Python – Group Consecutive elements by Sign
- Use the sign of $>,
- How to display mean in a boxplot with cross sign in base R?
- According to the New Cartesian Sign Convention" for mirrors
- Converting boolean values to positive or negative sign in MySQL?
- How to display Y-axis with Euro sign using ggplot2 in R?

Advertisements