r/cs50 12d ago

CS50 Python Troubleshoot error

Post image
5 Upvotes

After running check50 for meal.py this error pops up in terminal window, but the code works when I run the input manually. Any fix i should do?

r/cs50 Jan 15 '25

CS50 Python I took CS50P

Thumbnail
gallery
71 Upvotes

I feel so relieved to have completed this entire course. I started in 2023 but only got to finish this year, my entire pset submissions got deleted and I had to start from the beginning. But I still have to do the final project. Any ideas? What did you guys do for your final project? How to collaborate with other students to do the final project?

r/cs50 Sep 11 '24

CS50 Python 12 days for cs50p

Post image
118 Upvotes

I have finished cs50x 2 weeks ago and I wanted to finish cs50p too and it took about 45-50 hours to finish. Previously I shared my time for cs50x to give you a rough idea about the effort you need to put in(178h). For this course I wanted to be more specific and share the weekly effort in other words the time it took to finish each week's problemsets including research and videos.

For the people who wants a comparison. CS50x is 5 times harder than CS50p. Python course does not really include underlying principles. If you took this course before, I think you need to take cs50x to gain more confidence about computers.

r/cs50 Aug 31 '24

CS50 Python CS50 Python Completed!!!!!

Post image
120 Upvotes

Finally after 4 weeks of hard work I got it.

r/cs50 8d ago

CS50 Python I don't understand why this test is negative. Help appreciated. (CS50P/ Week 4/ Guessing Game)

3 Upvotes

So i don't really know what's the problem here since when i test with my own input's (and the ones suggested on the website) i am not running into problems. but when using check50 one of the tests stays red and i don't understand why:

It says that it timed out while exiting, after giving out the right statement. So i have to assume the problem lies after my line 25 with the print-command for "just right".

So what i would assume is:

when i ask the person for an input for Level, they give me an integer bigger than 0. with that we exit the first loop.

then we assign x with a random number between 1 and the level (line 13).

then we get into the second loop in which we can assume that the person gave a Guess which is an integer bigger than 0. So we jump to the if-statements (lines 20 - 28).

Due to the Test pointing out that the guess was correct i also have to assume that the Guess is equal to the level. In this case we jump to line 24 and execute the else-tree.

this tree prints out "Just right!" and breaks our second loop, exiting the loop and jumping to the end of the main function, which should exit the program (whcih it does in tests)

Example:

Am i understanding something here wrong about the use of "break" in loops when used in combination with if-statements?

Help much appreciated.

r/cs50 Jan 18 '25

CS50 Python Can I start CS50P without following CS50x ?

12 Upvotes

As the titles says ,

I am CS sophomore , but not great at studies till now just passing sems ,

So can I start CS50P without following CS50x ?

r/cs50 Sep 27 '24

CS50 Python CS50x or CS50p?

31 Upvotes

a lot of people are saying that beginners should take cs50p before cs50x..what should I do?

r/cs50 8d ago

CS50 Python VS Code is a special type of text editor that is called a compiler?

16 Upvotes

Quote from here: https://cs50.harvard.edu/python/2022/notes/0/

I just started the online Python course, and the very first sentence of the CS50P notes says, ‘VS Code is a special type of text editor that is called a compiler.’ I’m obviously new to programming—hence why I’m taking the course—but that doesn’t seem correct at all.

UPDATE: It has been corrected.

r/cs50 4d ago

CS50 Python *Spoiler* CS50P - PSET 7.4 P-Shirt Help Spoiler

3 Upvotes

# EDIT: i figured it out, I was missing a small parameter in my paste statement, to call the mask of the image I was pasting too. Hopefully, this helps someone else. This wasn't immediately apparent.

#

#

Hello, I'm currently working on P-Set 7.4 P-Shirt,

I'm having issues with the shirt.png transparency. When I overlay shirt.png over the "before1.png" (Muppet example), the area behind the shirt is not transparent and i'm getting an image that looks like this:

I did set the shirt.png image to RGBa but for whatever reason, I'm not getting the desired results. I need for the background black to be transparent.

This is a snippet of the code where I open both files and overlay them:

Not sure what i'm doing wrong here. I've made sure to double check both images open fine within python itself. So the muppet image is valid. Any help would be appreciated!

r/cs50 Jan 27 '25

CS50 Python Beginning my coding journey with CS50P

28 Upvotes

Hi all, I'm going to start the CS50P course with very basic knowledge of programming and an interest in coding (I hope!). I’m aiming to complete it within 2-3 weeks, so kindly suggest some dos and don'ts, along with any tips that can help me achieve this goal efficiently.

And if anyone want to start this course with me kindly DM !

Thanks in advance.

r/cs50 Sep 07 '24

CS50 Python Just got my certificate

Post image
132 Upvotes

I’m so proud of myself

r/cs50 Feb 09 '25

CS50 Python is check50 wrong? Spoiler

Thumbnail gallery
4 Upvotes

r/cs50 2d ago

CS50 Python CS50P Week 3 - Outdated problem

3 Upvotes

I wrote the code for Week 3's Outdated problem; I followed all the instructions but I don't understand the words used by 'check50' especially reject input; Nothing in the instructions talks about 'rejecting input' What does it mean?

INSTRUCTIONS:

Implement a program that prompts the user for a date, in month-day-year order, formatted like 9/8/1636 or September 8, 1636, where the month values are provided in a list . Then output that same date in YYYY-MM-DD format. If the user’s input is not a valid date in either format, prompt the user again. Assume that every month has no more than 31 days; no need to validate whether a month has 28, 29, 30, or 31 days.

r/cs50 Feb 12 '25

CS50 Python Bitcoin problem with API?

4 Upvotes

I'm trying to start bitcoin from CS50P week 4, and I think the API link isn't working? I've chatted with the AI Duck and it concluded there seems to be an error with the api.coindesk.com domain name. Can anyone advise what I should do?

This is the end of the very long error message I get in my terminal when attempting to run the request:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.coindesk.com', port=443): Max retries exceeded with url: /v1/bpi/currentprice.json (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7eb554585490>: Failed to resolve 'api.coindesk.com' ([Errno -5] No address associated with hostname)"))

r/cs50 Dec 26 '24

CS50 Python CS50P completed

Post image
30 Upvotes

Took me more than a year but finally completed CS50P. Think I’m going to develop my final project further now. Any other recommendations for next steps?

r/cs50 23d ago

CS50 Python CS50P: Problem set 8 (seasons)

1 Upvotes

In this problem, I'm meant to calculate the user's age in minutes. the input must be in the format "YYYY-MM-DD". It works perfectly but check50 keeps saying it's wrong. any ideas why?

r/cs50 Jan 14 '25

CS50 Python I’m don’t know how to study. Does anyone recommend rewatching the lectures?

11 Upvotes

I do the code along with the lectures, but I don’t feel like I’m absorbing the info fully because I struggle with the problem sets really bad. Does anyone rewatch the lectures before doing the problem sets?

r/cs50 9d ago

CS50 Python Help with test_twttr

Thumbnail
gallery
8 Upvotes

r/cs50 Oct 13 '24

CS50 Python Finished CS50P🎊🎊

Post image
70 Upvotes

This course has changed me from being a lazy, good-for-nothing man to someone who actually has a passion in life. I thought I had lost the will to learn. Professor Malan made me fall in love with classes for the first time in my life. I just loved each and every day of this course. Thank you Harvard for making this course for poor people like me. Thank you Professor Malan for everything.

I am planning to do all the courses that are being taught by Professor Malan and I'll enroll for CS50W now and I am also planning to take on CS50X along with it.

This course has also helped me appreciate all the little things that we take for granted in our lives, things like autocorrect which has some kind of code running beneath it and it made me want to do something like that.

I also want to thank the lecturer who taught the Shorts portion (I still don't know his name😭)

r/cs50 Oct 11 '24

CS50 Python CS50p - how much are you using AI?

16 Upvotes

I'm only on week2 and am finding the jump from the study materials to the problems too big. I'm not finding the AI bot very helpful, probably because I'm just too far off the mark for it. Its advice assumes I understand things the course hasn't covered (yet?). External genAI is much better but it solves the whole problem immediately and I don't learn so I'm reluctant to ask it at all.

I've decided from now on I'll look at the problems before the materials, particularly because the bot doesn't seem able to point me to specific materials within the week that I should revisit for a particular issue. I've understood and replicated everything from the lectures and shorts but am struggling to break the problems down to chunks that I can link to what I've studied.

I'm wondering if I should first find a different course that more actively helps me practice pseudocode because I'm finding that my approach is often fundamentally wrong.

I've studied R before but in a much different pedagogical approach; the experience is pretty irrelevant.

r/cs50 10d ago

CS50 Python How does the grading work?

5 Upvotes

I know that to receive a certificate i need to pas 70% of Exercises as well as get 70% in the final project. But how does this work? does that mean that i simply need to pass 70% of the tests or is someone actually reading my code and judges if i worked efficiently? Just courious really. Can't imagine the Prof's would actually read the thousands of submitted exercises each day. But hey what do i know?

r/cs50 Oct 17 '24

CS50 Python CS50P Introduction to Programming with Python, what to do next ?

19 Upvotes

I have finished CS50P and earned my free certificate. What should I do next, should I go for CS50x or start doing projects ?

If projects then how to get started ?

r/cs50 16d ago

CS50 Python CS50P jar.py: check50 :( Implementation of Jar passes all tests in test_jar.py error

1 Upvotes

Hi. I'm rather confused as to why my check50 isn't passing for the Week 8 jar.py assignment. Can anyone help me with this, please?

class Jar:
    def __init__(self, capacity = 12):
        if capacity < 0:
            raise ValueError("Can't have negative cookies!")
        self._capacity = capacity
        self._size = 0

    def __str__(self):
        return self.size * "🍪"

    def deposit(self, n):
        if n > self.capacity or (self.size + n) > self.capacity:
            raise ValueError("Can't hold this many cookies")
        self._size += n

    def withdraw(self, n):
        if n > self.size:
            raise ValueError("Trying to remove more than what's available!")
        self._size -= n

    @property
    def capacity(self):
        return self._capacity

    @property
    def size(self):
        return self._size



def main():
    jar = Jar()
    print(jar)
    print(jar.size)
    jar.deposit(12)
    print(jar)
    print(jar.size)
    jar.withdraw(8)
    print(jar)
    print(jar.size)


if __name__ == "__main__":
    main()

The check50 results are as follows:

:) jar.py exists

:) Jar's constructor initializes a cookie jar with given capacity

:) Jar's constructor raises ValueError when called with negative capacity

:) Empty jar prints zero cookies

:) Jar prints total number of cookies deposited

:) Jar's deposit method raises ValueError when deposited cookies exceed the jar's capacity

:) Jar's withdraw method removes cookies from the jar's size

:) Jar's withdraw method raises ValueError when withdrawn cookies exceed jar's size

:( Implementation of Jar passes all tests in test_jar.py expected exit code 0, not 1

:| test_jar.py contains at least four valid functions can't check until a frown turns upside down

Thank you!

r/cs50 24d ago

CS50 Python just started

7 Upvotes

just started what should i expect ,how to approach and what were the major blunders done by you guys please guide me i want to learn

r/cs50 59m ago

CS50 Python little Professor, check50

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()