r/PythonLearning • u/JordanYell • May 17 '25
Showcase I’ve never coded before today!
My grandpa was a python fanatic in the navy (desert storm era) and I’m pursuing a BS in CS. He mentioned python would be the best intro so I played around and decided to write him a script! Tell me what you think ;)
2
May 17 '25
Great. Keep going. Just for the readability, it is a good practice to choose appropriate variable names. I would use "age" as the variable name here instead of "now"
1
17
u/beepdebeep May 17 '25
Congrats! That's the perfect start - can I offer a couple small follow-up experiments as your next lessons?
Give it something that isn't an integer, like your name. Work out how to prevent what happens.
Give it a negative number. Provide slightly more accurate output, like, "That doesn't seem right...".
These kinds of details will become important in your studies soon enough, so it's good to get in the practice of doing.
15
10
u/Consistent-Gift-4176 May 17 '25
Congrats! Good luck in your endeavor, even if it's just a side hobby. I remember my first application was something similar - input > basic logic > output. Soon I wrote a text-based "combat game" where you were pitted against a dragon, and the player and the dragon each took turns rolling a random number for damage. I miss when simple applications had so much magic to them.
Some advice amid the AI boom, if you're serious about learning how to code, don't use it to learn. In order to learn, we need to do it the slow way. If you truly get stuck, try to learn how to solve it the old fashioned way - read documentation, or try googling.. etc. This is to learn how to solve it yourself, because AI often can't solve context dependent code issues. It can however recommend knowledge you aren't sure about, like a library, syntax issue, or algorithm to solve an issue.
AI isn't always trained on documentation, and even when it is, it doesn't always use the right versioning or get the right answer anyways.
1
May 17 '25
i have also started with basics. can u suggest how and from where should i practice further
1
u/Consistent-Gift-4176 May 18 '25
Well, it depends on what you want to learn. I just often wrote what I wanted to learn. For example, I wanted to make a chat room. So I created one - At the time of course, I already knew HTML, JavaScript and CSS, but what I didn't know was WebSockets (its what many "realtime" apps use.)
1
u/tazdraperm May 19 '25
It's very easy to ask AI something slightly incorrect and get a complete nonsense in response.
2
u/Terrible-Bid8028 May 17 '25
Awesome, it’s a great thing to learn to do.
Can I suggest you get in the habit of not doing stuff like
if condition: do stuff
on one line?
It’ll just throw people off when reading your code in the future. There’s nothing wrong with it at all, as you can tell because you wrote code and it worked as intended, but no one does this. Writing code that is easy for people to follow is almost as important as writing code that works properly.
Like I’ll straight up say that as a someone who’s written or read Python daily for over a decade I forgot you could do that.
4
u/JordanYell May 17 '25
So,
If condition:
Print(“blah blah blah”)
??
2
u/i_grad May 17 '25
You'll learn this one way or another eventually, but python scripts are very strictly formatted on their indentation.
if x > y: print("x is bigger") # this will run fine if y > x: print("y is bigger") # this will cause an errorBut yes. It is usually encouraged to put the condition on one line and to include the action in what's called a "code block" or just "block" on the following line(s). Smushing too much onto one line can make it tough to read in many cases.
Keep playing with it and keep learning! Python is a great first choice and something you can use at any point in a CS career.
1
u/SnooMachines8405 May 17 '25
Welcome to the club. Now try to implement so it can take people not entering numbers. And what if I haven't had my birthday this year yet? 🤔
2
1
u/atticus2132000 May 17 '25
Fantastic start.
Unfortunately, you're assuming that everyone who uses this has already celebrated their birthday for the current year. What's your plan for fixing that?
1
u/JordanYell May 17 '25
I could add more if properties, but I feel there should be a shorter way of doing that
1
u/atticus2132000 May 17 '25
Start by looking at the datetime functions. Use that to get the exact date today rather than just using 2025.
1
u/Expensive_Cup_5082 May 17 '25
i also want to start coding how should i approach
1
u/JordanYell May 17 '25
I started with codex! You have to pay after a certain point but the free part was useful
1
u/RamiFgl May 19 '25
i advice u to start with web languages, because you can literally click right now CTRL + SHIFT + J and u can start writing code already, easy to debug, there is this very handy website https://learnjavascript.online/for very good for beginners, helped me alot especially the reference map full of everything javascript related in my context https://learnjavascript.online/knowledge-map.html
1
1
u/AllanSundry2020 May 17 '25
forget qwen, deepseek, gchatPT, genimi -- this is the LLM we have all been waiting for
1
u/JordanYell May 17 '25
Feel free to turn the code into an app and send to your grandparents! This is a multi million dollar idea 😂
2
3
u/SCD_minecraft May 17 '25
Looks good
Just one thing, i recomed against putting a thing to do in same line as if
if something: then thisAs it hurts readability and doesn't work when you have more than one function there
Insted try
if something:
then thisSame with else and basicly all things with :
1
1
1
u/Potential_Speed_7048 May 17 '25
Yay!
Kaggle is great for data sets to use. I plan on doing one that has data based on a fictional story about a space ship 🚀 that has an outbreak of some disease and the goal is find correlations in the data on what might have caused it. Can found under competitions.
1
u/irrationallywise May 17 '25
Damn you need as fuck /s. Get learning bro. There are lots of resources out there.
1
1
u/Smart-Combination611 May 18 '25
Bro keep going 🫡, we programmers needs you, the entire world needs you 🤩🤩.
1
u/denehoffman May 19 '25
Next fun step, use the datetime library to get the current year (from datetime import datetime; year = datetime.now().year) and now your program will still work next year!
After this you can also work on getting the specific day of the year and ask the user for their birthday to see if it already happened.
0
u/stikaznorsk May 17 '25
Just a minor criticism. Your question should be "In which year were you born?"
1
1
1
May 17 '25
[removed] — view removed comment
1
u/JordanYell May 17 '25
He was a radioman, from what I understand the navy was using c but once python was introduced it made the storing of data incredibly easy. I’m most definitely being very broad on the uses but I think that’s the general idea lol
3
u/FlocklandTheSheep May 17 '25
Looks great! I recommend setting up an IDE ( this is an app in which you program ) though, as it makes development a lot easier and the file is on your machine, not some random website.
I use Visual Studio Code ( Visual studio =/= Visual Studio Code ), but people also recommend Pycharm.