Questions tagged [pset6python]
The pset6python tag has no usage guidance.
39
questions
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
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. ...
1
vote
1
answer
1k
views
PS6 Lines Of Code :( lines.py yields 2058 given 2058 lines of code in an open-source library file
I was wondering how to solve the last check on Lines of Code.
Expected Output: 2058
Actual Output: Too few command-line arguments
I recreated the file 2058.py with 2058 lines of code, and it worked. ...
2
votes
1
answer
2k
views
CS50 PSET6 DNA problem. Need advices to make my code more pythonic
I need some advises how i can improve my code and make it more pythonic. Cause i feel like my code is too long.
This is my solution to cs50 DNA problem:
import sys
import csv
if len(sys.argv) != 3:
...
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
"""...
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
3
answers
133
views
Program for dna not printing anything
I have written a program for DNA, but it's not printing anything. Code:
import csv
from sys import *
if len(argv) != 2:
print("Usage: python dna.py data.csv sequence.txt")
def maxcount(...
0
votes
3
answers
542
views
PSET6 Mario Python
I have been experiementing with this code for a couple hours and have come across an issue with each implementation. I can no longer put in any time at the moment so I figured I would go ahead and ask....
0
votes
1
answer
29
views
mario.py spacing issue
The program runs fine just that I keep getting an extra line after the user inputs so check50 rejects it because of the
\n before # #
def main():
hashHeight = height()
create(hashHeight)
#...
0
votes
1
answer
550
views
PSET6: DNA returns "no match"
import csv
import sys
def maxrepeats(sequences, substring):
# calculate maximum consecutive frequency for each STR
repeats = [0] * (len(sequences)+1)
for i in range(len(sequences)-len(...
0
votes
1
answer
144
views
What are the requirements for Week 6 Mario (more)? My code works but the grade book shows only 96% completeness
I tried two different variations but both reach 96% completeness
code 1:
from cs50 import get_int
while True:
height = get_int("Height: ")
if height < 9 and height > 0:
break
...
0
votes
1
answer
52
views
Stroring the header row from a csv file
Trying to store the header row of csv file, i.e. it's first row in a list after reading the file using reader().
Tried using next() and filednames() but none worked.
Could anyone guide me how to ...
0
votes
1
answer
547
views
DNA doesn't work with large database
My program gives valid output with small databases, but with large I always get "No match". Do you have any idea what may be the cause ? Belowe is my code, It may seem a little messy so if you find it ...
0
votes
1
answer
193
views
cs50 pset6 dna error while reading two file 8.txt and 9.txt
import sys
import csv
AATG, GATA, TATC, TCTG, AGATC, GAAA, TCTAG = 1, 1, 1, 1, 1, 1, 1
TTTTTTCT = 1
temp = 0
if int(len(sys.argv)) > 3 or int(len(sys.argv)) < 3:
print("Usage: python dna.py ...
0
votes
1
answer
310
views
My code solves for small csv but not for large. Could you guys help?
import csv
from sys import argv
if len(argv) != 3:
print("Usage: python dna.py arg1.csv arg2.txt")
exit(1)
database = open(argv[1])
sequence = open(argv[2])
s = sequence.read()
csv = csv....
0
votes
1
answer
961
views
PSET6 - DNA - Code fails to compare STRs to DNA text file
I have updated my code after making a number of amendments but am still a bit stuck! I don't think my STR_check_count is working properly as it always seems to return 0s and I'm also not sure if I'm ...
0
votes
2
answers
2k
views
pset6 Readability python: ugly code
I want to find the number of sentences of a text.
so I use:
n_sentence = text.count('.') + text.count('!') + text.count('?')
It's working and it's really ugly.
I've read the .count method but I ...
0
votes
1
answer
207
views
CS50 Bleep Incorrect Output
I am encountering a problem in CS50 Bleep. When censoring the message, the censored message consists of only one * for the entire word, rather than the length of the word. Here is my code:
from cs50 ...
0
votes
1
answer
1k
views
PSET 6: Sentimental [Mario.py(less)]: How exactly do I "reject input" in Python as specified in check50?
this is my first time posting on here and I'm trying to not break any rules but sorry if I do.
So, I followed the specification to make mario.py ( they are the same ones for mario.c ) in Sentimental ...
0
votes
1
answer
2k
views
CS50 Pset6: cash.py not returning number of coins used for change
Below is my code for pset6 of CS50, in which the user is prompted for an amount of change in the form of a float, which is converted into cents (e.g. 1.25->125), and the fewest coins needed to make ...
1
vote
1
answer
494
views
PSET6 CRACK (python)
I'm stuck on Crack (in Python). I wrote the following code, which I think should cover every case, however it runs for hours without finding a solution. Any thoughts/advice are appreciated.
from sys ...
0
votes
1
answer
30
views
Help reading this segment of python for Similiarities
i, j = len(s1), len(s2)
while True:
_, operation = matrix[i][j]
if not operation:
break
if operation == Operation.INSERTED:
j -= 1
elif ...
1
vote
1
answer
54
views
PSET 6 Similarities no display from log
I am working on the PSET6 more. My code passes the check50, and it displays the comparing table in the website. However, nothing is showing up for the log operations. I have around for answers but I ...
0
votes
1
answer
121
views
What is if __name__ == "__main__": doing in compare pset6?
I read the documentation, but I still can't pinpoint exactly what it is this line of code is doing in compare.
The code of compare is as follows:
#!/usr/bin/env python3
import argparse
import re
...
0
votes
1
answer
135
views
pset6 similarities How do I fill the rest of cells in edit distance algorithm?
I have the base cases but I don't know how to access them and compute to choose
the better operation and save a tuple in the cells
from enum import Enum
class Operation(Enum):
"""Operations"""
...
0
votes
1
answer
24
views
CS50 caesar.py. My program seems logically and syntactically fine, however my encryptions are never correct
import cs50
import sys
import string
def main():
# checks if there are two arguments
if len(sys.argv) != 2:
print("Incorrect amount of arguments")
return 1
# converts ...
0
votes
1
answer
179
views
pset6 mario(more).py check50 problems even when output is correct?
Working on mario (more).py port into python. My code works and it seems to output the correct things, but check50 does not like it. Can anyone point me in the right direction of where I am incorrect?
0
votes
1
answer
254
views
caesar python 3 using ord and chr - help please
i m trying to use ord and chr, but there is no result at the prompt ? i guess it s something with chr because earlier i was having an error of that ciphertext wasnt an interger, suggesting me to use ...
0
votes
1
answer
101
views
greedy with Pyhton 3 - how to code the largest coins first with Python
what would be the easiest way to use python for calculating the coins with the different quarter, dime, noony, penny ? I've seen some declaration with an array of values ? And waht i've done isn t ...
0
votes
2
answers
3k
views
mario pset6 PYTHON
i have trouble with the height value : when i enter Height of 1 or 25 (where Height must be higher than 1 and not higner than 23), it does print the error message but it also print the pyramid. What i ...
0
votes
1
answer
89
views
Python: location of variable in code
I have a functional version of "Vigenère" for pset6 but I noted an issue with the location of a variable that I would appreciate some insight on.
While iterating through each letter of the plaintext ...
0
votes
1
answer
224
views
vigenere python help
https://pastebin.com/DHEbSYWV
help i have been stuck for the last couple of day but i feel like i am really close just need the push in the right direction.
mainly for the this question.
how do i go ...
0
votes
1
answer
172
views
vigenere.py help
please guys i am really stuck, first of i have a question as to how to debug python code. like the debug50. and my second is with my code for vigenere.
import cs50
import sys
def main():
# make ...
0
votes
1
answer
32
views
Question about python dict syntax, how to past from one dict variable to another?
why does this code not work and gives back (TypeError: 'str' object does not support item assignment) :
sharesOwned = {'name': 'Apple.inc', 'symbol': 'AAPL', 'price':110, 'name': 'Google', 'symbol': '...
0
votes
1
answer
304
views
How do I add a condition to a for() loop in Python?
I'm porting crack.c to crack.py.
I crack.c, I am able to do this:
for (int i = 0; i < sizeof(letters) && strcmp(hash, solve) != 0; i++)
In order to break the for() loop if I find the ...
0
votes
1
answer
253
views
new to Python: for loop
I see David using a lot of for loops like this, usually in a table:
for (singular variable) in (plural variable)
e.g.
for registrant in registrants
He doesn't actually declare the singular ...
0
votes
2
answers
257
views
Caesar.py (PSET 6) ValueError: invalid literal for int() with base 10
I converted my C code into Python, but keep getting this error: ValueError: invalid literal for int() with base 10.
This is what my terminal is returning:
$ python caesar.py 3
hello
Traceback (most ...
0
votes
1
answer
42
views
pset6 - greedy doesn't print answer- just returns the input. Where have I gone wrong?
import cs50
while True:
print ("O! Hail!, How Much Change Is Owed?")
n = cs50.get_float()
if n >= 0:
break
q = 25
q1 = 0
d = 10
d1= 0
ni = 5
ni1 = ...
0
votes
1
answer
167
views
pset6 (python) caesar prints capital letters and shifts non-alpha chars
import cs50
import sys
if len(sys.argv) != 2:
print("usage: python caesar.py key")
exit(1)
else:
key = sys.argv[1]
c = int(key) % 26
cphtxt = 0
if c < 1:
print("...