Questions tagged [python]

Code using the python language.

Filter by
Sorted by
Tagged with
0
votes
1answer
9 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
0answers
36 views

Mail CS50 Web - How to Send Email (API not working)

I'm very new to Javascript and working on mail, project 3 for CS50 web. I've been working on just sending the email initially, for about a week and I'm getting very discouraged. I can't seem to get ...
0
votes
0answers
61 views

What's wrong with my register function? (Pset9 - Finance)

Here's my register function in application.py: @app.route("/register", methods=["GET", "POST"]) def register(): """Register user""" ...
0
votes
2answers
23 views

mario more (python)

I've tried to make my code efficient by reducing the number of loops/print functions compared with my solution in c. My code works, but check50 isn't happy with it -- apparently an extra space is ...
0
votes
1answer
12 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
1answer
10 views

IDE.CS50.io can't get FireFox to full screen. Tried the F10 and F11

I'm trying to get Firefox to display IDE.CS50.IO in to full screen mode, which I thought was F10 or F11 and neither works. Thank you kindly, John
0
votes
1answer
29 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
1answer
26 views

Easy way to change python version to 3.8.7 in IDE

How do I change the python version to 3.8.7 in IDE I have tried installing python, and using the portable version but just cant find an answer.
0
votes
0answers
73 views

pset6 dna question regarding searching string for substring, two types of code give different output

I am currently following along ayoutube tutorial for pset 6 DNA, and have a small question regarding a specific function. In this function, it basically takes a substring and a string, and counts the ...
0
votes
0answers
13 views

Same SQL query works in IDE but not in pythonanywhere?

In my web application I have an sqlitequery that works perfectly as desired in my IDE, but always raises an SErver Error 500 in my pythonanywhere hosting. It is the exact same code: else: # ...
0
votes
1answer
31 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
1answer
19 views

Generate dynamic datefields from selected dropdown value sent to another route in Flask

EDIT With the good help of @DinoCoderSaurus, I realised that I overlooked adding a POST method to the datainput form and the routes also lacked GET and POST methods. Adding those modifications helped ...
0
votes
1answer
24 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
1answer
35 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
1answer
25 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
1answer
32 views

Can't update shopping cart for more than one item, works fine for a single item, otherwise only the first one gets updated

I am trying to update the quantity of the products in the shopping cart by changing the number in the dropdown. If the cart has two or more items then only the first one works and the qty doesn't ...
0
votes
0answers
39 views

CS50 PSET 6 DNA Just Returns First Name

I've been working on DNA for a while now and thought I was done, but there's a problem with my code. Everytime I run it, the program just prints the first name on the database, so either 'Albus' or '...
0
votes
1answer
44 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
1answer
70 views

CS50W Project 4 / Network - like counter not always saving to database

I was able to implement a like counter where it keeps track of all the likes. For some reason though, it randomly doesn't save the counter to the database when I submit the PUT request. I can't figure ...
0
votes
0answers
45 views

DNA works with most names except Alice and Albus

I really don't undersrtand why this is happening. I'm trying to finish DNA for pset6. Since more elegant methods were too difficult for me, I decided to compare all values in STR one by one against ...
0
votes
0answers
56 views

Final Project - Get sql to work html, python and flask

On my website for my final project I am able to enter the user info on the website, but the information is not being inserted into the sql table. I feel that I am not understanding something very ...
0
votes
0answers
50 views

CS50W Project 4 / Network - NoReverseMatch

I'm currently on the last project for CS50 Web called Network and am stuck on the Follower spec. I'm trying to get the url in the Following tab to bring you to the profile of the specific user that's ...
0
votes
0answers
33 views

CS50 Web Track - Finance: OSError: [Errno 99] Cannot assign requested address

I'm trying to create a standard 'forgot password' feature for my web application. The issue is, when the user types in their email address and clicks submit to receive a token after which they can ...
0
votes
0answers
10 views

JavaScript functionalities not applied when JavaScript code written in an external .js file for a flask application

I'm working on project2 of CS50's web programming using python and javascript. I've made a .htm file and I need to write some javascript code for the page. I first wrote the code in an external file ...
0
votes
0answers
17 views

Flask-WTF: input field rendered based on the user's selection

I'm trying to make a form where the user logs an action they've done. Because there were too many actions, they are now split into categories and then, based on which category the user chooses, the ...
0
votes
0answers
68 views

PSet 6 DNA: Not able to match variables to dictreader names

I've mostly completed my code for PSet 6, except for the last part where I need to match up the values against the list of names. I know how to get the maximum occurances of the STRs and state the ...
0
votes
1answer
25 views

CS50 Final Project / Personalized HTML path

I'm on the Final Project for CS50 and trying to make a simple website to type in General Tasks and get information within different Subjects. I decided to use Flask over Django, however now I'm stuck ...
0
votes
0answers
87 views

I'm stack with dna (pset6). can you please help me?

I have divided my code into three main pieces: 1- open the CSV file and read its contents into memory and open the DNA sequence and read its contents into memory 2- compute the longest run of ...
0
votes
1answer
78 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
0answers
38 views

DNA.py error: 'TypeError: unsupported operand type(s) for *: 'NoneType' and 'int''. It passes all but 2 of the tests

DNA.py is nearly finished, but it is failing the tests with sequence/15.txt and 16.txt. This is the error message: ~/pset6/dna/ $ python dna.py databases/large.csv sequences/16.txt Traceback (most ...
0
votes
0answers
30 views

pset6 Readability Python: Calculated grades too high

My code below returns incorrect grades. Often it is even two grades higher than it should be. Any ideas where is the mistake? letters = words = sentences = 0 for char in text: if char.isalpha(): ...
0
votes
0answers
73 views

TicTacToe task: PyGame display not rendering

For some reason, the PyGame TicTacToe display is not showing. It just hangs at this: This is the runner.py: import pygame import sys import time import tictactoe as ttt pygame.init() size = width, ...
0
votes
0answers
43 views

i dont know why i got error in the cs50 knight puzzle

from logic import * AKnight = Symbol("A is a Knight") AKnave = Symbol("A is a Knave") BKnight = Symbol("B is a Knight") BKnave = Symbol("B is a Knave") CKnight =...
0
votes
1answer
14 views

Final Project - if statement with regex not working?

Working on my final project and I'm stuck trying to edit user input. The below code should take the first string in a list and check if it's numeric. If it is, great, that's what I want, otherwise, I ...
0
votes
0answers
11 views

I'm wondering how to import Django through my Powershell and how to active Django in my PythonPath

I'm trying to import and active Django in my pythonpath, but I still have this message show up in my manage.py tab on VSCode (I'm using Windows 10 and am finding a lot of Linux inputs): ""&...
0
votes
1answer
108 views

'>' not supported between instances of 'tuple' and 'float'

First I checked for correlation: >>>pear_cor = df.corr(method='pearson') >>>pear_cor Now I have to go through the data and check for the following condition: >>>for val in ...
0
votes
1answer
220 views

Struggling with PSET6 DNA

I've been doing this for quite some time now, but I'm struggling to get the appropriate output. In the below code (which is incomplete as of now, but the main pieces are all on the board), I'm not ...
0
votes
1answer
124 views

Keyerror Won't Go Away

I keep getting a key-error in pset7, Houses: Traceback (most recent call last): File "import.py", line 24, in <module> names = cutting(row["name"]) KeyError: 'name' ...
0
votes
1answer
35 views

Finance index.html is not rendering values from my index function

I'm having some issues trying to render values on my index.html page. In my index function, I created a dictionary of values from my transactions table to grab each record of my share symbols, share ...
0
votes
0answers
97 views

how do I perform a search

This is project one for wiki and I am stuck this is my last thing to do. below are screenshots of the views.py, util.py and template. We are suppose to use the functions from util.py(This is the last ...
0
votes
1answer
15 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
145 views

Pset6 DNA Not matching to names in the database

The print statements seem to turn out what I hoped for up until trying to compare the STR counts to the database STR counts. I would just appreciate any pointers of where I'm going wrong thanks. ...
0
votes
1answer
18 views

Python - for loop not being executed, leading to NameError of variables defined in the loop

It's a simple Python program to find the number of primes until a certain number. The for z in range(1,y): loop does not execute, but rather execution jumps to the print(count," Pr...) statement ...
0
votes
0answers
20 views

I keep getting invalid syntax at else. I am trying to redirect a page

here is the code. I keep getting invalid syntax at else. Can someone explain why and help please.
0
votes
0answers
29 views

I keep getting - TypeError: unhashable typ

can't get page to redirect please help. I keep getting the error TypeError: unhashable type: 'dict' at line: return HttpResponseRedirect (reverse("encyclopedia:index", { "entries":...
0
votes
3answers
179 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....
1
vote
1answer
132 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
0answers
114 views

PSET6 DNA [SPOILER] Refactor

I have solved the problem however is there anyway to optimize this further? Also, how do I judge the time-space complexity of the same? import csv from sys import argv, exit from csv import reader, ...
0
votes
0answers
17 views

I have been trying to fetch book reviews from Goodreeads API

I got this sqlalchemy.exc.ProgrammingError sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'RowProxy' while trying to fetch book reviews from Goodreads API with the ...
0
votes
0answers
92 views

Confused about DNA in pset6

I've just started DNA, and I've got what seems to be a working algorithm to see if the count of the STRs in the database and sequence are the same, but it does not seem to be working. I've been a bit ...

1
2 3 4 5
7