#๐Ÿ”’ Beginner code

39 messages ยท Page 1 of 1 (latest)

eager heathBOT
#

Hey @frail viper!

Please edit your message to use a code block

You are using the wrong character instead of backticks. Use ```, not '''.

Also, add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
#

@frail viper

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frail viper
#
from datetime import datetime

class WorkerData:
    ProductiveDays = ["Monday", "Tuesday"]

    def __init__(self, name, age, position, salary, needs, starting_hour):
        self.name = name
        self.age = age
        self.position = position
        self.salary = salary
        self.needs = needs
        self.starting_hour = starting_hour

    def __str__(self):
        return (f"Worker Profile:\n"
                f"Name: {self.name}\n"
                f"Age: {self.age}\n"
                f"Position: {self.position}\n"
                f"Salary: ${self.salary}\n"
                f"Needs: {self.needs}\n"
                f"Preferred Start Hour: {self.starting_hour}\n"
                f"Most Productive Days: {', '.join(self.ProductiveDays)}")

while True:
    try:
        nameinput = input("Hey, what's your name? : ")
        ageinput = input("How old are you? : ")
        companydomain = "Software Engineering"
        avragesalary = 3000.00
        commonneeds = "coffee"

        shinput_raw = input("At what hour would you be the most comfortable to work? (HH:MM format) : ")
        
        # Validate time format
        starting_hour = datetime.strptime(shinput_raw, "%H:%M").time()

        WorkerProfile = WorkerData(nameinput, ageinput, companydomain, avragesalary, commonneeds, starting_hour)
        print(WorkerProfile)
        break  # Exit the loop after a successful run

    except ValueError:
        print("Invalid time format. Please enter it like HH:MM (e.g., 07:00 or 13:45).")
    except Exception as e:
        print("Something went wrong :( Please try again!")
#

wrote this in 20 mins with little to no help from chatgpt , am i on the right path ?

#

i only used it for the format error on the 00:00 format as i didnt get into libraries yet

#

where should i be classified based on "skill" ?

stiff tusk
#

how much is 'little to no help' from chatgpt? how much code did it provide you, even if it is something you edited.

frail viper
# stiff tusk how much is 'little to no help' from chatgpt? how much code did it provide you,...

it provided me "full code" with 2-3 lines changed which i understood fairly. everything is pretty much "invented" by me besides the from datetime import datetime and the usage of it in the code and except Exception as e: because i completly forgot how the "Exception" was called for general errors and not ValueError , TypeError or smth specific. ChatGPT also added the extra valueerror expections which i didnt ask for but it was welcome

#

also suggested i should use str method which i didnt know of until now (i studied classes and methods today but skipped some important stuff due to an event)

stiff tusk
#

Well since chatGPT wrote basically all of it for you I would say there isnt much skill there since you didnt actually create anything. But understanding it is a good start

frail viper
#

and some part of it

#

when i said he gave me full code i mean he gave me the code i gave him with 2-3 lines changed

#

like i said , if it wasnt for him , i would've got stuck when printing the class instance as the output was an object offset(idk if thats how its called)

stiff tusk
#

So you wrote all of it on your own like from memory and then had chatgpt fix some things? Did it work properly before you gave it to chatgpt?

frail viper
# stiff tusk So you wrote all of it on your own like from memory and then had chatgpt fix som...

it worked properly in the sense of no errors , but not as intended since i printed the WorkerProfile without having

    def __str__(self):
        return (f"Worker Profile:\n"
                f"Name: {self.name}\n"
                f"Age: {self.age}\n"
                f"Position: {self.position}\n"
                f"Salary: ${self.salary}\n"
                f"Needs: {self.needs}\n"
                f"Preferred Start Hour: {self.starting_hour}\n"
                f"Most Productive Days: {', '.join(self.ProductiveDays)}")
eager heathBOT
#

Hey @frail viper!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
frail viper
#

which he added

#

after this def str was added the program worked as intented , i followed by adding the try and except for general error handling and i told him to code review it , moment in wich he added the "extra debugging" and thats it

stiff tusk
#

So its really hard to judge but since you asked having some understanding is good but basically what you had made before didnt do anything since it was missing a critical component. What would help you a lot more would be to read documentation on creating and handling classes and gain the understanding from there. Or if you want to use chatGPT you can ask it to explain concepts or things like that but functionally just handing it code and say 'make it do this' really doesnt count for much and just hinders your own improvement.

frail viper
# stiff tusk So its really hard to judge but since you asked having some understanding is goo...

true , i try using it for explaining mainly and i avoid actually building code with it . in this case classes are a concept i just learned today from a crashcourse and some little testing i was doing , the only method i knew was init(self, arg1, ...)
do u think coding is about memorising those methods and little things or gaining the skill of knowing where to look for it ? or does it come with experience

regal valve
#

Nothing you've shown there is a 'little thing', rather common things one would expect to know (of course with experience, aka time in the chair).
So I suppose 'both' suits your answer best, but I don't think the first part applies.

#

Don't take that as desparaging, just take it as motivation to keep going until they become familiar.
Getting working code going - with help or not - is still success.

frail viper
#

ofc i definetly need practice , i'm new to actually coding and not just implementing chatgpt code (ik shoot me in the head AHAHA) . ty for the replies , also where can i get project ideas? is there anywhere i could also get "checkpoints" to see if i had a good approach of a part of that project ?

regal valve
#

!resources

eager heathBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

regal valve
#

Some folks recommend Automate the Boring Stuff as a learning and project resource.

stiff tusk
#

That is indeed an excellent book but also the YouTube series by Corey are fantastic imo

regal valve
#

I would lean on documentation instead of an LLM to learn. It becomes a crutch, and apart from that will only be productive if you know what to ask it for your needs (and assess accuracy of its response).
Knowing where to find help on a standard library function etc or third party module is a necessary skill, just as knowing how to correctly use an LLM is becoming.

#

is there anywhere i could also get "checkpoints" to see if i had a good approach of a part of that project ?
I have heard good things about "100 Days of Python" by Angela Yu specifically for this notion that you do the work, and then see how a 'pro' got it done instead. And learn a bunch of different facets of Python, starting from easy to more difficult as you go, on actual projects.

frail viper
#

Thats why i actually started learning

#

๐Ÿ˜ญ๐Ÿ˜ญ

stiff tusk
#

ironically I tried using chatgpt (well gemini) like last year to have it try and spit out a function so I didnt have to figure it out on my own. And when it failed to create something even remotely functional 3x in a row is when I decided to learn it myself ๐Ÿ˜‰

eager heathBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.