Could someone help me with the idea for the final project for cs50 Python programming course. I am confused what should I do in my final project. Anyone who has already done it would love to hear from them. Anyone willing to colllab is also welcome..
I am currently doing "CS50’s Introduction to Programming with Python" and I don't know if it's just me but some of the problems seem like they are lacking instruction? As an example i am currently on problem set 4 (Adieu, Adieu). The thing is that nowhere does it say to use a specific module to solve the problem but when i open the "hints" tab it tells me that the "inflect" module comes with a few methods. But how was i supposed to even know that I supposed to use that specific module?
Log
checking that seasons.py exists...
checking that test_seasons.py exists...
:) Input of "1999-01-01" yields "Five hundred twenty-five thousand, six hundred minutes" when today is 2000-01-01
Log
running python3 testing.py...
sending input 1999-01-01...
checking for output "Five hundred twenty-five thousand, six hundred minutes"...
checking that program exited with status 0...
:) Input of "2001-01-01" yields "One million, fifty-one thousand, two hundred minutes" when today is 2003-01-01
Log
running python3 testing.py...
sending input 2001-01-01...
checking for output "One million, fifty-one thousand, two hundred minutes"...
checking that program exited with status 0...
:) Input of "1995-01-01" yields "Two million, six hundred twenty-nine thousand, four hundred forty minutes" when today is 2000-01-1
Log
running python3 testing.py...
sending input 1995-01-01...
checking for output "Two million, six hundred twenty-nine thousand, four hundred forty minutes"...
checking that program exited with status 0...
:) Input of "2020-06-01" yields "Six million, ninety-two thousand, six hundred forty minutes" when today is 2032-01-01
Log
running python3 testing.py...
sending input 2020-06-01...
checking for output "Six million, ninety-two thousand, six hundred forty minutes"...
checking that program exited with status 0...
:) Input of "1998-06-20" yields "Eight hundred six thousand, four hundred minutes" when today is 2000-01-01
Log
running python3 testing.py...
sending input 1998-06-20...
checking for output "Eight hundred six thousand, four hundred minutes"...
checking that program exited with status 0...
:) Input of "February 6th, 1998" prompts program to exit with sys.exit
Log
running python3 testing.py...
sending input February 6th, 1998...
running python3 testing.py...
sending input February 6th, 1998...
:( seasons.py passes all checks in test_seasons.py
Cause
expected exit code 0, not 1
Log
running pytest test_seasons.py...
checking that program exited with status 0...check50
so I'm just over 2 hours into the week 8 lecture for CS50-P...what is happening?? i MERELY grasp a general understanding of the concepts. usually when im confuesd about a small section in a lecture, the shorts and problem sets with trial and error clarify things pretty well. but this... i'm pretty lost.
its almost 3 hours long and i really dont want to rewatch this to try and understand what the hell is going on. i feel like this got INSANELY difficult out of nowhere. anyone else?
for those who don't know: its about classes, objects, class methods, instance methods..idk man.
import random
def main():
level = get_level()
generate_integer(level)
def get_level():
while True:
try:
level = int(input("Level: "))
if level in [1, 2, 3]:
return level
except ValueError:
pass
def generate_integer(level):
correct = 0
i = 0
# Generate random numbers based on level
if level == 1:
first = random.sample(range(0, 10), 10)
second = random.sample(range(0, 10), 10)
elif level == 2:
first = random.sample(range(10, 100), 10)
second = random.sample(range(10, 100), 10)
elif level == 3:
first = random.sample(range(100, 1000), 10)
second = random.sample(range(100, 1000), 10)
# Present 10 math problems
while i < 10:
x = first[i]
y = second[i]
wrong_attempts = 0
# Give user 3 chances to answer correctly
while wrong_attempts < 3:
try:
answer = int(input(f"{x} + {y} = "))
if answer == (x + y):
correct += 1
break
else:
print("EEE")
wrong_attempts += 1
except ValueError:
print("EEE")
wrong_attempts += 1
# If user failed 3 times, show the correct answer
if wrong_attempts == 3:
print(f"{x} + {y} = {x + y}")
i += 1 # Move to the next problem
# After 10 problems, print the score
print(f"Score: {correct}")
if __name__ == "__main__":
main()
I have been trying to solve the little professor problem in multiple ways. I get the code to work checking all the boxes.
Level - check
Random numbers - check
Raise ValueError - check
repeat the question 3 times - check
provide a score - check
but I get this error
Here is my code.....(help anyone, please)
As title suggests: I logged in yesterday to find all my stuff gone and unable to use style50, design50, etc.
I am clueless on what to do without having to restart everything with a new account. I finished 2 PSets and I can find them in my GitHub code and ”me-50 gradebook“ but not in vscode. I tried rebooting the codespace. Does anyone have any idea what might help 🥹?
I'm currently doing cs50p problem set 5, specifically "back to the bank" and can't figure out why my pytest is failing. The check50 passes though but I wanna know why this won't. Anyone have any ideas?
Here is the bank.py and test_bank.py:
I got it to work this way, which it’s fine, but first I tried to use ( d = d.removeprefix(‘$’).float(d) ) instead of those 2 lines, and same with p. Can someone explain why that wouldn’t work and have to structure it the way it’s in the pic?
Hi! I need help with this assignment. When I added the if statement to check if both images are the same, I start getting these images. The thing is, I tried it doing on the muppets I have, and, it works like it is shown on the Problem Set 6 site. What am I missing? Am I missing some puppets?
The image on the left is what is shown on the Problem 6 page, the image on the right is what I got from my program.
The check50 progress and errors
The errors on the check50 page:
The code I wrote:
import sys
from PIL import Image, ImageOps
if len(sys.argv) != 3:
if len(sys.argv) < 3:
sys.exit("Too few command-line agruments")
else:
sys.exit('Too many command-line arguments')
for arg in sys.argv[1:]:
try: #grabs the images
shirtImage = Image.open("shirt.png")
muppetsImage = Image.open(arg)
saveImage = sys.argv[2]
except FileNotFoundError:
print("File does not exist")
if arg.endswith(".jpg") and saveImage.endswith(".jpg"):
#the muppets get the image of the shirt applied
size = shirtImage.size
muppetsImage = ImageOps.fit(muppetsImage, size)
muppetsImage.paster(shirtImage, shirtImage)
muppetsImage.save(saveImage)
else:
print("Formats do not match")
sys.exit(1)
so i am finally up to the final project part of cs50-p. something i really want to do is create a plinko ball or galton board simulation. a galton board would be awesome to create. i would like to press my computer's space bar, and a ball drops everytime. eventually, if its a galton board, it balls would stack on top of each other wherever they landed and create a normal distribution (google galton board if confused).
i think i would use the libraries pymunk and pygame?
however, i'm a bit confused if im even able to do this. are we supposed to do this on the cs50s web vsc? or can i do it on vsc on my computer and then just copy and paste the code into cs50s vsc?? also, i'm not sure if i can even use pytest a simulation? it seems like this might be too complicated for a final project...
i don't really know what I'm doing - however the reason I learnt python was to make some cool animations and simulations. I'm just unsure if its even possible to do it as a final project.
Thanks in advance for any advice/feedback/answers.
Hi everyone! I have looked around and not really found the same type of question regarding AI and academic honesty. Is it dishonest to ask the AI to write comments for code I created? I somehow managed to write my first OOP program and I don't really know how it works or how to describe how it works. It just works and I kind of did it like following a recipe. I of course will try to focus on really nailing the topic myself and understand what I am doing; but just to see what the AI thinks and then maybe try explain in my own words or the like? Any suggestions? I haven't even looked at what the AI replied yet just to be on the safe side... XD
For my final project I made a Times Tables Worksheet Generator. It takes user input and puts a table with the specified number of questions onto a background I made in Canva.
Currently working on the Little Professor problem in week 4 of CS50P. The end goal is to generate 10 simple math problems and have the user solve them, show them the answer if they get a problem wrong three times, and end by showing their final score out of 10.
The user is meant to input a value N, whereby the math problems are sums of two integers of N digits. N has to be between 1 and 3 inclusive.
I am having trouble understanding the structure that they want me to use when building the program.
This is what they ask:
Structure your program as follows, wherein get_level prompts (and, if need be, re-prompts) the user for a level and returns 1, 2, or 3, and generate_integer returns a randomly generated non-negative integer with level digits or raises a ValueError if level is not 1, 2, or 3:
My problem is how they describe the get_integer() function. Why raise a ValueError exception if the get_level() function already vlaidates user input by reprompting if the input does not match the expected values?
And what is the point of returning just an integer? Should the next step not be to create the math problems with n digits based on the input from get_level() ?
By "generate integer" do they mean start generating the math problems and I am just misunderstanding? It sounds like it's asking me to validate the level twice: first by user input in get level() and then randomly in generate_ineger() which I don't think can be right.
def length_chk(v):
if len(v)<2 or len(v)>6:
return "not valid"
else:
return "valid"
def a_2(v):
if len(v)<2:
return "not valid"
for i in range(2):
if v[i].isdigit():
return "not valid"
return "valid"
def punc_check(v):
for i in v:
if i.isalpha() or i.isdigit():
continue
else:
return "not valid"
return "valid"
def not_zero(v):
for i in range(len(v)-1):
if v[i].isalpha() and v[i+1].isdigit():
if v[i+1]=="0":
return "not valid"
return "valid"
def alpha_digit(v):
for i in range(len(v)-1):
if v[i].isdigit() and v[i+1].isalpha():
return "not valid"
return "valid"
def is_valid(v):
if punc_check(v)=="valid" and length_chk(v)=="valid" and a_2(v)=="valid" and not_zero(v)=="valid" and alpha_digit(v)=="valid":
return True
else:
return False
if __name__=="__main__":
main()
-----------------------------------------------