Questions tagged [pset6]
The problem set for Week 7
854
questions
0
votes
0
answers
9
views
why, if coding in python, get_float accepts an int like 2 but not a float like 0.41?
In the pset6, exercise cash, get_float accepts an int like 2 but not a float like 0.41?
This is a snippet from my python code:
from cs50 import get_float
owed = get_float("Change owed: ")
...
0
votes
0
answers
26
views
How do i solve this error "PIL.UnidentifiedImageError: cannot identify image file 'before.jpg'" in the shirt problem in CS50?
This is my code:
from PIL import Image, ImageOps, ImageTk
import tkinter as tk
import os, sys
if len(sys.argv) == 3:
extensions = [".jpg", ".jpeg", ".png"]
extension1 = ...
0
votes
1
answer
40
views
mario-more does not pass check50 even though it appears like it should
There is something wrong with these checks for mario. I spent too much time googling but nothing helps. I tried different codes and nothing passes the check, but it works properly.
It seems like ...
0
votes
0
answers
21
views
Readability python pset6
I'm having a problem with check50 that I can't seem to get my head round.
When submitting i's met with the error: 'Cause
expected prompt for input, found none'
from cs50 import get_string
def main():
...
0
votes
1
answer
69
views
pset6 lines, expected 2058 lines and mine gets 2062
When I check with check50, I got the following:
I do not know what I am doing wrong, as I practice with the 2 programs (hello.py and goodbye.py) everything seems to be running good.
import sys
if ...
0
votes
0
answers
5
views
Mario.py is confusing me
So I came up with a code that seems like that it should work. This code is my logic that I used for mario.py, here it is:
height = 0
while (height <= 0 or height > 8):
try:
height = ...
0
votes
1
answer
201
views
Week6 Mario-less Help!
I really need help with Week 6 problem sets. I am quite sure all my codes are correct, but I just can't seem to get the answer that I should be getting. For example, this is my solution for ...
0
votes
1
answer
15
views
Defining an argument for a bool function in Python (PSET6)
I've been trying to work out ways to define check_sum for the execution of this bool function. The error message that has been showing on my screen is "NameError: name 'check sum' is not defined. ...
0
votes
0
answers
93
views
I'm having problems with the pset 6 CS50 P-Shirt
I keep getting errors such as the ones below when submitting my code. Can someone tell me how I can fix my code so that it will accept it?
def main():
if len(sys.argv) == 3:
input_name, ...
1
vote
1
answer
368
views
What are exit codes and how can I find the reason for certain value of exit code?
I took CS50's Introduction to Programming with Python recently and I'm stuck at the CS50P-Shirt problem from pset 6. Though the output is correct, the program fails to exit with exit code '0' (...
0
votes
1
answer
513
views
CS50P PSET6 Scourgify check50 error
I am experiencing errors on the last two check50 test cases. I checked my csv output and it seems correct to me. Anyone knows what I have done wrong in my code?
import sys
import csv
def scourgify(...
1
vote
1
answer
255
views
PSET6: DNA check50 expecting no match on txt18 ,but my program returns harry
my code works for all the other tests on check50 besides the one for txt18. I checked the Large.csv file and the return value of longest_match function (both provided by cs50) and they match up yet ...
1
vote
1
answer
2k
views
CS50P PSET6 : program doesn't produce a CSV file with specified format
My program fails last two tests with check50 eventhough the output is a csv file with the correct specified columns(first, last, house). Can anyone tell me where the problem is?
Here is my code:
...
0
votes
1
answer
303
views
pset6 DNA - help creating and referencing dictionaries
This may be a strange question - my code actually worked, but I feel like I got to a solution by brute force, rather than something more elegant.
I'm still not sure how to create and reference ...
-1
votes
1
answer
73
views
Can't figure out why my code fails check50
I spent a huge amount of time tring to figure out why, and couldn't so far.
Thanks in advance :)
0
votes
0
answers
139
views
pset6 I just don't understand what I have to do
import csv
import sys
counter = 0
def main():
if len(sys.argv) != 3:
sys.exit("Usage: python dna.py data.csv sequence.txt")
# Open csv file and read it's contents into memory
...
0
votes
1
answer
103
views
PSET6 DNA Why is my (count consecutive substrings in string) function always returns 0's?
I tried writing different function variations but my count_dna function keeps returning zeroes (despite having consecutive sequences of STRs in the dna sequences)--can anyone please tell me why?
Note: ...
0
votes
2
answers
108
views
PSET6 Readability "unsupported operand type(s) for *: 'float' and 'NoneType'"
I'm getting "unsupported operand type(s) for *: 'float' and 'NoneType'" error for line 34: "s = (100 / words) * sentences".
Not sure what to make of this since count_sentences(text)...
0
votes
1
answer
78
views
What does "consecutively" mean in pset6 DNA?
I am working on pset6 DNA and I'm not sure I understand the terms of the problem.
The objective is to write a program that matches a DNA sequence to a person in a DNA database based on the largest ...
0
votes
1
answer
48
views
PSET6 - Readability. When I am running my program it is showing me this error again and again
The error I am getting
Traceback (most recent call last):
File "/home/ubuntu/pset/pset6/readability/readability.py", line 46, in
<module>
main()
File "/home/ubuntu/pset/pset6/...
1
vote
1
answer
168
views
How should rounding be handled in pset6 readability?
I'm struggling to understand what sort of rounding needs to be implemented to produce the grade in [pset6 readability][1].
For the Harry Potter extract provided ("Harry Potter was a highly ...
0
votes
1
answer
55
views
My program is not is not able to import strlen from string.h
I am working on problem set 6 - Readability (python). When I am compiling my code the following error keeps coming.
Traceback (most recent call last):
File "/home/ubuntu/pset/pset6/readability/...
0
votes
1
answer
107
views
My program is not working
I am working on pset6 Mario. When I am running my program it is showing me some errors. But I think my code is correct.
Here is my code:
from cs50 import get_int
row = 0
space = 0
insert = 0
...
0
votes
1
answer
117
views
Pset6 - DNA - Strange Error
I'm in the [ Testing ] section and my program works fine with [ small.csv ], but the expected data is not the same as the real data:
For example:
If I run this: python dna.py databases/large.csv ...
0
votes
1
answer
107
views
Credit Card Check
So I am on pset6 trying to implement the credit card check.
I've already completed working through the numbers and am not having any issue with the actual algorithm.
But for some reason my if ...
0
votes
1
answer
100
views
DNA Max Sequence Bug | Working on small.csv but not on large.csv
This is the complete code:
"""
- open csv file and sequence , read contents
- for each str, compute longest chain
- compare str counts aganist ech row in csv file
"""...
1
vote
1
answer
63
views
DNA: Excluding a column from my dict iteration
Logic: I'm trying to do this in such a way that I check the database first, then I check the DNA sequence to see if that information corresponds to any of the information in my database.
I want to ...
0
votes
1
answer
109
views
Pset 6 - Dna - My outputs are slightly incorrect. Could someone help me figure out what might be the problem here?
I've been stuck on this question for a week. After countless hours of debugs, I decided to post it here. Please refer to images and code snippets below and kindly explain to me what might be the ...
0
votes
1
answer
172
views
Minor change in pset6/dna required, need some help or hint
I am really really close to completing pset/dna.
But there seems to be some problem in the 'if statement'. Somebody please guide.
Before the line of underscores in the terminal, I have printed the ...
0
votes
1
answer
104
views
pset6 DNA // having problem comparing elements from the database and the sequence file
Hi there I am having an issue comparing the data I have extracted from the sequence and the database files for now I am doing a sort of in efficient way but later I will fix it I am not sure really ...
0
votes
1
answer
412
views
PSET6 DNA Almost done - matching not working correctly
I have been stuck with last part of the code that is supposed to match the DNA sequence from sequence.txt with the one in database.csv.
It passes most of the tests in check50 and fails only in ...
0
votes
1
answer
75
views
PSET6 DNA Think I'm getting an infinite loop which is apparent when testing with every txt file after 4.txt
Hi all I'm having trouble for PSET6 DNA. My code works fine for everything up until and including 4.txt but whenever I go to check the large.csv file and thus 5.txt, 6.txt, 7.txt and so on I seem to ...
0
votes
2
answers
535
views
Imprecision during float subtraction in python
During pset6/cash, I tried to write the python code without multiplying change by 100 to get cents (as I had in c).
I had assumed that this wouldn't lead to any precision issues, however when ...
0
votes
1
answer
99
views
pset6 DNA works with small database but not with the large one
For some reason, when counting the times a substring repeats within a string (a STR in a DNA), my code fails with the large database. It is not a matter of overlapping sequences, because the numbers ...
0
votes
1
answer
124
views
pset6 - DNA - works for small.csv but not large.csv
import csv
import sys
with open(sys.argv[1], 'r') as file:
# stores data from small.csv in both dict and list form
dna_names_dict = csv.DictReader(file)
...
0
votes
1
answer
117
views
get_string function not working on pset6 2020
here is the problem
~/ $ python hello.py
Traceback (most recent call last):
File "/home/ubuntu/hello.py", line 1, in <module>
answer = Get_string("what is your name")
...
0
votes
1
answer
183
views
Mario (less) PSET6 Python Spacing help
Slightly embarrassed to be posting this as I could succesfully complete mario(less) in pset1 but apparently cannot replicate it in Python. My code is as follows:
h = int(input("h: ")) # get ...
0
votes
1
answer
90
views
pset6 mario more - there is a extra line in my output how do i get rid of it
o = input("Height: ")
if int(o) > 8 or int(o) <= 0:
o = input("Height: ",end = "")
i = int(o)
for j in range (i + 1):
# calculating number of spaces
n ...
0
votes
1
answer
24
views
Index to integer
How do i convert an index to an integer?
I tried int(index), that didnt work.
For example;
S = [a,b,c,d]
For index in S:
n = int(index)
print (n)
break
print ()
0
votes
1
answer
69
views
Pset6 Readability wrong Grade [duplicate]
Adjusted code to see how many letters, sentences and words counted. Noticed word count is lesser by one
from cs50 import get_string
text = get_string("Text: ")
letter = 0
word = 0
...
0
votes
1
answer
96
views
pset6 credit help with calculations in python
I am trying to convert my credit solution from C to python, but for some reason it is not working. Attached is my code and the problems
from cs50 import get_int
card, a, m, v = False, False, False, ...
0
votes
1
answer
120
views
Getting ONE error on check50 for DNA - ValueError: max() arg is an empty sequence - Where is the bug?
I'm so close the finish line, but I get error on one out of the 21 CS50 tests.
The test that is generating the error is number #2, which is:
python dna.py databases/small.csv sequences/2.txt
And I ...
0
votes
1
answer
103
views
DNA - Getting the highest key value from a defaultdict
I have come a bit on DNA and have managed to write an algorithm for adding the number of matches in the sequence to a defaultdict. But I'm having problems with how to get the maximum value from the ...
0
votes
1
answer
130
views
Pset6 Cs50 = Readability false output
I have been trying to complete readability python but on every result it is showing before Grade one
from cs50 import get_string
s = get_string("Text: ").strip()
num_letters, num_sentences,...
0
votes
1
answer
123
views
PSET6 - Readability: false grade output
from cs50 import get_string
text = get_string("Text: ")
letters = sentences = i = words = 0
length = len(text)
while i < length:
if text[i].isalpha():
letters += 1
//...
0
votes
1
answer
102
views
Pset 6 - Readability printing one grade off
I managed to translate readability from C to python, except it is printing one grade lower than what it is supposed to when testing.
What am I missing here?
"""
1) Ask user for phrase
2)...
0
votes
1
answer
109
views
check50 gives different output than my own for "18.txt" sequence. All others pass. Any thoughts/suggestions are appreciated
from sys import argv
import csv
import re
# Only run if argc is 3
if len(argv) == 3:
STRs = ["AGATC", "TTTTTTCT", "TCTAG", "GATA", "TATC", "...
0
votes
1
answer
174
views
PSET 6 DNA - Computing STRs
I am trying to compute the most repeated STR for each sequence in a dictionary called str_dict.
# compute STRs
i = 0
# stablish length of the sequence
length_seq = len(sequence)
# iterate through all ...
0
votes
0
answers
73
views
DNA pset6 My code works fine in small csv, but not large (Spoiler)
The problem happens with the count when i try to count STRs, it counts some str right and some wrong, which is strange for me, and when i deal with small csv all works fine.
can someone help me in ...
0
votes
1
answer
58
views
Print keys of CSV files in DNA pset6
I want to see what the keys of the reader dictionary are so I use the print(key) function. The result is all the lines of the dictionary. Why is that?
import csv
from sys import argv, exit
# Check if ...