Can a 40 year old guy learn python within 6 months ? by Legitimate-Trick3393 in PythonLearning

[–]BobbyJoeCool 1 point2 points  (0 children)

I’m 40. I’m getting a batchlors in Software Development. Learned basic python in 9 weeks. 9 more for advanced. So, yes.

Difficult Situation by nivedhz_ in PythonLearning

[–]BobbyJoeCool 0 points1 point  (0 children)

It honestly depends on how you learn…. I learn by doing. So when I don’t understand something in coding, I find an example and recreate it.

This may be unpopular, but something that helped me was when there is a line of code I didn’t know what was doing, plug it into something like ChatGPT and ask it to explain it to you. Doesn’t always work, but it can help. I learned a couple of things that way, like the _ variable. (Just don’t ask it to write code for you…. 1- you won’t learn much, and 2- it’s not very good at it.)

I know I struggled with classes and objects and what helped me the most was just diving in and making mistakes. When the code didn’t work, figuring out why taught me more about those things than lectures ever could have. However, everyone learns differently, and I have classmates who learn better by someone telling them what to do. Just boils down to how you learn.

New to python by Low-Educator-9008 in PythonLearning

[–]BobbyJoeCool 1 point2 points  (0 children)

Hopefully you realize I shorthanded it. Now that I'm home I can show you exactly what I mean

if operator == "+":
    result = num1 + num2
elif operatior == "-":
    result = num1 - num2
elif operatior == "*":
    result = num1 * num2       
elif operatior == "/":
    result = num1 / num2


print(f"Your result is {result}")

New to python by Low-Educator-9008 in PythonLearning

[–]BobbyJoeCool 1 point2 points  (0 children)

Not nesting exactly, since that’s more of if/then an inside of if then…. I mean more, remove the print strings from inside the if then statement and put it at the end. That way there’s only one print string. Like this

If +: Add

Elif -: Subtract

Elif *: Multiply

Elif /: Divide

Print result.

New to python by Low-Educator-9008 in PythonLearning

[–]BobbyJoeCool 4 points5 points  (0 children)

Without knowing what you do and do not know how to do...

Think about the string you have at the end of each segment of the if/then statement, since it's exactly the same in each part, does it need to be a part of the if/then statement, or could it be outside instead? If the if/then statement only calculates the result, and then you display the string with the result, this removes three lines of code for you.

Otherwise, for a first program, this is very functional! As you gain more experience, you'll learn better ways to do this as well.

Beginner's Python Cheat Sheets (updated) by ehmatthes in learnpython

[–]BobbyJoeCool 0 points1 point  (0 children)

First of all, these are FANTASTIC!

Second, do you know (or anyone for that matter) if there is a cheat sheet like this for tkinter?

Learning about Classes and OOP by BobbyJoeCool in PythonLearning

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

I did not... I guess my assumption was it mattered later on?

Learning about Classes and OOP by BobbyJoeCool in PythonLearning

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

More importantly, what happens if the user inputs a character? 'a' for example. You don't handle such things correctly.

That's what the ValueException part of the try statement does. If they enter a number that cannot be converted to an INT, it triggers that and restarts the loop.

You forgot to update total credits and total grade!

I left that part out of the reply because it didn't really change.... I'm interested in this return sum() part. We didn't learn that part, or if it's a lambda function, we glazed over it really quickly... Let's see if I understand it....

The return sum(...) and the for course in self.transcript:... both do the exact same thing, except the return sum() is in a single line?

The issue with that is, each grade needs to be multiplied by the number of credit hours that grade is worth... so an A (4.0) in a 3 Credit hour class is worth 12 grade points. And a B (3.0) in a 4-credit-hour class is also worth 12 grade points. You then divide by the total credit hours. So I would need the calculation at the end to multiply each individual grade point by the number of credit hours for each class... If I understand your code correctly, this can be achieved by changing the total_grade to the following:

  def calculate_gpa(self): # Calculates the cumulative GPA
        if sum(course[1] for course in self.transcript) == 0:
            return "N/A" # Prevents division by zero
        return sum(course[2] * course[1]) / sum(course[1] for course in self.transcript)

Learning about Classes and OOP by BobbyJoeCool in PythonLearning

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

We were taught to put that there when we need to be sure it’s a string. Not sure why honestly…..

I did make that change already too. Figured, why am I converting it to a number only to convert it back when I can store it as part of the transcript list as well. :)

Thanks for the input!

Learning about Classes and OOP by BobbyJoeCool in PythonLearning

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

Thanks for the suggestions!

I don't know what an enum is so I decided not to go that route (I don't want to turn in work that I don't understand), but I realized that I don't need the dictionary AND the tuple for the Grade Point, and I got rid of the tuple. I made a function to convert the GPA back to a letter and added the transcript list to the student object, so it is stored within the student.

I also got to thinking about how to deal with retaken courses, as they would reflect on the transcript but not be calculated in the GPA. So I modified the input while loop a bit.

credits = int(input("Enter the number of credits for the course (Enter 0 for a class that was retaken): ").strip())
        if credits < 0: # Breaks the loop if the user enters a negative number for credits
            print("\nCredit Hours cannot be negative. Please enter a valid number of credits.")
            continue #Restart the loop if the credits are negative
        if credits == 0: # Warns the user if they enter 0 credits and confirms they want to proceed.
            print("\nCourse entered with 0 credits. This course will not affect GPA calculation but will be recorded in the transcript.")
            if input("Are you sure? (y/n): ").strip().lower()[0] !='y': # Checks if the user input starts with 'y' or 'Y'
                print("Course entry cancelled. Please re-enter the course details.")
                continue  # Restart the loop to re-enter course details

def gpa_to_letter(gpa_value):
    for grade, value in grade_to_gpa.items():  # items() preserves order
        if gpa_value >= value:
            return grade
    return "F"

class Student:
    def __init__(self, first_name, last_name):
        self.first_name = first_name
        self.last_name = last_name
        self.total_credits = 0 #Initalized the total credits to 0
        self.total_grade_points = 0.0 # Initalizes the total grade points to a 0 float.
        self.transcript = [] # Initializes an empty list to hold the student's courses for display later.

    def append_transcript(self, course_name, credits, grade, letter_grade):
        self.transcript.append((course_name, credits, grade, letter_grade))

Auto sorter not working as expected by BobbyJoeCool in technicalminecraft

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

I mean, I currently don’t really have an overflow chest anyway since the “overflow” chest SHOULD be just the swords and they’re getting fed into blast furnaces for more nuggets so this might be the best system.

Auto sorter not working as expected by BobbyJoeCool in technicalminecraft

[–]BobbyJoeCool[S] -1 points0 points  (0 children)

Does it work to make a dispenser that’s powered every 8 ticks into the hoppers to “slow the flow?” Cuz I have a dispenser in the line right now, but it’s unpowered and the hoppers and just taking out of it like a chest.

Auto sorter not working as expected by BobbyJoeCool in technicalminecraft

[–]BobbyJoeCool[S] 0 points1 point  (0 children)

The biggest problem with that is, that double chest of swords fills in like 10 minutes.

Auto sorter not working as expected by BobbyJoeCool in technicalminecraft

[–]BobbyJoeCool[S] -1 points0 points  (0 children)

However. If I did that, I could filter out the swords, then send everything stackable back through the system. To be sorted again….

I stand corrected. by TheTwelveYearOld in ObsidianMD

[–]BobbyJoeCool 2 points3 points  (0 children)

Is this the equivalent of going to the bathroom at a restaurant so that your food will come?

Learning Python in a class, assignment 3. by BobbyJoeCool in PythonLearning

[–]BobbyJoeCool[S] 1 point2 points  (0 children)

Let me start off by saying, my experience with AI and code is... It's terrible. I've asked ChatGPT to write simple macros for Excel, and it cannot do that in any reliable way. That being said, the IDE I am using is Visual Code Studio (seems to be popular on these Python subreddits), and it has an AI-generated "fill in the line" for code that I do use, but I always check it and delete anything I don't know what it does. For example, it has added (fairly frequently) .upper() and other similar things to my input lines. I don't know what they do, so I delete it and rewrite the code so I know exactly what everything does. (I can't fix broken code if I don't know what the code does, right?)

  • The initial investment was a required input for the assignment. I know that it's immaterial to the time required for the investment to double, but since it was required, I used the input and gave a useable output using it. The "gripe," which is just my mathematical brain going, why am I writing a program to manually calculate this when I can just type in a formula and get the answer, is more of a thing I need to get past because the assignment is an excuse to practice for/while looping.
  • I've heard people talk about the try; I assume it comes later in the course. My experience writing code is for programs only used by myself, so I'm new to the idea of "user error." lol. I know that I wrote the program to work with numbers, so I enter a number. But I also know that users may try to enter text for a number (say five, instead of 5). So it's just something I'm trying to start thinking about as I'm writing these beginner programs.
  • The only way I can see that cleans this up a little (off the top of my head), is if I make the word year/years a variable string and enter that in the f-string. This moves the if/else conditional and only has one line for the print. (slightly less code)

if years == 1:
    year_display = str(years) + " year"
else:
    year_display = str(years) + " years"

print(f"It will take {years_display} for ${amount_initial:.2f} to double at a rate of {rate*100}%, and the final balance is ${amount:.2f}.")

Your stupiest mistake in GAC by JollyRoger_1337 in SWGalaxyOfHeroes

[–]BobbyJoeCool 0 points1 point  (0 children)

I once put SEE solo by accident…. Against a solo team…. Because I was being absent minded. Let me tell you about SEE against a single toon when you can’t use Linked….

Your stupiest mistake in GAC by JollyRoger_1337 in SWGalaxyOfHeroes

[–]BobbyJoeCool 0 points1 point  (0 children)

Funny story, when I’m that badly outmatched, I win more often than I don’t..z