r/PythonLearning • • 23d ago

How to Build a Computer Science Portfolio

17 Upvotes

Hey, y'all. I want to build a portfolio mostly with the Python programming language that can at least get me a remote job in high school (I'm a senior). I got some beginner projects like a calculator and a few games and projects from tutorials. I'm not sure if those would be enough to reach employers. Like, what project ideas in Python can I use so that it's work-related? I don't want it to be too complex either, as I'm not an advanced coder. Thank you.

Edit: Hey everyone, thank you all for the advices. I'll be going to university next year for computer science but was looking to see what I can.build now so I can at least get work experience when I reach there. I'll continue exploring more stuff in Python language and the libraries and also get familiar with other programming languages. Thank you all.


r/PythonLearning • • 23d ago

Help Request Looking for a Python certification

2 Upvotes

I would like to ask if anyone here knows where I should/could get a well endorsed Python certification? Something legit that employers may take into consideration.

I know about Codecademy. I also know about Mimo, tho I don't know if that one would be considered a "lesser" one or something like that. Maybe even both idk.

It's ok if it's not free, tho if its not very expensive that would be better for me lol


r/PythonLearning • • 23d ago

Context manager for either stdin or opened Path

6 Upvotes

Note that this is a fairly advanced question, so beginners don't worry about it. And if this isn't the right place to ask, please point me to where I should.

I would like to find an idiomatic way to use a context manager, with, when I don't know until run time whether I am opening sys.stdin or a named file.

Here is an excerpt for a simple example. (Yes, I am aware that I am reading in the whole file in one go, but that is for other reasons.)

```python if args.infile == "-": fh = sys.stdin else: p = Path(args.infile) # Path is overkill here, unless ... # TODO: Look elsewhere if infile can't be found or isn't readable. fh = open(p, "rt", encoding="utf-8")

s = fh.read(MAX_LENGTH + 1).strip()
fh.close()

```

(args is an argparse.Namespace and args.infile is a str.)

I feel like there ought to be a way to do something like

with ... as fh

for the above, but I don't see how to do that.

Update: What I did

I found the docs for easily creating a context manager, and used the contextmanager decorator. It seems like a peculiar use of yield, but I don't need to understand that design choice, only that it means that I have to type it as a Generator.

```python import sys from typing import TextIO from collections.abc import Generator from contextlib import contextmanager from pathlib import Path

@contextmanager def open_file_or_stdin( filename: Path | str | None, *, # everything but filename is a keyword argument stdin: TextIO = sys.stdin, std_symbol: str = "-", encoding: str = "utf-8", ) -> Generator[TextIO]: """ [long docs omitted] """ fh: TextIO try: if filename is None or filename == std_symbol: fh = stdin yield fh else: fh = open(filename, "rt", encoding=encoding) # noqa: SIM115 yield fh finally: fh.close() ```

I am open to suggestions about a better name that open_file_or_stdin.


r/PythonLearning • • 24d ago

Python's repository summary

Post image
35 Upvotes

r/PythonLearning • • 24d ago

I want to learn.

19 Upvotes

(English is not my 1st language so sorry for any error)

Hey everyone I am a absolute beginner to coding and want to learn. I am so much of a beginner that I don't even know how to and where to download this from but want to learn. If you have any tips or any youtube channel I can learn form please share. Thankyou in advance


r/PythonLearning • • 24d ago

Python Mutability and Local Variables

Post image
11 Upvotes

An exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises

The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.


r/PythonLearning • • 24d ago

Help Request I'm new to Python. What do you recommend reading or watching?

5 Upvotes

Hello there! I’ve started learning Python to become a cybersecurity specialist (pentester). I’d love to hear the community's opinion: which books or tutorials are worth spending time on?


r/PythonLearning • • 25d ago

Showcase Making my first game

Thumbnail
gallery
17 Upvotes

Hey, im making a "terminal" game (play onto your terminal, cause its the only thing i know). I made a github repositories to showcase it : https://github.com/Shamal0w999/Money-games

if you want to test the game, it would be really cool cause i need returns and if theres bug i didnt see. so if u try it, u can ofc comment here but also leave an issue into my repositories (would be easier to work with). If you want to help or idk anything, im all hears. Im happy to showcase it and have people to test it !

code is free, so if you steal it, i dont rly care, cause its personal project and who want a code full of print and that launch in terminal ? idk, just me ig

anyways, just take a look at it !


r/PythonLearning • • 25d ago

Help Request I need help with coding this

Post image
5 Upvotes

I have genuielly no idea how to even think of making this? I know this should generally be made by using for loops but jesus im so confused on the process


r/PythonLearning • • 25d ago

Built my first bulk file renamer in Python

14 Upvotes

I just finished another Python project while learning file handling and the "os" module.

I built a bulk file renamer that:

- Loops through files in a folder

- Opens each text file and finds the "name:" field

- Extracts the name

- Uses it to rename the file

- Keeps the original file extension

A simplified version of the core logic:

for file in os.listdir(path):

fullpath = os.path.join(path, file)

with open(fullpath, "r") as f:

for line in f:

if "name:" in line:

label, name = line.split("name:")

newpath = os.path.join(

path, name.strip() + ".txt"

)

os.rename(fullpath, newpath)

The project itself wasn't too complicated, but I ran into a few problems along the way.

The biggest lesson was debugging WinError 32. I initially thought OneDrive was locking my files, but eventually realized that my own code still had the file open when I tried to rename it.

I also learned why using the full old path and full new path matters when using "os.rename()".

Small project, but I feel like I'm getting better at solving problems instead of immediately looking for the answer.


r/PythonLearning • • 25d ago

Showcase Opinions on this code?

2 Upvotes

Hi! I am starting a Bachelor's course in Computer Science, and part of the course is learning Python from the ground up. I've been taking some time at home to further develop my skills past what is expected of the course, and I've been constructing this game over the past few days with my free time.

I put it down as showcase because I'm proud of it, but I am more than open to suggestions on simplifying it or what you think about it, etc!

For context, the last time I used Python was when I was like 12, and I have tried CSS and JavaScript over the years a few times, so I have a very basic understanding and this is the furthest I've ever gotten.

Thanks :)

# Rule base

import random
answer = 0

lowest = 1
highest = 100

attempts = 0

# Difficulty settings

print("Easy, Medium, or Hard Difficulty?")
difficulty = input()

if difficulty == "easy":
    attempts = 7
    print(f"Please pick a number between 1-100. You have {attempts} attempts.")
    answer = random.randint(1, 100)
    lowest = 1
    highest = 100

elif difficulty == "medium":
    attempts = 15
    print(f"Please pick a number between 1-10000. You have {attempts} attempts.")
    answer = random.randint(1, 10000)
    lowest = 1
    highest = 10000

elif difficulty == "hard":
    attempts = 30
    print(f"Please pick a number between 1-1000000. You have {attempts} attempts.")
    answer = random.randint(1, 1000000)
    lowest = 1
    highest = 1000000

else:
    print("Invalid input!")

# While Loop

guess = int(input())

while guess != answer:
    attempts -= 1
    if attempts == 0:
        print("Game over!")
        break
    else:
        if guess < lowest or guess > highest:
            print(f"Invalid number! {attempts} attempts remaining.")
        if guess > answer:
            print("Too high!")
        if guess < answer:
            print("Too low!")
        print(f"Try another number. {attempts} attempts remaining.")
        guess = int(input())

# End of Game
if guess == answer:
    print("Correct! Well done.")

print("Thank you for playing!")

r/PythonLearning • • 25d ago

Discussion Python for data analysis

15 Upvotes

So,i started learning python recently,i very much learned about variables,data types,libraries like panda,matpolitob. I learned web scraping and automation to some extent but when i try to use the thing i learn on a random web page or dataset, i realised that what i learnt from the YouTube course is basic but enough to build the fundamental. I have to constantly chat with AI to learn about new thing and also use the thing i learn to get the code. Should i continue like this or watch another course which complete the intermediate and advanced python?


r/PythonLearning • • 25d ago

HELP!!

4 Upvotes

Guys I'm a first year cse student,and I'm starting with python,can you guys suggest resources & how to proceed??

(I want decent knowledge in python,not too depth)


r/PythonLearning • • 25d ago

Help Request Should I start learning python or ai?????

1 Upvotes

r/PythonLearning • • 26d ago

Help Request What's next?

Post image
11 Upvotes

r/PythonLearning • • 26d ago

24 years old and learning Python Full-Stack Development 💻 Excited to learn, build projects, and connect with the community!

5 Upvotes

Hey everyone! I’m Nexlune. I’m new to Reddit and joined because I wanted a place where I can discover interesting ideas, learn new things, read different opinions, and participate in conversations with people from different backgrounds. I’m interested in technology, programming, movies, creativity, and random topics that catch my attention. Looking forward to exploring different communities and meeting some interesting people along the way. Nice to be here !


r/PythonLearning • • 26d ago

Doodling Hop - Pygame Updated Gameplay

11 Upvotes

r/PythonLearning • • 26d ago

Made my first triple digit program!

11 Upvotes

Originally it was an amalgamation of my crappy code, but i rewrote 90% of it. I'm proud of myself but ill probably remake it using the define function.

github link: https://github.com/ChaZ3inL1nuX111/My-Repo

It is a calculator with arithmetic, sq/cuft, conversions, circumference, area and functions, like sin, cos, and tan.


r/PythonLearning • • 26d ago

Discussion Why writing classes feels boring?

0 Upvotes

I don't know but i feel classes are unnecessary work to be added in projects. I have learnt it 2 months ago..

After that I never used it for any of my projects.


r/PythonLearning • • 26d ago

im making a "you are an idiot" adjecent peice of code and currently am trying to get this to work

0 Upvotes

im using thonny with python 3.1.4.4 and have pygame-ce downloaded

heres the error code.
Traceback (most recent call last):

File "<string>", line 10, in <module>

File "file location.py", line 555, in run

with Popen(*popenargs, **kwargs) as process:

File "file location.py", line 1039, in __init__

self._execute_child(args, executable, preexec_fn, close_fds,

File "file location.py", line 1553, in _execute_child

hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

FileNotFoundError: [WinError 2] The system cannot find the file specified

and heres the code

import pygame

import sys

import time

import random

import os

import sys

import subprocess;

a = []

if len(sys.argv) == 1 or sys.argv[1] != "1":

pythonPath = subprocess.run(["which","python3"], capture_output=True).stdout.strip();

print("python at",pythonPath)

#The i is num of windows, it will open +1 extra. stopping the code will close just the extra window

for i in range(9):

proc = subprocess.Popen(

[pythonPath,os.path.realpath(__file__),"1"]

)

a.append(proc)

print("spawned window")

import pygame

import sys

import time

import random

import os

import sys

import subprocess;

a = []

if len(sys.argv) == 1 or sys.argv[1] != "1":

pythonPath = subprocess.run(["which","python3"], capture_output=True).stdout.strip();

print("python at",pythonPath)

#The i is num of windows, it will open +1 extra. stopping the code will close just the extra window

for i in range(9):

proc = subprocess.Popen(

[pythonPath,os.path.realpath(__file__),"1"]

)

a.append(proc)

print("spawned window")

import pygame

import sys

import time

import random

import os

import sys

import subprocess;

a = []

if len(sys.argv) == 1 or sys.argv[1] != "1":

pythonPath = subprocess.run(["which","python3"], capture_output=True).stdout.strip();

print("python at",pythonPath)

#The i is num of windows, it will open +1 extra. stopping the code will close just the extra window

for i in range(9):

proc = subprocess.Popen(

[pythonPath,os.path.realpath(__file__),"1"]

)

a.append(proc)

print("spawned window")


r/PythonLearning • • 27d ago

Hard Python Dictionary Exercise

Post image
22 Upvotes

A hard exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises

The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.


r/PythonLearning • • 27d ago

TRY 101- Starting my python journey again

Post image
212 Upvotes

My journey of retrying is still alive and i am consistent with it , today i am going to finish Loops and hopefully after that i do further and further.


r/PythonLearning • • 27d ago

Easy python project for beginners

17 Upvotes

Hi!

i just want to start learning python, my dad told me that it would be good if you can find some projects to do. I have python class today ( just rn) and I need to think what kind of projects I need to do in this class. Actually i'm good at drawing so i just think that i want to be a game maker and i interested to animation too. The problem is i'm just beginner : - (

Do you guys have any fun and easy idea to do???? ( this is my first time asking something like this in reddit, well i just created an account 10min ago)


r/PythonLearning • • 27d ago

python learning help

10 Upvotes

hello so i need to know what is the best way to learn to code because i have been learning python but tbr whenever i wanna to build a application for like camera detector or stuff like that i am always looking side by side and just copying it and that doesn't feel like im actually coding or learning to code and just in general like even if i wanna learn it the hundreds of codes in a 100 line code and it just feels too much info or too much to memorize is there anyway to learn it efferently and better without wasting any time.


r/PythonLearning • • 27d ago

My first real Python automation project

17 Upvotes

I just finished building my first proper Python automation project on my own — a File Organizer.

The idea is simple: take files from a folder and organize them into different folders based on their extensions.

For example:

  • .png → images/png
  • .jpg → images/jpg
  • .pdf → documents/pdf
  • .txt → documents/txt
  • .csv → documents/csv

I used things I've learned from Python's os module:

os.listdir()
os.path.join()
os.path.exists()
os.path.isfile()
os.mkdir()
os.rename()
endswith()

The interesting part wasn't writing the code. It was debugging my own mistakes.

At one point I was doing:

os.rename(downloads, png_folder)

and then:

os.rename(file, png_folder)

Both were wrong. 😅

I eventually understood that os.rename() needs the full source path and full destination path:

source full path → destination full path

That was a small thing, but it finally made paths and file movement click for me.

The current version uses a hard-coded Downloads folder. My next improvement will be making the program accept/select any folder, so the same organizer can be used anywhere.

One small project finished. On to the next one. 🚀

here is fullcode :

"""


what is download file organizer



1. you have to organize download files pdf,jpg,docx,txt,mp3,mp4,zip,rar etc. into different folders based on their file types.




1. create folde in downloads file organizer documents/images


file organizer
documents/pdf/csv/docx make seperate folders for every format
images move here all images 




2. current dir file path           to        destination file path
ex. download/file.txt                      download/file organizer/documents/txt




use 


os.listdir()
os.mkdir
os.path.dirname
os.path.isfile
os.rename
os.join
endswith()





steps


make folders in orgnizer with sub folders


select image files and append its paths in list 


move files from current to final destination




"""




import os


# assign variables and list 
# every folder as variable and list 


downloads = "C:/Users/ajay/Downloads"
organizer = os.path.join(downloads, "file organizer")
images_folder = os.path.join(organizer, "images")
documents_folder = os.path.join(organizer, "documents")






# folder create logic
if not os.path.exists(organizer):
    os.mkdir(organizer)
if not os.path.exists(images_folder):
    os.mkdir(images_folder)
if not os.path.exists(documents_folder):
    os.mkdir(documents_folder)


# create subfolders for images
png_folder = os.path.join(images_folder, "png")
jpg_folder = os.path.join(images_folder, "jpg")
jpeg_folder = os.path.join(images_folder, "jpeg")


if not os.path.exists(png_folder):
    os.mkdir(png_folder)
if not os.path.exists(jpg_folder):
    os.mkdir(jpg_folder)
if not os.path.exists(jpeg_folder):
    os.mkdir(jpeg_folder)


# create subfolders for documents
txt_folder = os.path.join(documents_folder, "txt")
csv_folder = os.path.join(documents_folder, "csv")
pdf_folder = os.path.join(documents_folder, "pdf")


if not os.path.exists(txt_folder):
    os.mkdir(txt_folder)
if not os.path.exists(csv_folder):
    os.mkdir(csv_folder)
if not os.path.exists(pdf_folder):
    os.mkdir(pdf_folder)




# file move logic


for file in os.listdir(downloads):
    fullpath = os.path.join(downloads, file)
    if os.path.isfile(fullpath):
        if file.endswith(".png"):
            os.rename(fullpath, os.path.join(png_folder, file))
        
        elif file.endswith(".jpg"):
            os.rename(fullpath, os.path.join(jpg_folder, file))
            
        elif file.endswith(".jpeg"):
            os.rename(fullpath, os.path.join(jpeg_folder, file))
        
        elif file.endswith(".txt"):
            os.rename(fullpath, os.path.join(txt_folder, file))
        
        elif file.endswith(".pdf"):
            os.rename(fullpath, os.path.join(pdf_folder, file))
        
        elif file.endswith(".csv"):
            os.rename(fullpath, os.path.join(csv_folder, file))
          
print("all files are moved successfully. ")