Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Secret Valentines You ve built a website where people can specify who their crushes are. A person can have a crush on zero or more
Secret Valentines
Youve built a website where people can specify who their crushes are. A person can have a crush on zero or more others, and can be crushed on by zero of more others.
There are two tables for holding this data: a table named names that matches names to id numbers and a table named crushed that matches ids from persons and the persons they have a crush on
Example data:
CREATE TABLE names name TEXT, id INTEGER;
INSERT INTO names VALUES
Josh
Emily
Cam
Zizhen
Jane
Jie
Dennis
Jacob
Carrie
Tim
;
CREATE TABLE crushed crusher INTEGER, crushedon INTEGER;
INSERT INTO crushed VALUES
;
Write a python function named getcrushes that takes a filename of a sqlite database. This function should returns a list of strings with each string being a crushercrushedon pairing. However, if someone has no crushes, be sure to have a string representing that see below Order by crusher then by crushed on name
Example return value for the above data:
Cam has a crush on Tim',
'Carrie has a crush on Jane',
'Dennis has a crush on nobody',
'Emily has a crush on Josh',
'Jacob has a crush on Carrie',
'Jacob has a crush on Josh',
'Jane has a crush on nobody',
'Jie has a crush on nobody',
'Josh has a crush on Emily',
'Tim has a crush on nobody',
'Zizhen has a crush on nobody'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started