Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python help def get bday_compatibility(bday1, bday2) (str, str) -int Given t wo strings representing birthdates in the format YVVY-MM-DD figure out what star sign each

python helpimage text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

def get bday_compatibility(bday1, bday2) (str, str) -int Given t wo strings representing birthdates in the format YVVY-MM-DD figure out what star sign each birthdate belongs to and return the astrological compatibility of the two signs NOTE FROM BOB: This code should look similar in structure to the get name_compat ibility funct ion that already finished That is, it should cal l on other functions for help, and not be more than a couple of lines long in total. >>get bday_compatibility 1998-08-30 1998-03-10) 70 >get bday_compatibility'1998-08-10, '1998-04-01 100 def get name compat ibility(name, namez): (str, str) -int Given two strings, return their name compatibility According to Bob's rules, this should be calculated by checking how many letters in the first name occurs in the second, and adding this to how many letters in the second name occurs in the first, and then multiplying this sum by 10 For example: If the names are BOB Y and BOBBETTE Z, then - for BOB Y, we get the number 3, because 3 letters in this name occur in the other for BOBBETTE Z, we get the number 4, because 4 letters in this name occur in the other. The number returned for these two names should be 3 47, multiplied by 1070. >>>get.name_compatibility( bob ybobbette z') 70 >>get name_compatibility sadia sharmin,ryan gosling) 150 return (count_common_occurrences(name1, name2) count_common occurrences (name2, namel)) 10 def count_common_occurrences (word1, word2): (str, str) - int Given two strings, word1 and word2, return how many characters in word1 are letters that also occur in word2. You can assume all characters in the given string are lowercase. Also, spaces do not count as a common character Algorithm Go through each character in word1, one by one. If this character occurs in word2, then add 1 to the count. Return total count after you're done going through the characters. >>count.common_occurrences( bob ybobbette z') >>>count common_occurrences( bobbette z bob y') count =0 for x in word1: if(x in word2): count count1 return count # NOTE FROM BOB: DO NOT EDIT THIS STRING # SIGNS is a string representing the start and end date of each sign # Each star sign is represented using three characters (e.g. Aries -ARI) # This is followed by a : and then the start month and start date # and then a- and then the end month and end date # (e.g. Aries starts on 03, 21 (March 21), and ends on 04, 19 (April 19)) # Each star signs information ends with a semicolon SIGNS = . 03, 21-04, 1 9-ARI ; 04, 20-05, 20-TAU; 05, 21-06, 21 =GEM :06, 22-07, 22-CAN ; . + 07, 23-08, 22-LEO; 08, 23-09, 22-V I R: 09, 23-10, 23-LI B: 1 0, 24-11 , 20-SCO; . . 1 1 , 21-12, 21 =SAG: 1 2, 22-01 , 20=CAP:01 , 21-02. 21-AQU: 02, 22-03, 20-PIS; + def get bday_compatibility(bday1, bday2) (str, str) -int Given t wo strings representing birthdates in the format YVVY-MM-DD figure out what star sign each birthdate belongs to and return the astrological compatibility of the two signs NOTE FROM BOB: This code should look similar in structure to the get name_compat ibility funct ion that already finished That is, it should cal l on other functions for help, and not be more than a couple of lines long in total. >>get bday_compatibility 1998-08-30 1998-03-10) 70 >get bday_compatibility'1998-08-10, '1998-04-01 100 def get name compat ibility(name, namez): (str, str) -int Given two strings, return their name compatibility According to Bob's rules, this should be calculated by checking how many letters in the first name occurs in the second, and adding this to how many letters in the second name occurs in the first, and then multiplying this sum by 10 For example: If the names are BOB Y and BOBBETTE Z, then - for BOB Y, we get the number 3, because 3 letters in this name occur in the other for BOBBETTE Z, we get the number 4, because 4 letters in this name occur in the other. The number returned for these two names should be 3 47, multiplied by 1070. >>>get.name_compatibility( bob ybobbette z') 70 >>get name_compatibility sadia sharmin,ryan gosling) 150 return (count_common_occurrences(name1, name2) count_common occurrences (name2, namel)) 10 def count_common_occurrences (word1, word2): (str, str) - int Given two strings, word1 and word2, return how many characters in word1 are letters that also occur in word2. You can assume all characters in the given string are lowercase. Also, spaces do not count as a common character Algorithm Go through each character in word1, one by one. If this character occurs in word2, then add 1 to the count. Return total count after you're done going through the characters. >>count.common_occurrences( bob ybobbette z') >>>count common_occurrences( bobbette z bob y') count =0 for x in word1: if(x in word2): count count1 return count # NOTE FROM BOB: DO NOT EDIT THIS STRING # SIGNS is a string representing the start and end date of each sign # Each star sign is represented using three characters (e.g. Aries -ARI) # This is followed by a : and then the start month and start date # and then a- and then the end month and end date # (e.g. Aries starts on 03, 21 (March 21), and ends on 04, 19 (April 19)) # Each star signs information ends with a semicolon SIGNS = . 03, 21-04, 1 9-ARI ; 04, 20-05, 20-TAU; 05, 21-06, 21 =GEM :06, 22-07, 22-CAN ; . + 07, 23-08, 22-LEO; 08, 23-09, 22-V I R: 09, 23-10, 23-LI B: 1 0, 24-11 , 20-SCO; . . 1 1 , 21-12, 21 =SAG: 1 2, 22-01 , 20=CAP:01 , 21-02. 21-AQU: 02, 22-03, 20-PIS; +

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions