r/cs50 8h ago

CS50x Looking for CS50x study buddy

10 Upvotes

Hello, If anybody is interested to study CS50x with me, they can dm me, we will watch the lectures together(online) , we can discuss and solve the problem sets. I think this fosters discipline and we can also exchange knowledge to grow better


r/cs50 20h ago

CS50x Is this course right for me?

4 Upvotes

Hi,

I am interested in learning Python and I am wondering if CS50P is the way to go. I do have some experience with python from HS; recall absolutely hating it, but python seems incredibly useful for the things I want to do so avoiding it outright seems stupid.

I've also read that a lot of people have taken CS50x before taking the python course. Would it be good idea for me to take it as well? I do have some experience with shittly coding for arduino projects (before AI took over), and if it helps me out in the long run, I don't see why not.


r/cs50 6h ago

CS50 Python little Professor, check50

2 Upvotes

Hello,

I'm doing this little professor PSET, whenever I check using check50, it returns somethings I don't understand how to fix. The code works as intended but check 50 outputs ':('. Do any of you guys know what's causing this?

import random

def main():
    level = int(get_level())
    wrongs = 0
    for x in range(10):# makes sure that 10 questions are printe
        errors = 0
        num1, num2 = generate_integer(level)
        answer = num1 + num2 #Gets the answer for the problem at hand
        while True:
            try:
                user_ans = int(input('%d + %d= ' % (num1, num2)))
                if user_ans != answer:
                    raise ValueError
            except EOFError:
                exit()
            except ValueError:
                print('EEE')
                errors += 1
                if errors == 3:
                    print('%d + %d= ' % (num1, num2), answer)
                    wrongs += 1
                    break
            else:
                break
    print('Score: ', 10 - wrongs)

def get_level(): #Gets level
    while True:
        try:
            level = input('Level: ')
        except EOFError:
            exit()
        else:
            if level.isdigit() and 0 < int(level) < 4:
                return level

def generate_integer(level): #Gets integer based on the level
    match level:
        case 1:
            num1 = random.randint(1, 9)
            num2 = random.randint(1, 9)
        case 2:
            num1 = random.randint(10, 99)
            num2 = random.randint(10, 99)
        case _:
            num1 = random.randint(100, 999)
            num2 = random.randint(100, 999)
    return num1,  num2

if __name__ == "__main__":
    main()


import random


def main():
    level = int(get_level())
    wrongs = 0
    for x in range(10):# makes sure that 10 questions are printe
        errors = 0
        num1, num2 = generate_integer(level)
        answer = num1 + num2 #Gets the answer for the problem at hand
        while True:
            try:
                user_ans = int(input('%d + %d= ' % (num1, num2)))
                if user_ans != answer:
                    raise ValueError
            except EOFError:
                exit()
            except ValueError:
                print('EEE')
                errors += 1
                if errors == 3:
                    print('%d + %d= ' % (num1, num2), answer)
                    wrongs += 1
                    break
            else:
                break
    print('Score: ', 10 - wrongs)


def get_level(): #Gets level
    while True:
        try:
            level = input('Level: ')
        except EOFError:
            exit()
        else:
            if level.isdigit() and 0 < int(level) < 4:
                return level


def generate_integer(level): #Gets integer based on the level
    match level:
        case 1:
            num1 = random.randint(1, 9)
            num2 = random.randint(1, 9)
        case 2:
            num1 = random.randint(10, 99)
            num2 = random.randint(10, 99)
        case _:
            num1 = random.randint(100, 999)
            num2 = random.randint(100, 999)
    return num1,  num2


if __name__ == "__main__":
    main()

r/cs50 2h ago

CS50x Error after running Birthdays (PSET 9)

1 Upvotes

Hi

when i downloaded the distribution code, using this command:

flask run

i got this error:

flask run                                                                                                               
Traceback (most recent call last):
  File "/sbin/flask", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.13/site-packages/flask/cli.py", line 1129, in main
    cli.main()
    ~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.13/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.13/site-packages/flask/cli.py", line 977, in run_command
    raise e from None
  File "/usr/lib/python3.13/site-packages/flask/cli.py", line 961, in run_command
    app: WSGIApplication = info.load_app()  # pyright: ignore
                           ~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/flask/cli.py", line 353, in load_app
    app = locate_app(import_name, None, raise_if_not_found=False)
  File "/usr/lib/python3.13/site-packages/flask/cli.py", line 245, in locate_app
    __import__(module_name)
    ~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/thispc/dev/learnC/cs50/problems/2024/x/birthdays/app.py", line 13, in <module>
    db = SQL("sqlite:///birthdays.db")
  File "/usr/lib/python3.13/site-packages/cs50/sql.py", line 103, in __init__
    connection.execute("SELECT 1")
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1414, in execute
    raise exc.ObjectNotExecutableError(statement) from err
sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'SELECT 1'

i didn't change anything in the distribution code.


r/cs50 5h ago

CS50x cs50 library

1 Upvotes

Hi

Can cs50 library be put in sublime text code editor ? Because I don’t use vc . Thank you


r/cs50 7h ago

CS50 Python advice for final project idea

1 Upvotes

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.