Questions tagged [pset7]

For problem set 7 (CS50 Finance)

Filter by
Sorted by
Tagged with
0
votes
2answers
6 views

accidentally imported data multiple times (pset7 houses)

I was testing the code out and ended up running "python import.py characters.csv" multiple times. Now when I go into sqlite3 and print out the data it's repeated itself 3 times over, once ...
0
votes
0answers
18 views

Students only passing 4/6 the last two showing concatnation error but works locally somebody help

[33mTraceback (most recent call last):[0m [33mFile "roster.py", line 34, in main()[0m [33mFile "roster.py", line 27, in main print(row[0] + " " + row[1]+" "+ ...
0
votes
1answer
13 views

In students its printing all the data correctly but when I try to insert it into db its showing this funny error

File "import.py", line 58, in db.execute("INSERT INTO students (first, middle, last, house, birth) VALUES (name[0], NULL, name[1],house, birth)") File "/usr/local/lib/python3....
0
votes
0answers
12 views

Poor JOIN performance?

From my limited understanding, JOIN operations are supposed to generally be faster than nested subqueries. However, when solving the various Movies SQL problems, I'm finding queries with JOINs (...
0
votes
2answers
27 views

How can I check my number of rows on pset7 movies?

I wanted to check my queries one by one as I am doing them, my 1.sql works fine but how I find out how many rows I am getting?
0
votes
1answer
21 views

PSET7 7.sql Error

The code gives the right amount of rows but is not passing the check50 SELECT movies.title, ratings.rating FROM movies JOIN ratings ON ratings.movie_id = movies.id WHERE year = 2010 ORDER BY title ASC
0
votes
1answer
24 views

pset7 6.sql rounding problem

My code works fine but check50 give me an error because it´s not rounded the same way. :( 6.sql produces correct result expected "7.74", not "7.75" SELECT ROUND(AVG(rating), 2) ...
0
votes
1answer
20 views

7.sql CASE error

I'm getting an error where it says Error: near line 3: near "DESC": syntax error My code is SELECT title, rating FROM movies JOIN ratings ON movies.id = ratings.movie_id WHERE year = 2010 ...
0
votes
1answer
38 views

PSET 7, failing on Luna Lovegood test case even though output looks the same as expected output

Expected Output [{'first': 'Luna', 'middle': None, 'last': 'Lovegood', 'house': 'Ravenclaw', 'birth': 1981}] Actual Output: [{'first': 'Luna', 'middle': 'None', 'last': 'Lovegood', 'house': 'Ravenclaw'...
0
votes
1answer
38 views

Submit50 for pset7 movies loads SQL files but returns “Error when executing query: missing statement”

When I execute: submit50 cs50/problems/2020/x/movies All my SQL files are sent for grading and all come back with the same error: Error when executing query: missing statement I have tried the sql ...
0
votes
1answer
198 views

PSET 7 Movies SQL Q9

In 9.sql, write a SQL query to list the names of all people who starred in a movie released in 2004, ordered by birth year. ...Your query should output a table with a single column for the name of ...
0
votes
0answers
25 views

“Error when executing query: too many statements at once” pset 7 movies

Hi! I wanted to know what this error message meant because all my sql statements give the correct output but submit50 shows that i've only got a 2/14 , "Error when executing query: too many ...
0
votes
1answer
12 views

Why updating a dictionary is not working?

for row in rowsList: if row['middle'] is None: row['middle'] == "" print("{} {} {}, born {}".format(row['first'], row['middle'], row['last'], row['birth'])) Where ...
0
votes
1answer
43 views

PSET 7 HOUSES - Syntax error on case function

I'm trying to select the first name and last name and ONLY select the middle name when there is one. The logic of my query makes sense. Every time I am extracting the first name, last name, and birth. ...
0
votes
1answer
25 views

When I run the testing code, it says that movies.db does not exist. How should I fix it?

This is my code in the terminal: cat 1.sql | sqlite3 movies.db This is the output: Error: near line 1: no such table: movies.db
1
vote
1answer
79 views

CS50 Houses : Output is correct in my console but error in check50

I am working on the CS50 course by Harvard EDx. The output for CS50 - Houses is correct in my console. However, check50 which is validates and evaluates the response gives an error. I have checked the ...
0
votes
1answer
53 views

Pset7 houses - why does my output prints thrice instead of once?

The code is as follows: for row in students_list: first, middle, last, birth = row["first"], row["middle"], row["last"], row["birth"] print(f"{...
0
votes
1answer
71 views

pset7 Q10 Weird Result

The challenge is apparently straightforward: write an SQL query to list the names of all people who have directed a movie that received a rating of at least 9.0. To get from names (which lives in the '...
0
votes
1answer
124 views

PSET 7 movies 5.sql check50 not giving the actual output correctly

the check50 output doesn't match sqlite3 output. the code runs and outputs 10 rows in sqlite3 and DBsqlite but check50 output is different.
0
votes
1answer
51 views

How to exclude 'Kevin Bacon's' name from query table?

i have tried to exclude the name from the list but most of the solution aren't doing anything. anyone have idea how to solve. SELECT name FROM movies JOIN stars ON movies.id=stars.movie_id JOIN ...
0
votes
1answer
111 views

Pset7 (Movies) 12.sql: Table outputs 96 rows rather than 5 rows

I've been stuck on this for quite some time and did a lot of research on the AND operator in SQL, but no matter how many variations I try I cannot get my table to output just 6 rows, with each row ...
0
votes
0answers
26 views

Not able to sort the fetched values of chadwick boseman movies

SELECT title FROM movies WHERE movies.id IN ( SELECT ratings.movie_id FROM ratings WHERE ratings.movie_id IN ( SELECT stars.movie_id FROM stars where stars.person_id = ( SELECT people.id FROM ...
0
votes
1answer
137 views

PSET 7 Movies 12.sql

can someone explain the difference between using IN and "="? Here is my code. When I use IN it runs perfectly but when I use "=" there is no output. Thank you! SELECT title FROM ...
0
votes
1answer
118 views

PSET 7 - 6.sql, terminal just hangs

PSET 7 for 6.sql, Terminal just hangs when I execute it. Can anyone tell me why this wouldn't work? I've tried every variation I could think of (and several I found online) for this and none of them ...
0
votes
0answers
84 views

pset7/houses: db.execute(“INSERT”) fails to export data to students.db

I am using pandas to read in the csv file, since I'm familiar with dataframes from R. But I think that may not be the issue here, which is that db.execute fails to export data to students.db. The code,...
0
votes
1answer
50 views

pset7 houses printing the error message if wrong usage

The commandline argument check in roster.py: A bit strange, I find whatever I am doing I can't get this error message to print, the function will shut down alright, but no error message, I have tried ...
0
votes
1answer
81 views

Pset7 Movies Q12: I don't get what's wrong

I can't figure out why my pset7 movies Q12 code isn't working. Can anyone tell me why? Here is my code: SELECT DISTINCT title FROM movies, stars, people WHERE movie_id IN (SELECT movie_id FROM stars ...
0
votes
1answer
228 views

Misuse of aggregate function CS50 Pset 7 10.sql

I'm stuck on pset7 10.sql, it keeps coming up with a misuse of aggregate function. My code is currently: SELECT name FROM people INNER JOIN directors ON people.id = directors.person_id INNER JOIN ...
0
votes
1answer
86 views

CHECK50 Bug in pset7: movies SQL

I have been banging my head on this for an hour and half. Finally finished the pset, uploaded it. Check 50 says: Now, both cs50 ide and DB browser return the correct results, and number of lines for ...
0
votes
1answer
191 views

Houses ~ Import.py - Nothing being inserted into students.db

The following is my code: import csv from sys import argv import sqlite3 import os.path def main(): #Check if correct number of arguments were provided by the user if len(argv) != 2: ...
0
votes
1answer
56 views

pset7 Q7: How many actors are named “Meryl”?

I am at a complete loss for something that should be very simple to find in SQLite. In the IMDB database, I have to find how many actors have the name 'Meryl', I have tried select name, count(name) ...
0
votes
1answer
106 views

pset7 Houses get 17% submit

My code run right and My output same they output but after submitted get 17% why //import.py from sys import argv, exit import cs50 import csv if len(argv) != 2: print("...
0
votes
1answer
31 views

I am working through roster.py, but the first line in the solution is not printing in my output. why is this happening?

import cs50 import sys import sqlite3 db = sqlite3.connect("students.db") house_reader = db.cursor() if len(sys.argv) != 2: print('Usage: import.py file.csv') exit() house_reader.execute("...
0
votes
1answer
167 views

PSET7 Movies Q8 - Why these queries return different results?

I'm working on pset7 movies problem of the CS50 course and I have a question regarding 8.sql, which asks to write a SQL query to list the names of all people who starred in Toy Story. To my ...
0
votes
1answer
168 views

Pset 7 Movies - 13.sql “Error When Executing Query - Too Many Statements at Once”

I'm working on Pset 7 "Movies" and check50 shows an error for 13.sql (list of Kevin Bacon's co-stars) when I submit my code despite running successfully in the IDE. The exact error message is Error ...
0
votes
0answers
37 views

Pset7 buy route error due to API use by lookup function

I am experiencing an error each time I call the lookup function within the buy route when the request method equals post. However, calling lookup during quote does not result in the same error. I ...
0
votes
1answer
58 views

Pset7 Houses, what does my error message mean?

Whenever I run my code, I get a strange error message because of my code. It is because of my SQL code, but I followed all of the instructions, and even tried some other SQL code, which worked ...
0
votes
0answers
83 views

Problem with check50 in pset7 houses

I am getting the correct result when I am executing from the terminal but when I am submitting than it is behaving strangely. MY CODE
0
votes
1answer
316 views

pset7/movies/13.sql: exclude Kevin Bacon from the resulting list

In pset7/movies, I want to dynamically exclude Kevin Bacon from the resulting list (e.g. not specifically mentioning his name with NOT or EXCEPT or copying and pasting code that calculates his ID, so ...
0
votes
1answer
118 views

Problem with Check50 in pset7

I have a problem when I use check50 in speller pset7. I get 1/6 as a final score, but when i run the code in the ide, I get the correct output, but the speller says its a wrong answer. enter image ...
0
votes
1answer
329 views

How to test pset7 queries in the terminal window?

I am trying to test the queries I've saved in files i.e. 1.sql, 2.sql,.... But I can't able to test them in the terminal window. The command given in the instruction is not showing any results. ...
0
votes
0answers
150 views

SQL error pset7 houses

with open(argv[1],"r") as inp: reader = csv.DictReader(inp) for row in reader: lis = row["name"].split() print(len(lis)) if (len(lis) == 2): print(row["...
0
votes
1answer
573 views

Pset7 8.sql is not giving output

i am in problem set 7 now, and i'm stuck in '8.sql'. Specifications is to write a SQL query to list the names of all people who starred in Toy Story. When i run my code, i get no output, i have ...
0
votes
1answer
345 views

Reason for error pset7

There seems to be a problem with the sql line but idk whats wrong. from cs50 import SQL, get_string from sys import argv import csv db = SQL("sqlite:///students.db") if (len(argv) != 2): exit() ...
0
votes
1answer
419 views

Reason for error pset7 houses

from cs50 import SQL, get_string from sys import argv import csv db = SQL("sqlite:///students.db") if (len(argv) != 2): exit() with open(argv[1],"r") as inp: reader = csv.DictReader(inp) ...
0
votes
1answer
166 views

My code pset7 houses pass all check but just take 17% on progess?

I don't know why my code pset7 houses pass all check but when i submit it i just take 17% on progress. Who can help me?. This my code: import.py from cs50 import SQL import csv import sys def main(...
1
vote
1answer
246 views

Why isnt it printing out the average?(pset7 7.sql)

SELECT AVG(rating) FROM ratings WHERE ratings.movie_id = (SELECT id FROM movies where movies.year = 2012); It doesnt seem to print anything.
0
votes
1answer
308 views

pset7 houses printing none instead of last name and extra space

Trying to finish roster.py and my output is incorrect. It prints the None instead of the last name and I am getting and extra space after the last printed name, such as "None , born 1981" or "Jean , ...
1
vote
1answer
696 views

roster.py not getting output

import sys import cs50 # checking argv (that there's one and it's a csv) if (len(sys.argv) != 2): sys.exit("Usage: roster.py house_name") housename = sys.argv[1] #print(house_name) #open(f"...
1
vote
2answers
2k views

PSET7 Movies Q9: Why is my number of rows generated different from what the assignment requires?

Here are the parameters for running a SQL query in the file 9.sql: In 9.sql, write a SQL query to list the names of all people who starred in a movie released in 2004, ordered by birth year. ...

1
2 3 4 5
15