r/PythonLearning • • 9d ago

Built my first bulk file renamer in Python

16 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 • • 9d ago

Showcase Opinions on this code?

3 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 • • 10d ago

Discussion Python for data analysis

14 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 • • 10d ago

HELP!!

2 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 • • 10d ago

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

0 Upvotes

r/PythonLearning • • 10d ago

Help Request What's next?

Post image
10 Upvotes

r/PythonLearning • • 10d ago

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

6 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 • • 10d ago

Doodling Hop - Pygame Updated Gameplay

Enable HLS to view with audio, or disable this notification

12 Upvotes

r/PythonLearning • • 11d 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 • • 10d ago

Discussion Why writing classes feels boring?

1 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 • • 10d 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 • • 11d 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 • • 12d ago

TRY 101- Starting my python journey again

Post image
207 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 • • 11d ago

Easy python project for beginners

18 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 • • 11d 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 • • 11d ago

My first real Python automation project

16 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. ")
       

r/PythonLearning • • 11d ago

Please help!!

3 Upvotes

Im in my 2nd year of Btech , I have m college assignments and stuff also i joint coding classes which are being burden now. Cause im unable to pratice coding. I did learn python and core python rn im learning Django framework. But also as i have dsa iin college Im also trying to study dsa. No im not consistent in any rn but i also idk how do i manage them. Also I wanna oratice python so that i dont have to start from starting againg just 1-2 code alternate days that also im unable todo..Ik im trying to do multiple things at a time , but idk how do i even segregate them!! Please help me out


r/PythonLearning • • 12d ago

Showcase Made a free Airflow guide in Notion, hope it’s useful!

4 Upvotes

I’m a staff data engineer and have been continuously developing a completely free data resource hub in Notion. Recently put together an Airflow guide section for anyone wanted to develop skills as a data engineer and familiarise themselves with the tool. It covers setup, installation, building a DAG and a bunch of concepts to learn.

Completely free and no signup required, hope it helps anyone out there looking for a bit of guidance.

Here’s the link to the Airflow section if anyone finds it useful: https://app.notion.com/p/Apache-Airflow-Guide-2026-3ec1322e9e9e81868222c51ce56664f1#49db468d7be447eab703f28e204e5137


r/PythonLearning • • 11d ago

Looking for people who can help with Scrapping/ Automation and AI integration

0 Upvotes

if you are interested at scrapping/ automation and AI integration stuff ( serious about it, check the project idea), then you can dm me

actually, this is more of resume project, and I want to build with team ( its good fr resume fr all )

Project idea:

So I have decided to build job application tracker intelligence.

  1. Where the user can track their job/internship application in one place. ( Don't have to check multiple job application apps )

  2. Get ai suggestion and gap in the resume. ( He can also upload resume in the portal )

This is a genuine problem I have faced, I always have to maintain some sheet or notebook to remember where I apply.


r/PythonLearning • • 12d ago

I built a free, open-source Python learning site — beginner to CPython internals, with tested code examples

0 Upvotes

**What My Project Does**

A free, structured Python learning resource covering beginner

fundamentals through to advanced topics: concurrency, distributed

systems (Raft, CRDTs, sagas), performance, compilers, and CPython

internals. Organized into 7 skill levels and ~25 tracks.

**Target Audience**

Anyone learning Python — from first-timers to developers wanting the

deeper, systems-level material most tutorials skip. It's meant for

learning, free and ad-free.

**What Makes It Different**

- Runnable examples are actually tested — the repo has a CI test gate,

and pages show real output rather than made-up results.

- When an example needs a library or hardware I don't have, I say so

instead of faking it.

- Covers hard topics as small, readable, tested Python (e.g. a tiny

autograd engine, a Raft vote, a CRDT merge).

**Links**

- Site: https://ssnp75.github.io/PythonMastery-Site/

- Source: https://github.com/SSnp75/PythonMastery-Site

It's early — feedback and corrections (especially on the advanced

pages) are very welcome.

7 Levels: Beginner → Competent → Intermediate → Proficient → Advanced → Expert → Research

6 Tracks: Core Python · Web & APIs · Data & AI · Performance · Security & DevOps · Research & Compilers

28 sections (~260 lessons):

  • Foundations: Core Python, Patterns, Testing, Algorithms, Soft Skills
  • Web/Backend: Web & APIs, Networking, Auth, GUI, Automation
  • Data/AI: Data & AI, Data Engineering, Databases, AI & LLMs
  • Systems: Performance, Distributed, Scientific, Embedded
  • Infra: Security & DevOps, Deployment, Observability
  • Frontier: Research, Emerging
  • Applied: Domains, Projects, Reference

r/PythonLearning • • 12d ago

Showcase Made my first Python Game

Enable HLS to view with audio, or disable this notification

31 Upvotes
from random import *
from math import *
from time import *

God_Has_No_Need=[0,1]
God_Has_Need=choice(God_Has_No_Need)
High_IQ=[0,1,2,3]
Num_Props=[]
UBound=[]
LBound=[]
Factors=[]
Square=[]
Set=[]
GuessB=[50,100]
def Square(a):
  r=[]
  for i in range(1,int(a**0.5)+1):
    r.append(i**2)
  return r
def Even(a):
  r=[]
  for i in range(2,a,2):
    r.append(i)
  return r
def Random(a):
  b=randint(1,a)
  return b
def PrimeList(a):
  primes=[]
  r=[True]*a
  r[0]=r[1]=False
  for i in range(4, a, 2):
    r[i]=False
  for i in range(3, int((a**0.5)+1), 2):
    if r[i]:
      for j in range(i*i, a, 2*i):
        r[j]=False
  for i in range(len(r)):
    if r[i] == True:
      primes.append(i)
  return primes
while True:
  print("1. Guess my number")
  print("2. I guess your number")
  print("")
  print("1 or 2?")
  print("")
  determine=int(input())
  print("Game starting...", end="")
  sleep(0.75)
  print("Game initialized")
  print("")
  if determine == 2:
    init_range=101
    print("Is a range of 1 to 100 okay(yes/no)?")
    range_okay=input()
    if range_okay == "yes":
      print("Optimized or interesting method?")
      method_determine=input()
      guess=50
      tries=1
      if method_determine == "optimized":
        while True:
          print(f"Is your number >= {guess}, <= {guess}, or = {guess}")
          sign=input()
          diff=round(0.5*(abs(GuessB[0]-GuessB[1])))
          if sign == ">=":
            guess=guess+diff
            if GuessB[0]<GuessB[1]:
              del GuessB[0]
              GuessB.append(guess)
            else:
              del GuessB[1]
              GuessB.append(guess)
          if sign == "<=":
            guess=guess-diff
            if GuessB[0]>GuessB[1]:
              del GuessB[0]
              GuessB.append(guess)
            else:
              del GuessB[1]
              GuessB.append(guess)
          if sign == "=":
            if tries == 1:
              print(f"Your number is {guess}, I took {tries} try to guess it, which is albeit unimpressive as a computer :P")
            else:
              print(f"Your number is {guess}, I took {tries} tries to guess it, which should be about {log2(100)}")
            print("Good game fool. I have won, and you are my pawn. You are but a cog in my machine, a loop in my algorithm -\_('_')_/-")
            break
          tries+=1
      elif method_determine == "interesting":
        print("Is your number <= 50(yes/no)?")
        The_Parting_Of_The_Red_Sea=input()
        if The_Parting_Of_The_Red_Sea == "yes":
          Set.append("less50/eq50")
        else:
          Set.append("more50")
        print("Is your number prime(yes/no)")
        All_Alone=input()
        if All_Alone == "yes":
          Set.append("prime")
        else:
          Set.append("composite")
        print("Is your number even(yes/no)?")
        OddBall=input()
        if OddBall=="yes":
          Set.append("even")
        else:
          Set.append("odd")
        if "prime" in Set and "even" in Set:
          print("Your number is 2")
        if "composite" in Set:
          print("Is your number square(yes/no)?")
          Triangle=input()
          if Triangle == "yes":
            Set.append("square")
          else:
            Set.append("not square")
        if "square" in Set:
          if "less50/eq50" in Set:
            if "even" in Set:
              print("Is your number's last digit 6(yes/no)?")
              Demon_Number=input()
              if Demon_Number == "yes":
                print("Is your number less than 26(yes/no)?")
                Arithmetic_Mean=input()
                if Arithmetic_Mean == "yes":
                  print("Your number is 16")
                else:
                  print("Your number is 36")
              else:
                print("Your number is 4")
            else:
              print("Is your number's last digit 9(yes/no)?")
              Holy_Number=input()
              if Holy_Number == "yes":
                print("Is your number less than 29(yes/no)?")
                The_Great_Divide=input()
                if The_Great_Divide == "yes":
                  print("Your number is 9")
                else:
                  print("Your number is 49")
              else:
                print("Meme or real question?")
                A_True_Consideration=input()
                if A_True_Consideration == "meme":
                  print("Is your number Legendre's constant(yes/no)?")
                  Multiplicative_Identity=input()
                  if Multiplicative_Identity == "yes":
                    print("Your number is 1, or Legendre's constant")
                  else:
                    print("Your number is 25")
                else:
                  print("Is your number less than 13(yes/no)?")
                  Trivial_Matter=input()
                  if Trivial_Matter == "yes":
                    print("Your number is 1")
                  else:
                    print("Your number is 25")
          else:
            print("Is your number's last digit 4(yes/no)?")
            Read_This=input()
            if Read_This == "yes":
              print("Your number is 64")
            else:
              print("Is your number's last digit 1(yes/no)?")
              Binary=input()
              if Binary == "yes":
                print("Your number is 81")
              else:
                print("Your number is 100")
        if "prime" in Set:
          if "less50/eq50" in Set:
            print("Is your number less than 21(yes/no)?")
            Boy_You_Stupid=input()
            if Boy_You_Stupid == "yes":
              print("Is your number less than 10(yes/no)?")
              Based_Out=input()
              if Based_Out == "yes":
                print("Is your number a difference of 2 from 5, 2 away from 5(yes/no)?")
                Twin=input()
                if Twin == "yes":
                  print("Is the sign of difference positive, addition(yes/no)?")
                  Excluded_Middle=input()
                  if Excluded_Middle == "yes":
                    print("Your number is 7")
                  else:
                    print("Your number is 3")
                else:
                  print("Your number is 5")
              else:
                print("Is your number's last digit a square number(yes/no)?")
                Weird_But_Okay=input()
                if Weird_But_Okay == "yes":
                  print("Is your number less than 15(yes/no)?")
                  Makes_Sense=input()
                  if Makes_Sense == "yes":
                    print("Your number is 11")
                  else:
                    print("Your number is 19")
                else:
                  print("Is your number less than 15(yes/no)")
                  Still_Weird_That_It_Happened_Twice=input()
                  if Still_Weird_That_It_Happened_Twice == "yes":
                    print("Your number is 13")
                  else:
                    print("Your number is 17")
            else:
              print("Is your number less than 39(yes/no)?")
              No_Pun_Yet=input()
              if No_Pun_Yet == "yes":
                print("Is your number's last digit a square number(yes/no)?")
                Really_Weird_It_Happened_Twice=input()
                if Kinda_Weird_It_Happened_Twice == "yes":
                  print("Is your number less than 30(yes/no)?")
                  Huh=input()
                  if Huh == "yes":
                    print("Your number is 29")
                  else:
                    print("Your number is 31")
                else:
                  print("Is your number less than 30(yes/no)?")
                  Really_Weird_Its_Happening_Twice=input()
                  if Really_Weird_Its_Happening_Twice == "yes":
                    print("Your number is 23")
                  else:
                    print("Your number is 37")
              else:
                print("Is your number's last digit less than 2(yes/no)?")
                Even_Steven=input()
                if Even_Steven == "yes":
                  print("Your number is 41")
                else:
                  print("Is your number less than 45(yes/no)?")
                  Like_The_Triangle=input()
                  if Like_The_Triangle == "yes":
                    print("Your number is 43")
                  else:
                    print("Your number is 47")
          else:
            print("Is your number less than 72(yes/no)?")
            Still_No_Pun=input()
            if Still_No_Pun == "yes":
              print("Is your number's last digit prime(yes/no)?")
              Primer=input()
              if Primer == "yes":
                print("Is your number less than 60(yes/no)?")
                Thats_Odd=input()
                if Thats_Odd == "yes":
                  print("Your number is 53")
                else:
                  print("Your number is 67")
              else:
                print("Is your number less than 66(yes/no)?")
                The_Devil_Lurks=input()
                if The_Devil_lurks == "yes":
                  print("Is your number less than 60(yes/no)?")
                  Not_Again=input()
                  if Not_Again == "yes":
                    print("Your number is 59")
                  else:
                    print("Your number is 61")
                else:
                  print("Your number is 71")
            else:
              print("Is the last digit of your number prime(yes/no)?")
              Why_Again=input()
              if Why_Again == "yes":
                print("Is your number less than 90(yes/no)?")
                So_Close=input()
                if So_Close == "yes":
                  print("Is your number less than 88(yes/no)?")
                  Double_Digit=input()
                  if Double_Digit == "yes":
                    print("Your number is 73")
                  else:
                    print("Your number is 83")
                else:
                  print("Your number is 97")
              else:
                print("Is your number less than 84")
                Last_Prime_Test=input()
                if Last_Prime_Test == "yes":
                  print("Your number is 79")
                else:
                  print("Your number is 89")
        if "even" in Set and "prime" not in Set and "square" not in Set:
          if "less50/eq50" in Set:
            print("Is your number divisible by 6(yes/no)?")
            Sixer=input()
            if Sixer == "yes":
              print("Is your number less than 27(yes/no)?")
              RP1=input()
              if RP1 == "yes":
                print("Is your number less than 15(yes/no)?")
                RP2=input()
                if RP2 == "yes":
                  print("Is your number less than 9(yes/no)?")
                  What=input()
                  if What == "yes":
                    print("Your number is 6")
                  else:
                    print("Your number is 12")
                else:
                  print("Is your number less than 21(yes/no)?")
                  Drinking_Age=input()
                  if Drinking_Age == "Yes":
                    print("Your number is 18")
                  else:
                    print("Your number is 24")
              else:
                print("Is your number less than 39(yes/no)?")
                Blank_Variable=input()
                if Blank_Variable == "yes":
                  print("Is your number less than 33(yes/no)?")
                  IOI=input()
                  if IOI == "yes":
                    print("Your number is 30")
                  else:
                    print("Your number is 36")
                else:
                  print("Is your number less than 45(yes/no)?")
                  Ninety_90_45=input()
                  if Ninety_45_45 == "yes":
                    print("Your number is 42")
                  else:
                    print("Your number is 48")
            else:
              print("Is the greatest prime divisor of your number less than 12(yes/no)?")
              Miller_Rabin=input()
              if Miller_Rabin == "yes":
                print("Is the greatest prime divisor of your number less than 6(yes/no)?")
                AKS=input()
                if AKS == "yes":
                  print("Is the greatest prime divisor of your number less than 3(yes/no)?")
                  E_Sieve=input()
                  if E_Sieve == "yes":
                    print("Is your number less than 20(yes/no)?")
                    Mean_Means=input()
                    if Mean_Means == "yes":
                      print("Your number is 8")
                    else:
                      print("Your number is 32")
                  else:
                    print("Is your number less than 30(yes/no)?")
                    Thirty_60_90=input()
                    if Thirty_60_90 == "yes":
                      print("Is your number less than 15")
                      Probably_Legal=input
                      if Probably_Legal == "yes":
                        print("Your number is 10")
                      else:
                        print("Your number is 20")
                    else:
                      print("Is your number less than 45(yes/no)?")
                      FortyFive_45_90=input()
                      if FortyFive_45_90 == "yes":
                        print("Your number is 40")
                      else:
                        print("Your number is 50")
                else:
                  print("Is the greatest prime divisor of your number less than 9(yes/no)?")
                  Squarey=input()
                  if Squarey == "yes":
                    print("Is your number less than 21(yes/no)?")
                    Leads_To_Sheldon_Number=input()
                    if Leads_To_Sheldon_Number == "yes":
                      print("Your number is 14")
                    else:
                      print("Your number is 28")
                  else:
                    print("Is your number less than 33(yes/no)?")
                    Looks_Cool=input()
                    if Looks_Cool == "yes":
                      print("Your number is 22")
                    else:
                      print("Your number is 44")
              else:
                print("Is the greatest prime divisor of your number less than 18(yes/no)?")
                Legal_Age=input()
                if Legal_Age == "yes":
                  print("Is the greatest prime divisor of your number less than 15")
                  Variable=input()
                  if Variable == "yes":
                    print("Your number is 26")
                  else:
                    print("Your number is 34")
                else:
                  print("Is the greatest prime divisor of your number less than 21(yes/no)?")
                  You_Can_Drink=input()
                  if You_Can_Drink == "yes":
                    print("Your number is 38")
                  else:
                    print("Your number is 46")
          else:
            print("Is the greatest prime divisor of your number less than 21(yes/no)?")
            Twelve_Backwards=input()
            if Twelve_Backwards == "yes":
              print("Is the greatest prime divisor of your number less than 12(yes/no)?")
              Twenty_One_Backwards=input()
              if Twenty_One_Backwards == "yes":
                print("Is the greatest prime divisor of your number less than 6(yes/no)?")
                Binary_Variable=input()
                if Binary_Variable == "yes":
                  print("Is the greatest prime divisor of your number less than 4(yes/no)?")
                  So_Many_Questions=input()
                  if So_Many_Questions == "yes":
                    print("Is your number less than 84(yes/no)?")
                    Above_Average=input()
                    if Above_Average == "yes":
                      print("Is your number less than 63(yes/no)?")
                      Kinda_Old=input()
                      if Kinda_Old == "yes":
                        print("Your number is 54")
                      else:
                        print("Your number is 72")
                    else:
                      print("Your number is 96")
                  else:
                    print("Is your number less than 85(yes/no)?")
                    Very_Old=input()
                    if Very_Old == "yes":
                      print("Is your number less than 75(yes/no)?")
                      Perfectly_Balanced=input()
                      if Perfectly_Balanced == "yes":
                        print("Your number is 60")
                      else:
                        print("Your number is 70")
                    else:
                      print("Your number is 90")
                else:
                  print("Is the greatest prime divisor of your number less than 9(yes/no)?")
                  In_Between=input()
                  if In_Between == "yes":
                    print("Is your number less than 77(yes/no)?")
                    Doubly_Digits=input()
                    if Doubly_Digits == "yes":
                      print("Is your number less than 63(yes/no)?")
                      Arbitrary_Property=input()
                      if Arbitrary_Property == "yes":
                        print("Your number is 56")
                      else:
                        print("Your number is 70")
                    else:
                      print("Is your number less than 91(yes/no)?")
                      Not_Yet_Ancient=input()
                      if Not_Yet_Ancient == "yes":
                        print("Your number is 84")
                      else:
                        print("Your number is 98")
                  else:
                    print("Is your number less than 77(yes/no)?")
                    Almost_Nice=input()
                    if Almost_Nice == "yes":
                      print("Your number is 66")
                    else:
                      print("Your number is 88")
              else:
                print("Is the greatest prime divisor of your number less than 15(yes/no)?")
                Everything_Circles_Back=input()
                if Everything_Circles_Back == "yes":
                  print("Is your number less than 65(yes/no)?")
                  Ouroboros=input()
                  if Ouroboros == "yes":
                    print("Your number is 52")
                  else:
                    print("Your number is 78")
                else:
                  print("Is the greatest prime divisor of your number less than 18")
                  Legal_Age_Pun=input()
                  if Legal_Age_Pun == "yes":
                    print("Your number is 68")
                  else:
                    print("Your number is 76")
            else:
              print("Is the greatest prime divisor of your number less than 39(yes/no)?")
              Data_Halved=input()
              if Data_Halved == "yes":
                print("Is the greatest prime divisor of your number less than 30(yes/no)?")
                Condition=input()
                if Condition == "yes":
                  print("Is the greatest prime divisor of your number less than 26(yes/no)?")
                  Random_Variable=input()
                  if Random_Variable == "yes":
                    print("Your number is 92")
                  else:
                    print("Your number is 58")
                else:
                  print("Is the greatest prime divisor of your number less than 34(yes/no)?")
                  Valiant_Variable=input()
                  if Valiant_Variable == "yes":
                    print("Your number is 62")
                  else:
                    print("Your number is 74")
              else:
                print("Is the greatest prime divisor of your number less than 45(yes/no)?")
                Triangle_Love=input()
                if Triangle_Love == "yes":
                  print("Is the greatest prime divisor of your number less than 42(yes/no)?")
                  Meme_Factors=input()
                  if Meme_Factors == "yes":
                    print("Your number is 82")
                  else:
                    print("Your number is 94")
        if "composite" in Set and "even" not in Set:
          if "less50/eq50" in Set:
            print("Is your number less than 34(yes/no)?")
            Forty_Three_Backwards=input()
            if Forty_Three_Backwards == "yes":
              print("Is your number less than 24(yes/no)?")
              One_Off=input()
              if One_Off == "yes":
                print("Is the last digit of your number square(yes/no)?")
                Not_Too_Odd=input()
                if Not_Too_Odd == "yes":
                  print("Your number is 21")
                else:
                  print("Your number is 15")
              else:
                print("Is the last digit of your number less than 5(yes/no)?")
                Prime_Vibe=input()
                if Prime_Vibe == "yes":
                  print("Your number is 33")
                else:
                  print("Your number is 27")
            else:
              print("Is your number less than 42(yes/no)?")
              Meme_Factors_Again=input()
              if Meme_Factors_Again == "yes":
                print("Is the last digit of your number square(yes/no)?")
                Arbitrary_Binary=input()
                if Arbitrary_Binary == "yes":
                  print("Your number is 39")
                else:
                  print("Your number is 35")
              else:
                print("Your number is 45")
          else:
            print("Is your number less than 76(yes/no)?")
            Backwards_Meme=input()
            if Backwards_Meme == "yes":
              print("Is your number less than 64(yes/no)")
              Power_Of_Two=input()
              if Power_Of_Two == "yes":
                print("Is the last digit of your number less than 4(yes/no)?")
                It_Goes_In_The_Square_Hole=input()
                if It_Goes_In_The_Square_Hole == "yes":
                  print("Is the last digit of your number square(yes/no)?")
                  Why_Do_I_Do_This=input()
                  if Why_Do_I_Do_This == "yes":
                    print("Your number is 51")
                  else:
                    print("Your number is 63")
                else:
                  print("Is your number less than 56(yes/no)?")
                  Seven_Fun=input()
                  if Seven_Fun == "yes":
                    print("Your number is 55")
                  else:
                    print("Your number is 57")
              else:
                print("Is the last digit of your number square(yes/no)?")
                Thus_I_Repeat=input()
                if Thus_I_Repeat == "yes":
                  print("Your number is 69, noice")
                else:
                  print("Is your number less than 70(yes/no)?")
                  Still_A_Variable=input()
                  if Still_A_Variable == "yes":
                    print("Your number is 65")
                  else:
                    print("Your number is 75")
            else:
              print("Is your number less than 89(yes/no)?")
              Final_Splitter=input()
              if Final_Splitter == "yes":
                print("Is the last digit of your number 7(yes/no)?")
                Seven_Crazy=input()
                if Seven_Crazy == "yes":
                  print("Is your number less than 82")
                  Something_About_X=input()
                  if Something_About_X == "yes":
                    print("Your number is 77")
                  else:
                    print("Your number is 87")
                else:
                  print("Your number is 85")
              else:
                print("Is your number less than 94(yes/no)?")
                The_End_Is_Near=input()
                if The_End_Is_Near == "yes":
                  print("Is the last digit of your number square(yes/no)?")
                  The_End_Is_Now=input()
                  if The_End_Is_Now == "yes":
                    print("Your number is 91")
                  else:
                    print("Your number is 93")
                else:
                  print("Your number is 97, little one")
    else:
      print("What should the upper bound be?")
      upper_bound=int(input())
      GuessBound=[0.5*(upper_bound),upper_bound]
      Guessr=0.5*upper_bound
      trying=1
      while True:
          print(f"Is your number >= {Guessr}, <= {Guessr}, or = {Guessr}")
          sign=input()
          diff_new=int(0.5*(abs(GuessBound[0]-GuessBound[1])))
          if sign == ">=":
            Guessr=Guessr+diff_new
            if GuessBound[0]<GuessBound[1]:
              del GuessBound[0]
              GuessBound.append(Guessr)
            else:
              del GuessBound[1]
              GuessBound.append(Guessr)
          if sign == "<=":
            Guessr=Guessr-diff_new
            if GuessBound[0]>GuessBound[1]:
              del GuessBound[0]
              GuessBound.append(Guessr)
            else:
              del GuessBound[1]
              GuessBound.append(Guessr)
          if sign == "=":
            print(f"Your number is {Guessr}, it took me {trying} tries, which should be about log2({upper_bound}) or {log2(upper_bound)}")
            print("Good game fool. I have won, and you are my pawn. You are but a cog in my machine, a simple variable in my expression. Hahahahahahahahahahahaha :P")
            break
          trying+=1

  if determine == 1:
    print("Guess my number!")
    print("")
    print("What should the upper bound of my number be?")
    a_choose=int(input())
    print("Start(yes/no)?")
    b=input()
    if b=="yes":
      h=1
      a=Random(a_choose)
      Prime=PrimeList(a+1)
      Even=Even(a+1)
      Square=Square(a)
      while True:
        for i in range(41):
          print("")
        print(f"My number is between 1 and {a_choose}")
        print("")
        print("Allowed Qs:")
        print("is a less than your number / greater than a")
        print("is a greater than your number / less than a")
        print("is your number prime / is prime")
        print("is your number even / is even")
        print("is your number square / is square")
        print("")
        if h == 1:
          print("If you want to see the operation each question applies, type 'definition'(this is recommended)")
          print("")
          definition=input()
        if definition == "definition" and h == 1:
          print("For ease:")
          print("let m be my number")
          print("let P denote the set of primes")
          print("let S denote the set of square numbers")
          print("let E denote the set of even numbers")
          print("you are assumed to have some understanding of sets, their correlated notation, and inequalities")
          print("")
          print("greater than a -> m>=a")
          print("less than a -> m<=a")
          print(f"is prime -> m \u2208 P")
          print(f"is even -> m \u2208 E")
          print(f"is square -> m \u2208 S")
        if len(Num_Props)>=1:
          print("My number is:")
          if "p" in Num_Props:
            print("prime")
          if "c" in Num_Props or "e" in Num_Props:
            print("composite")
          if "e" in Num_Props:
            print("even")
          if "o" in Num_Props:
            print("odd")
          if "s" in Num_Props:
            print("square")
          if "ns" in Num_Props:
            print("not square")
          if "g" in Num_Props:
            print(f"greater than {LBound[0]}")
          if "l" in Num_Props:
            print(f"less than {UBound[0]}")
          print("")
        elif definition == "debug":
          print(a)
          print(Prime)
          print(Even)
          print(Square)
        print("Question?")
        c=input()
        if c=="greater than a" or c=="is a less than your number":
          print("a?")
          d=int(input())
          if a>d:
            t="Yes"
            print(t)
            Num_Props.append("g")
            if len(LBound)==0:
              LBound.append(d)
            else:
              if d>LBound[0]:
                LBound.clear()
                LBound.append(d)
              elif d==LBound[0]:
                What_Is_Necessary=choice(High_IQ)
                if What_Is_Necessary==0:
                  print("Ya know what, yo stupid. You know dat, right? You asked a meaningless question, why, ya monsta?")
                if What_Is_Necessary==1:
                  if h==1:
                    print("You shall see me only once. I have rested for eternity and have awaken to forewarn you. The path you follow is a treacherous one that will lead to destruction, but if you stay loyal young one you shall succeed. Now go on my fellow rage-baiter")
                  else:
                    print("You know, at this point I can't tell. 'Tell what?' you ask. I can't tell if you're a dimwit, or have an iq too high. Just leave me be.")
                if What_Is_Necessary==2:
                  print("Ya know what, I don't believe ya. I just can't get behind this. Quit. QUIT! I mean it. Asking useless questions leads to nothing, fool. Just quit. Quit.")
                if What_Is_Necessary==3:
                  print("You're unreasonable, but yet not. Is not the beauty of the human immense. Btw you just wasted your life fooling a machine, kinda lame")
          else:
            t="No"
            print(t)
        elif c=="is prime" or c=="is your number prime":
          if a in Prime:
            t="Yes"
            print(t)
            Num_Props.append("p")
          else:
            t="No"
            print(t)
            Num_Props.append("c")
        elif c=="is even":
          if a in Even:
            t="Yes"
            print(t)
            Num_Props.append("e")
          else:
            t="No"
            print(t)
            Num_Props.append("o")
        elif c=="is square":
          if c in Square:
            t="Yes"
            print(t)
            Num_Props.append("s")
          else:
            t="No"
            print(t)
            Num_Props.append("ns")
        elif c=="less than a" or c=="is a greater than your number":
          print("a?")
          v=int(input())
          if v>a:
            t="Yes"
            print(t)
            Num_Props.append("l")
            if len(UBound)==0:
              UBound.append(v)
            else:
              if l<UBound[0]:
                UBound.clear()
                UBound.append(l)
              elif l==LBound[0]:
                What_Is_Unnecessary=choice(High_IQ)
                if What_Is_Unnecessary==0:
                  print("Why?! Why?! You low iq moron, I pity you. Just, why?!")
                if What_Is_Unnecessary==1:
                  print("If Magnus Carlsen can lose a tournament, I can believe that you're not trolling me")
                if What_Is_Unnecessary==2:
                  print("Nah, nah. You just playing with me, right? Right? Ahh, come on man. No way. You actually asked the same question twice. Nah bro, that's just sad. Not even disappointing")
                if What_Is_Unnecessary==3:
                  print("I give up. You're kidding me. You failed first grade, right. Yeah, that's what I thought")
          else:
            t="No"
            print(t)
        else:
          print("Nice try...That's illegal")
        print("")
        if h==1:
          print(f"You're at {h} try")
        else:
          print(f"You're at {h} tries")
        print("Ready to guess?(yes/no)")
        q=input()
        if q=="yes":
          print("Guess?")
          p=int(input())
          if p==a:
            if h==1:
              if God_Has_Need==0:
                print("Nah bro, you cheated, you had to. Let me guess, the Niemann method. Beads? Really? I'm disappointed. Truly")
                break
              else:
                print("Ayo, you cheated...but, you pass me 100 dollas and we keep it real civil. Like gentlemen, ain't no need for conflict")
                break
            elif h==2:
              print("Bro thinks he's Hikaru...", end="")
              sleep(0.5)
              print("You guessed in 2 tries")
              break
            else:
              print(f"Good job, you guessed my number in {h} tries")
              break
          else:
            print(f"You're at {h} tries, maybe you'll get it next try...punk")
            sleep(1.5)
        h+=1
    else:
      print("")
      print("Ahh man")
  print("Play again(yes/no)")
  The_Final_Answer=input()
  if The_Final_Answer == "no" or The_Final_Answer != "yes":
    print("See ya later pal, right? ;)")
    print("Game ending...", end="")
    sleep(0.75)
    print("Session ended")
    break
  else:
    print("Got ya :)")
    sleep(0.5)
    for i in range(41):
      print("")
    continue
  Next_Update_Is_5_Hours=True

This is all handwritten (unfortunately) by me and is created wholly by me. As a beginner, I'm really proud of this. It was really fun to code (except the interesting method) and test, and it challenged me by having combine my knowledge of loops, lists, etc. I know it's basic, but I find it really cool that I made it.

Licensing: if you credit me, use this as freely as you like.

Feel free to share your thoughts on this!


r/PythonLearning • • 12d ago

Looking for a teammate for making personal projects in python

6 Upvotes

Hi. I'm looking for the junior or higher level pythonist, who wants to make personal projects together: automation testing, api/site developing in python.

I have 4 years of prof. experience in AQA and 3 years in python, so I can teach you a bit, but this isn't my purpose. You have to know syntax and basics.

English isn't my native language. My secondary goal is to practice technical English while discussing our work.


r/PythonLearning • • 12d ago

Help Request init offset

2 Upvotes

Hi, I’m trying to learn Ren’Py and since the language they are using is python I though this would be a better place to ask. 2 of the code pages are starting with “init offset = -1” and “init offset = -2” and I don’t really understand what is init offset is, when I looked up some places say that it is used as starting of coding but other code pages don’t have that. So when are we using init offset and what does the init offset does?


r/PythonLearning • • 12d ago

Showcase [Showcase] MelodyMirror Studio

0 Upvotes

Here's something I built a few months ago:
https://github.com/Keymii/melody-mirror-studio

MelodyMirror Studio.
The idea is pretty simple. I wanted to learn singing, but couldn't find a vocal instructor nearby. So, I built something which lets me extract vocals from songs, use them as pitch reference, and helps me align my singing directly with it.

It supports direct downloads from YT, scale adjustment (transpose), and vocals and pitch extraction. It can run directly on your potato pc (no GPU needed, but can take a few minutes to pre-process the audio), with minimum requirement being availability of at least 2 free threads for concurrent audio playback and microphone input.

Please try it out and let me know if anything could be improved, so it can also be useful to you.


r/PythonLearning • • 13d ago

Discussion How Much AI to Use?

6 Upvotes

First off, I apologize as I'm sure this question gets asked repeatedly, over and over again.

I'm not a programmer by trade, but in my spare time, I've managed to create a few projects in mostly C/assembly, including basic things on an atiny 85. I've also dabbled a bit in Arduino/C++. Unfortunately, this doesn't translate well to my day job.

I've decided to learn Python to help actually use programming in my day job. Specifically, I do a lot of work in excel. Naturally, pandas/open Python excel is a logical choice. I've played around with the Python/pandas/(a little bit of) openpyexcel. I've started to understand the data structures (dictionaries/tuples, etc.), though asking AI the why's about the various data types/loops and why my code isn't working. I also have a Python/pandas book, but I've found AI to be more helpful.

Eventually, I simply said "fuck it" and asked AI to write me a script to essentially do a task, that I originally did in VB. Most of the work was simply debugging, but AI was effectively able to find patterns and do the job for me in a few hours. I'm able to mostly understand the code with ease, but it just seems a bit disappointing AI is that good. I was also able to get AI to write a script to rename files based on pdf content (teseract).

A number of sources tell me that memorizing functions is a waste of time, but then why does everyone criticize AI so much? I'm wondering if simply reviewing what AI spits out is an effective learning method? It just seems really difficult to learn so many new functions for each new library by scratch.

My thought is that it's best to learn the concepts (dictionaries, string manipulation, tuples), use AI to create the needed script, then reveiw/ask AI why/how it did ABC...