Questions tagged [pset6]
The problem set for Week 7
845
questions
0
votes
0
answers
43
views
pset6 DNA problem with sequence 18
I have solved all the cases but sequences 18.txt always gives me "Harry" result but needs to have "No Match" result!
I tried to debug but always the same results. Here is my code:
...
0
votes
1
answer
92
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
54
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
76
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
69
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
44
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
0
answers
54
views
There is something wrong with the DNA file
I am doing Problem Set 6 DNA. And it looks like the data given to me in the large file is incorrect. When I am running my code with small file it works fine. But when I run with large file it is not ...
0
votes
0
answers
37
views
My DNA program is showing me this error repeatedly
The error is written below:
Traceback (most recent call last):
File "/home/ubuntu/pset/pset6/dna/dna.py", line 54, in <module>
main()
File "/home/ubuntu/pset/pset6/dna/dna....
0
votes
0
answers
29
views
Pset6 [DNA] . Works when I check by hand, but doesn't correctly identify names with check50.(doesn't return anything)
import sys
import csv
def main():
if len(sys.argv) != 3:
print("Should be 3 command-line arguments ")
sys.exit(1)
with open(sys.argv[2], 'r') as f:
for line ...
0
votes
1
answer
57
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
39
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
92
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
30
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
60
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
89
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
81
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
77
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
45
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
90
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
145
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
82
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
262
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
70
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
79
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
80
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
92
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
33
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
93
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
40
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
22
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
45
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
73
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
111
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
66
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
78
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
65
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
53
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
77
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
163
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
1
answer
70
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
52
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 ...
0
votes
1
answer
63
views
Pset6 mario more didn't pass the test
I run through my code many times and didn't find anything wrong with it but the result printed out wasn't right:
from cs50 import get_int
while True:
height = get_int("How high is the pyramid?...
0
votes
1
answer
97
views
Computing consecutive STR is sometimes off by a little (Spoiler!)
My code works fine for the small csv file; however, when I get to the big csv file, my counts for the number of consecutive STR are less than the actual value by about 1 or 2.
Here is my code:
import ...
0
votes
1
answer
309
views
Count the number of spaces in a string in python
I was trying to figure out how to calculate the number of spaces in a string when i came across this code online. Can someone please explain it?
text = get_string("Enter Text: ")
spaces = ...
0
votes
1
answer
152
views
pset6 count STR in the DNA sequence issues
so i m a bit confused...i have been testing my code using the small database and what i have so far produced what i expected ....
more specifically the STRcounts (i marked that part #?????). it is ...
0
votes
1
answer
279
views
PSET 6 DNA: How to get number of repeats for each value of STR's? [SPOILER: Full code]
I have written a code to count the highest number of consecutive repeats of specific DNA substring sequences in a long string of DNA...or so I thought. While my code can correctly count the longest ...
0
votes
1
answer
188
views
DNA: Errors in sequences.3 and 18.txt
I have worked hard on writing codes for DNA. Everything works except for sequences/18.txt, which returns "Harry" instead of "No match". The problem still exists in spite of several ...
0
votes
1
answer
82
views
Pset6 Mario More
I submitted my code for Mario More in Python. Although it works properly by my own checks it gives me a 6/9 when submitted.
from cs50 import get_int
def main():
n = height()
for i in range(n)...
0
votes
1
answer
236
views
Pset 6 DNA: improving efficiency
I've successfully submitted the below code on Pset6 for the DNA problem. But, I know my 'get_longest' function is a horror show as far as efficiency is concerned: I am doing a series of checks that I ...
0
votes
1
answer
75
views
Issue with recording STRs in memory (PSET6 - DNA)
I'm trying to record the number of repetitions of each str in the sequence. I created a dictionary as below and another empty dict because i couldn't update a dict while iterating through it. But for ...