Questions tagged [python]
Code using the python language.
359
questions
0
votes
1
answer
51
views
Lab 6 World-Cup | Timed out issue
Check50 says, and I qoute, "timed out while waiting for program to exit" in some of the criterias, I don't understand what infinite loop is causing this. Can you help?
# Simulate a sports ...
1
vote
1
answer
39
views
Seasons of love doesn't pass the test_seasons.py
I'm having problems passing the test_seasons.py on check50, if I run "pytest test_seasons.py" all the seven tests I have pass but if I run the command of "check50" it shows red. My ...
0
votes
0
answers
11
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
18
views
My code look correct and work correctly for all other sequence but check50 says sequence/18 is wrong, expected "No match" not harry
import csv
import sys
global y
def main():
y = 0
x = 0
t = 0
# Check for command-line usage
if len(sys.argv) != 3:
sys.exit("Usage: python dna.py data.csv sequence....
-1
votes
1
answer
8
views
Hi all, Please peruse the Python script, it does produce a Tkinter page with the correct buttons etc however it wont perform the calculation, thanks
import tkinter as tk
from math import radians, cos, sin, asin, sqrt
def calculate_distance():
lat1 = float(entry_lat1.get())
lat2 = float(entry_lat2.get())
lon1 = float(entry_lon1.get())
lon2 = float(...
0
votes
1
answer
14
views
No rule to make target distance
distance/ $ make distance
make: *** No rule to make target 'distance'. Stop.
distance/ $ code distance.py
distance/ $ make distance
make: *** No rule to make target 'distance'. Stop.
distance/ $
...
0
votes
0
answers
18
views
Error EACCES. File won't save!
I get this error intermittently. Basically the file won't save.
Failed to save 'test_seasons.py': Unable to write file 'vscode-remote://codespaces+kslicker-code50-90402590-5gr754v9rf74wq/workspaces/...
0
votes
0
answers
7
views
Code isn’t reading in Terminal
Ive used mikdir indoor for the folder and code indoor.py for the file. I used cd indoor to set the directory and entered in python indoor.py. All of that was good until testing the code. I’m getting ...
0
votes
1
answer
59
views
Cannot run program that imports pyttsx
I'm trying to recreate the program from class to use cowsay and pyttsx to say any phrase.
import cowsay
import pyttsx4
engine = pyttsx4.init()
this = input("What's this? ")
cowsay.cow(this)...
0
votes
2
answers
43
views
TypeError: 'NoneType' object is not subscriptable in PSET9, but working manually
I am working on pset9 Finance. I have implemented the functionality for purchasing stocks, and it works well when I manually test it. However, when I run the CS50's check50 validation, it returns an ...
0
votes
0
answers
40
views
PageRank Project not getting accepted
def iterate_pagerank(corpus, damping_factor):
"""
Return PageRank values for each page by iteratively updating
PageRank values until convergence.
Return a dictionary ...
0
votes
1
answer
133
views
CS50P PSET5: test_bank passes Pytest but not check50
When I test manually with the check50 input test strings I don't get an error.
However, here are the results when I run check50.
Results for cs50/problems/2022/python/tests/bank generated by check50 ...
0
votes
1
answer
51
views
My code looks and works correctly but check50 fails
import csv
import sys
global y
def main():
y = 0
x = 0
# Check for command-line usage
if len(sys.argv) != 3:
sys.exit("Usage: python dna.py data.csv sequence.txt")
...
0
votes
0
answers
53
views
Vanity Plate problem set basic doubt
Please refer to below mentioned image:
Wanted to understand why ECT088 should have valid output when there is clear statement/ condition "The first number used cannot be a ‘0’.”
What is the logic?...
0
votes
0
answers
6
views
Why its giving output Not ok, even if it is a Alppha string?
Why its giving output Not ok, even if it is a Alppha string?
0
votes
0
answers
11
views
Runtime Error when adding two numbers using python
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return ...
0
votes
0
answers
8
views
PSET9/Finance Blocked by login/register issue
Attached the issue that I'm getting and I don't understand what I did in my code that was wrong.
Here's register function. Am I missing something here...?
def register():
"""...
0
votes
0
answers
42
views
Reverse for 'entry' with no arguments not found. 1 pattern(s) tried: ['(?P<title>[^/]+)\\Z']
I'm getting this error from Django project and here is my code
in urls.py
urlpatterns = [
path("", views.index, name="index"),
path("<str:title>", views....
0
votes
0
answers
33
views
Project 1 Wiki, Correct directory or venv path
This is probably too simple a problem, but I keep getting stuck, so here I am.
Prior to project one, in lecture 3 for Django, I followed along with the lecture and was able to overcome any hiccups ...
0
votes
0
answers
77
views
fixing an 'from github import Github' error
I continue to receive this error message for when I attempt to import GitHub to my visual studio code in order to have it read the repository.
ERROR MESSAGE:
ModuleNotFoundError: No module named ‘...
0
votes
0
answers
51
views
Professor Code Rejected by CS50 Check50
When submitting the code to check50, I get the following error message:
":( Little Professor accepts valid level
Cause: Timed out while waiting for program to exit."
When I run the program ...
0
votes
1
answer
22
views
Output not as expected
Why in output Twitter is getting printed, only twwtr should be printed as per my understanding.
0
votes
1
answer
106
views
Check50 says the answer is wrong in the outdated.py problem but it is right. Help, how to solve?
I'm new here.
I'm solving the Outdated problem. It seems it works as expected but, check50 says it is wrong.
When I do it manually it works.
Manually:
Date: 9/8/1636
1636-09-08
Results from check50:
...
0
votes
1
answer
55
views
CS50 AI -Degrees. Logical problem
I kind of finished the CS50 AI degree problem but I have an issue with the logical part of it.
Instead of returning the shortest path, my code has unintentionally been designed to return the whole ...
0
votes
1
answer
17
views
What's the issue
my code is giving output as per expectation.
0
votes
1
answer
19
views
please clear the basic doubt
Why OK is displayed when i entered the integer 45 ?
1
vote
2
answers
182
views
except EOFError: can't end program with control-d
I have a little problem with EOFError in Python. There is instruction to quit program with control-d but on my win 11 (firefox browser) this shortcuts doesn't work. My programs are correct, undergo ...
0
votes
0
answers
33
views
CS50 python problem set 1 bug
about the problem set 1 (bank), I have wrote the "bank" codes correct and tested several times and it works but still edx check think the codes are incorrect.
is it vocode or GitHub bug or ...
0
votes
1
answer
224
views
CS50 2023 Finance Check50 issue
There is no way to get rid of the following check50 error:
:( logging in as registered user succeeds
application raised an exception (see the log for more details)
I found through googling that in ...
0
votes
0
answers
53
views
cs50ai traffic.py has all requirements already satisfied from requiremnts.txt but keep getting ImportError: libGL.so.1
I have all requirements installed to run traffic.py but every time I run it, I get the following error message when I run python traffic.py gtsrb or python traffic.py gtsrb-small.
"ImportError: ...
0
votes
1
answer
18
views
PSET6 DNA storing STR subsequences in a dictionary
I am working on one of the TODOs where the longest match of each short tandem repeat (STR) needs to be found from the DNA sequence read—written as just "sequence" in this code. To check ...
0
votes
1
answer
731
views
check50 error expected exit code 0, not 1
I was following python programming course and with the unit test chapter I updated the main file and the test files as described in this problem set page. Now I'm sure that my tests are running fine ...
0
votes
1
answer
65
views
Finance app - object is not subscriptable
I have problems with pset 9 finance.
Since days I try to figure out what is wrong with my code for the sell route.
I know that there a handfull of similar questions on StackExchange/StackOverflow but ...
0
votes
2
answers
11
views
Why does this class not require the __init__() method? This example is from the constants section of the Et Cetera lecture
class Cat:
MEOWS = 3
def meow(self):
for _ in range(Cat.MEOWS):
print("meow")
cat = Cat()
cat.meow()
0
votes
1
answer
416
views
CS50P-pset5-test_fuel: My code for fuel.py did not raise ZeroDivisionError
My code for fuel.py:
def main():
while True:
# Prompting the user to enter a fraction
fraction = input("Fraction: ")
# Calling check_fraction() function to ...
0
votes
1
answer
185
views
CS50p pset4 Little professor "timed out while waiting for program to exit"
could someone help in this? CS50P pset4 Little professor works fine when I run it on terminal, but check50 disagrees. When the user gives the third answer, should he see 'EEE' like after the first and ...
0
votes
1
answer
286
views
Outdated - Problem set 3
months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
...
0
votes
1
answer
162
views
pset 3- outdated.py... I can't figure out the error
I have done this:
# list of all months
months = ["January", "February", "March", "April", "May", "June", "July", "August&...
0
votes
1
answer
302
views
iterate pagerank issue in cs50ai pagerank project
My PageRank results from iteration come up more than .001 off the initial sampling result but I am not sure where I went wrong. please see code below followed by results. Any help would be greatly ...
0
votes
2
answers
123
views
What is the meaning of ”can't check until a frown turns upside down“?
This is my code for the CS50 week 1 homework called Meal time and it can work correctlt.
def convert(time):
y,z = time.split(":")
y=float(y)
z=float(z)
time=y+z/60
return(time)
def main():
...
0
votes
0
answers
11
views
web programming with python and javascriptLecture 4 : invalid literal for int() with base 10
I'm stuck on lecture 4, I keep getting :
Exception Value: invalid literal for int() with base 10: ''
Here is the code :
def book(request, flight_id):
if request.method == "POST":
flight = ...
0
votes
0
answers
21
views
My program is exiting unitentionally due to my class or regular expression, why?
For Pset 8 seasons of love, I am struggling to get my code working. I still have to add in the inflect code to put my output into words; however, I am running into the issue that my program is always ...
0
votes
2
answers
708
views
Why does it say my test for numb3rs passes all checks when it does not?
I manually checked my code for the numb3rs regular expression (works perfectly) project and my code is as follows:
import re
import sys
def main():
print(validate(input("IPv4 Address: ")...
0
votes
1
answer
89
views
What does "submit the user’s input via POST to /register" mean?
I'm doing "Finance" from Week 9. In register implementation, says:
Submit the user’s input via POST to /register.
I researched, but I can't understand what does that mean. I inserted the ...
0
votes
1
answer
155
views
game.py rejects non-numeric level expected program to reject input, but it did not
while True:
try:
m = input("Level: ")
m = int(m)
x = random2.randint(0,100)
while True:
try:
n = input("Guess: ")
...
0
votes
1
answer
608
views
CS50 Python Problem Set 7 Working 9 to 5 check50 fails
I am attempting to finish the problem set. I have posted the code, and the testing code I've written. The check50 passes my main program, but fails the testing code, I have posted the check50 result ...
1
vote
1
answer
394
views
(Edited) CS50P - PSET 4 - LITTLE PROFESSOR
I've made some corrections, the answers for CHECK 50 are the same though. I'm not getting it, the workability of the code is fine (working as expected, even when testing by 'How to Test' section).
I ...
0
votes
3
answers
1k
views
CS50P - PSet 8 - Seaons of love - seasons.py
I am trying to follow instructions for the exercice Seasons of Love on PSET8. Unfortunately, while running the "check50" command, it seems that I missing one input in order to replace "...
1
vote
2
answers
676
views
my code works fine and passes al test in test_fuel.py but i dont know why i get this error
:) test_fuel.py exist
:( correct fuel.py passes all test_fuel checks
expected exit code 0, not 2
:| test_fuel catches fuel.py returning incorrect ints in convert
can't check until a frown ...
0
votes
1
answer
129
views
split function in python seems to perform a strip as well?
I am following CS50P and I developed the outdated problem (last exercise in pset3)
My code works ok, and I got 100% - all checks passed. However, I then checked for other solutions online to help me ...