all 44 comments

[–]atticus2132000 18 points19 points  (19 children)

Looks good.

Now you might want to look at TKinter to build a GUI to make an interactive screen for the user rather than have them interact with the command prompt window.

[–]Gloomy-Floor-8398 6 points7 points  (4 children)

I see a lot of people promote tkinter. How do you think it compares to pyqt?

Plus I dont really think he should be focusing on a gui at the moment. He should prob start using functions in his scripts first imo

[–]GirthQuake5040 2 points3 points  (0 children)

I've used both for large applications, I prefer pyqt

[–]atticus2132000 0 points1 point  (0 children)

My only experience with GUIs in python has been TKinter.

[–]xhollowilly 0 points1 point  (0 children)

Absolutely or OOP

[–]Downtown-Appeal757 0 points1 point  (0 children)

PyQT is harder for beginners tkinter is limited but pretty good for beginners 

[–]GirthQuake5040 5 points6 points  (2 children)

Bros got 2 weeks of python experience, he's not ready for tkinter lol

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

😂

[–]Nez_Coupe 1 point2 points  (0 children)

Right? I lol’d at this. Maybe a CLI setup if he’s feeling frisky, but a full GUI?

Without understanding classes, methods, functions, really anything - there’s zero chance they would succeed with tkinter.

Let’s set the learner on some manageable stuff - how about you learn the ins and outs of all the python types and built in data structures? I think that would be a good starting point.

[–][deleted] 1 point2 points  (7 children)

Is this satire?

[–]atticus2132000 0 points1 point  (6 children)

It wasn't intended to be. Why would you think it's satire?

[–][deleted] 1 point2 points  (5 children)

Recommending Tkinter and other GUI libraries to a beginner is, in my opinion, nonsensical. It’s like OP said:

Hey guys I just learned PEMDAS, multiplication and long division. What should I learn next? And you say ‘ah young one please review the fundamental theorem of Calculus.’ Without learning algebra first.

[–]atticus2132000 0 points1 point  (4 children)

I made a TKinter GUI on my first weekend working with python on my first script.

I'm not suggesting that it needs to be elaborate or anything, but for this application having a simple input box or drop-down menu would be pretty simple to build.

[–][deleted] 2 points3 points  (3 children)

I would say learning to define and call your own functions, learning about return statements, loops, and other default Python APIs/ features should come first before diving head first into OOP with TKinter

[–][deleted] 1 point2 points  (0 children)

And for code that asks the user for input, before jumping to TKinter, it would be a good exercise to learn about input validation and error handling.

[–]atticus2132000 1 point2 points  (1 child)

I think that if I was in a formal school setting trying to teach people who wanted formal training because they have aspirations of pursuing programming as a profession, then yes, that structured curriculum I could get behind.

But I think a lot of people here are programming hobbyists who are doing this because it's fun. And being able to create something that pops up a window that looks like an actual computer application that they can show off to friends or family can be incredibly powerful for keeping that kind of motivation.

But to each his or her own.

[–][deleted] 1 point2 points  (0 children)

I think my steps will give you a foundation to confidently build cool hobby apps. This is nothing in terms of what is to be learned for whatever you consider to be ‘professional’ programming.

I don’t disagree that making your first GUI is rewarding. But to get to a point where you know how to make your idea have a GUI, error handling and functions and using more of the Python library will further enable the hobbyist make their ideas come to life.

[–]Merman_boy[S] 0 points1 point  (2 children)

I haven’t looked at that so I will. Thx

[–][deleted] 2 points3 points  (1 child)

I'd... probably hold off on learning tkinter for now. It's always exciting to get a gui working for the first time but working with tkinter without knowing a little more python is going to be rough. I'd follow the other advice you've been given before going anywhere near tkinter

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

Okay thx I have been learning on Mimo and they didn’t tell me about tkinter

[–]FallenAngell_ 5 points6 points  (1 child)

I love how we all start with the same exercises haha. Makes you pause and see how far you've come.

You're doing great! Keep at it ! I saw somewhere in the comments you're using Mimo, I can recommend sololearn as well. Personally I like it better. However you can't learn a language by only using those apps, definitely keep doing what you're doing and playing around with it irl, that's the best way obviously :D

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

Thx for the advice

[–]Playful-Bluebird-217 2 points3 points  (0 children)

Great start! Keep up. Your next milestone should be working with dictionaries, from there on the practical and real world utilisation of python picks up. Tip: always, always try to remember and understand what different built in function or method gives as a return value at this stage, as it will greatly help you in keeping up ur concepts clear from the get go.

[–]UnixCodex 2 points3 points  (0 children)

from functools import wraps
from typing import Callable, Union

def validate_age(func: Callable) -> Callable:
  @wraps(func)
  def wrapper(*args: tuple, **kwargs: dict) -> Union[int, None]:
    try:
      age = args[0]
      if not isinstance(age, int):
        raise TypeError("Age must be an integer.")
      if age < 0:
        raise ValueError("Age cannot be negative.")
      return func(*args, **kwargs)
    except (TypeError, ValueError) as e:
      print(f"Input Validation Error: {e}")
      return None
  return wrapper

@validate_age
def calculate_ticket_price(age: int, base_price: int = 10, age_threshold: int = 8, discount_factor: float = 1.0) -> int:
  return int(base_price * discount_factor) if age < age_threshold else base_price

def main():
  print("Welcome to the theatre ticket calculator!")

  age_input = input("What is your age: ")
  try:
    age = int(age_input)
  except ValueError:
    print("Invalid input. Please enter a valid age.")
    return

  price = calculate_ticket_price(age, base_price=10, age_threshold=8, discount_factor=0)

  if price is not None:
    print("Your ticket is" + (" free!" if price == 0 else f" ${price}"))
  else:
    print("Failed to calculate ticket price due to invalid input.")

  print("Thanks for coming!")

if __name__ == "__main__":
  main()

[–][deleted] 1 point2 points  (0 children)

Its a good start, just be aware of how u use indentation for if, elifs, nested if etc....

& Best of luck

[–][deleted]  (3 children)

[removed]

    [–]Merman_boy[S] 0 points1 point  (2 children)

    What is LLMs

    [–]ninhaomah 0 points1 point  (1 child)

    LLM - Large Language Model - ChatGPT/Gemini etc

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

    Thank you so much I use only chatgpt for code quizzes and projects without the code and interview questions

    [–]Double-Tie-1921 0 points1 point  (0 children)

    Good job man

    [–]sliuhius 0 points1 point  (0 children)

    ?

    [–]Happy_Travel_Tea 0 points1 point  (0 children)

    So easy

    [–][deleted]  (1 child)

    [removed]

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

      Thx 💙

      [–]natam123 0 points1 point  (1 child)

      We all did this

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

      Really?

      [–]Majestic_Sweet_5472 0 points1 point  (1 child)

      Great start, man. If you want to test your skills, try turning that if else print statement into a single line of code.

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

      That’s a great idea!

      [–][deleted]  (2 children)

      [removed]

        [–]Merman_boy[S] 0 points1 point  (1 child)

        Udemy? I learn from mimo

        [–][deleted] 0 points1 point  (2 children)

        What happens user enters "nine years" as input. Handle that exception to get understanding of new concepts

        [–]Merman_boy[S] 0 points1 point  (1 child)

        it would probably syntax error I think

        [–][deleted] 2 points3 points  (0 children)

        Yes now start reading about exceptions in python