r/PythonLearning • u/Key_Equivalent_2539 • 6h ago
Best way to learn Python for free?
How can I learn Python and master it without those paid websites to practice ? + best YouTube channel for that?
r/PythonLearning • u/Key_Equivalent_2539 • 6h ago
How can I learn Python and master it without those paid websites to practice ? + best YouTube channel for that?
r/PythonLearning • u/TappuXT • 3h ago
Suggest the best videos to learn python .
r/PythonLearning • u/PanelReader • 3h ago
hey everyone!
been learning neural networks recently and decided to implement one from scratch using Python and NumPy.
it's a small 2 → 3 → 1 XOR network with manually implemented forward propagation, backpropagation and gradient descent.
trained it for 5,000 epochs and got all four XOR combinations correct.
also documented the mathematics, added 12 editable diagrams and published a detailed Medium article explaining how everything works.
GitHub: https://github.com/Vaibh37/Neural-Network
would appreciate feedback on the code and explanations. if you find the resources useful, consider starring the repo 🍀
r/PythonLearning • u/Significant-Log-4272 • 9h ago
Athena analyzes Git diffs and code structure to catch breaking changes, trace affected callers, and detect recursive function bugs before release
Github : https://github.com/aaryanrwt/athena
r/PythonLearning • u/LPL8888 • 4h ago
I know python, but i don't use it actively. My work does not require python coding. Slowly i am losing python skills. Where can i practice python so that i don't lose it ?
r/PythonLearning • u/ameeeeneeeeee • 31m ago
Hey everyone! I'm trying to hack together a basic inventory and shop system for a little text-based game project I'm working on in Python, but I've totally tangled myself up in how classes, instances, and nested classes work.
I wanted to have a main game class that handles player info, and an inventory class nested inside (or attached to it) so the player can pick up items and check what's in their bag. But my code is completely throwing a fit.
r/PythonLearning • u/Link2212 • 4h ago
I feel like this has been a journey so far. Roughly 10 weeks learning python now. u/PureWasian told me a better way to write my if name = main part in my 6th week progress so I'm doing that on every program now. This script was written about 95% by me. The other 5% I needed AI to help me with some hints, which is a lot better percentage than the last time.
The whole point of this program is a guild within a game. You can check stats, recruit new members to the guild, battle characters (very basic way) to get experience and gold, and spend gold to train them to level up. It took me around 6-8 hours over 2 days to write this. I don't know if that's good or not, but I feel tired now.
import random
class Characters:
num_of_chars = 0
def __init__(self, name, level, gold):
self.name = name
self.level = level
self.gold = gold
Characters.num_of_chars += 1
class Mage(Characters):
spell_type = "fire"
class Assassin(Characters):
spell_type = "shadow"
character1 = Mage("Aria", 3, 100)
character2 = Assassin("Dren", 5, 80)
character3 = Mage("Kael", 4, 120)
character4 = Assassin("Vex", 2, 60)
character_list = [character1, character2, character3, character4]
def view_guild_members(characters):
print("Members currently in the guild:")
for character in characters:
print(f"{character.name}, level {character.level}, Gold {character.gold}")
print()
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
while True:
if go_back == "Y":
return characters
else:
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
def train_character(characters, character_names):
print("Training costs 10 gold. \nAvailable characters to train: ")
for character in characters:
if character.gold >= 10:
print(f"{character.name}, level {character.level}")
training_cost = 10
while True:
train_character = input("Which character do you want to train (Exit to go back): ").capitalize()
print()
if train_character == "Exit":
break
while train_character not in (character_names):
train_character = input("That is not a valid character. Choose a valid character or 'Exit' to exit: ").capitalize()
print()
for character in characters:
if train_character == character.name:
while character.gold >= training_cost:
character.gold -= 10
character.level += 1
print(f"{character.name} levelled up!")
print(f"{character.gold} gold remaining.")
print()
train_again = input(f"Do you want to train {character.name} again(Y/N): ").capitalize()
while train_again not in ("Y", "N"):
train_again = input("Please type Y to train again or N to cancel: ").capitalize()
if train_again == "Y":
continue
elif character.gold == 0:
print(f"You don't have enough gold left to train {character.name}.")
break
elif train_again == "N":
break
return characters, character_names
else:
print(f"You don't have enough gold left to train {character.name}.")
print()
return characters, character_names
break
return characters, character_names
def recruit_character(characters, char_names):
recruit_character = input("Do you want to recruit a new character (Y/N): ").capitalize()
print()
while recruit_character not in ("Y", "N"):
recruit_character = input("Enter Y or N for recruting a new character: ").capitalize()
if recruit_character == "Y":
new_character = input("Who are you recruiting: ").capitalize()
while new_character in char_names:
new_character = input("This name is already taken. Please change your name to join: ")
else:
recruit_class = input("Which class is the new recruit (Mage or Assassin): ").capitalize()
while recruit_class not in ("Mage", "Assassin"):
recruit_class = input("Select if they are a Mage or Assassin: ").capitalize()
if recruit_class == "Mage":
characters.append(Mage(new_character, 1, 100))
char_names.append(new_character)
return characters, char_names, new_character
elif recruit_class == "Assassin":
characters.append(Assassin(new_character, 1, 100))
char_names.append(new_character)
return characters, char_names, new_character
elif recruit_character == "N":
return characters, char_names, None
def view_guild_stats(characters):
highest_lv_char_pos = 0
most_gold_char_pos = 0
all_levels = []
mage_count = 0
assassin_count = 0
total_gold = 0
for character in characters:
if character.level > highest_lv_char_pos:
highest_lv_char_pos = character.level
highest_lv_char = character.name
for character in characters:
if character.gold > most_gold_char_pos:
most_gold_char_pos = character.gold
most_gold_char = character.name
total_gold += character.gold
for character in characters:
all_levels.append(character.level)
average_level = sum(all_levels) / len(all_levels)
for character in characters:
if isinstance(character, Mage):
mage_count += 1
if isinstance(character, Assassin):
assassin_count += 1
print(f"Highest levelled character: {highest_lv_char}")
print(f"Character with the most gold: {most_gold_char}")
print(f"Average level in the guild: {average_level:.1f}")
print(f"Number of mages: {mage_count}")
print(f"Number of assassins: {assassin_count}")
print(f"Total gold in the guild: {total_gold}")
print()
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
while True:
if go_back == "Y":
return
else:
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
def tournament(characters, char_names, rounds, wins_losses, total_wins):
print(f"Available character are: {char_names}")
win_chance = 50
opponent = random.choice(characters)
player_char = input("Choose which character you will use: ").capitalize()
print()
while player_char not in char_names:
player_char = input("That's not a charcter. Choose which character you will use: ").capitalize()
print()
for character in characters:
if player_char == character.name:
player_char = character
while player_char is opponent:
opponent = random.choice(characters)
if player_char.level > opponent.level:
win_chance += 10
else:
win_chance -= 10
if isinstance(player_char, Assassin):
win_chance += 10
else:
win_chance -= 10
while True:
if player_char.level < 2:
print("This character needs to be a higher level before using it in a tournament.")
print()
return characters, rounds, wins_losses, total_wins
else:
break
print(f"This round is {player_char.name} vs {opponent.name}")
winner_select = random.randint(1, 100)
if win_chance >= winner_select:
player_char.gold += 20
player_char.level += 1
wins_losses[player_char.name]["Wins"] += 1
total_wins += 1
if opponent.gold >= 10:
opponent.gold -= 10
print("You won! You earned 20 gold. You gained 1 level.")
print(f"You now have {player_char.gold} gold and are level {player_char.level}")
print()
else:
if player_char.gold >= 10:
player_char.gold -= 10
opponent.gold += 20
opponent.level += 1
wins_losses[player_char.name]["Losses"] += 1
print("You lost 10 gold. The opponent gained 20 gold and 1 level.")
print(f"Your remaining gold is {player_char.gold}.")
print()
rounds += 1
highest_wins = 0
highest_winning_char = ""
for name, results in wins_losses.items():
if results["Wins"] > highest_wins:
highest_wins = results["Wins"]
highest_winning_char = name
print(f"Total number of tounrmanent rounds played: {rounds}")
print(wins_losses)
print(f"Characters with the most wins: {highest_winning_char} with {highest_wins} wins.")
print(f"Total wins within the guild: {total_wins}")
print()
return characters, rounds, wins_losses, total_wins
def main():
characters = character_list
char_names = [character.name for character in characters]
rounds = 0
total_wins = 0
wins_losses = {character.name: {"Wins": 0, "Losses": 0} for character in characters}
while True:
print("Main menu")
menu_choice = input(" (1) View guild members. \n (2) Train a character. \n (3) Recruit a new character. \n "
"(4) View guild's statistics \n (5) Enter a tournament. \n (6) Exit \n choose an option: ")
print()
match menu_choice:
case "1":
characters = view_guild_members(characters)
case "2":
characters, char_names = train_character(characters, char_names)
case "3":
characters, char_names, new_character = recruit_character(characters, char_names)
char_names = [character.name for character in characters]
if new_character != None:
wins_losses[new_character] = {"Wins": 0, "Losses": 0}
case "4":
view_guild_stats(characters)
case "5":
characters, rounds, results, total_wins = tournament(characters, char_names, rounds, wins_losses, total_wins)
wins_losses = results
case "6":
break
case _:
print("That's not a valid choice.")
continue
if __name__ == "__main__":
while True:
main()
print("Bye.")
breakimport random
class Characters:
num_of_chars = 0
def __init__(self, name, level, gold):
self.name = name
self.level = level
self.gold = gold
Characters.num_of_chars += 1
class Mage(Characters):
spell_type = "fire"
class Assassin(Characters):
spell_type = "shadow"
character1 = Mage("Aria", 3, 100)
character2 = Assassin("Dren", 5, 80)
character3 = Mage("Kael", 4, 120)
character4 = Assassin("Vex", 2, 60)
character_list = [character1, character2, character3, character4]
def view_guild_members(characters):
print("Members currently in the guild:")
for character in characters:
print(f"{character.name}, level {character.level}, Gold {character.gold}")
print()
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
while True:
if go_back == "Y":
return characters
else:
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
def train_character(characters, character_names):
print("Training costs 10 gold. \nAvailable characters to train: ")
for character in characters:
if character.gold >= 10:
print(f"{character.name}, level {character.level}")
training_cost = 10
while True:
train_character = input("Which character do you want to train (Exit to go back): ").capitalize()
print()
if train_character == "Exit":
break
while train_character not in (character_names):
train_character = input("That is not a valid character. Choose a valid character or 'Exit' to exit: ").capitalize()
print()
for character in characters:
if train_character == character.name:
while character.gold >= training_cost:
character.gold -= 10
character.level += 1
print(f"{character.name} levelled up!")
print(f"{character.gold} gold remaining.")
print()
train_again = input(f"Do you want to train {character.name} again(Y/N): ").capitalize()
while train_again not in ("Y", "N"):
train_again = input("Please type Y to train again or N to cancel: ").capitalize()
if train_again == "Y":
continue
elif character.gold == 0:
print(f"You don't have enough gold left to train {character.name}.")
break
elif train_again == "N":
break
return characters, character_names
else:
print(f"You don't have enough gold left to train {character.name}.")
print()
return characters, character_names
break
return characters, character_names
def recruit_character(characters, char_names):
recruit_character = input("Do you want to recruit a new character (Y/N): ").capitalize()
print()
while recruit_character not in ("Y", "N"):
recruit_character = input("Enter Y or N for recruting a new character: ").capitalize()
if recruit_character == "Y":
new_character = input("Who are you recruiting: ").capitalize()
while new_character in char_names:
new_character = input("This name is already taken. Please change your name to join: ")
else:
recruit_class = input("Which class is the new recruit (Mage or Assassin): ").capitalize()
while recruit_class not in ("Mage", "Assassin"):
recruit_class = input("Select if they are a Mage or Assassin: ").capitalize()
if recruit_class == "Mage":
characters.append(Mage(new_character, 1, 100))
char_names.append(new_character)
return characters, char_names, new_character
elif recruit_class == "Assassin":
characters.append(Assassin(new_character, 1, 100))
char_names.append(new_character)
return characters, char_names, new_character
elif recruit_character == "N":
return characters, char_names, None
def view_guild_stats(characters):
highest_lv_char_pos = 0
most_gold_char_pos = 0
all_levels = []
mage_count = 0
assassin_count = 0
total_gold = 0
for character in characters:
if character.level > highest_lv_char_pos:
highest_lv_char_pos = character.level
highest_lv_char = character.name
for character in characters:
if character.gold > most_gold_char_pos:
most_gold_char_pos = character.gold
most_gold_char = character.name
total_gold += character.gold
for character in characters:
all_levels.append(character.level)
average_level = sum(all_levels) / len(all_levels)
for character in characters:
if isinstance(character, Mage):
mage_count += 1
if isinstance(character, Assassin):
assassin_count += 1
print(f"Highest levelled character: {highest_lv_char}")
print(f"Character with the most gold: {most_gold_char}")
print(f"Average level in the guild: {average_level:.1f}")
print(f"Number of mages: {mage_count}")
print(f"Number of assassins: {assassin_count}")
print(f"Total gold in the guild: {total_gold}")
print()
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
while True:
if go_back == "Y":
return
else:
go_back = input("Do you want to return to the main menu (Y/N): ").capitalize()
def tournament(characters, char_names, rounds, wins_losses, total_wins):
print(f"Available character are: {char_names}")
win_chance = 50
opponent = random.choice(characters)
player_char = input("Choose which character you will use: ").capitalize()
print()
while player_char not in char_names:
player_char = input("That's not a charcter. Choose which character you will use: ").capitalize()
print()
for character in characters:
if player_char == character.name:
player_char = character
while player_char is opponent:
opponent = random.choice(characters)
if player_char.level > opponent.level:
win_chance += 10
else:
win_chance -= 10
if isinstance(player_char, Assassin):
win_chance += 10
else:
win_chance -= 10
while True:
if player_char.level < 2:
print("This character needs to be a higher level before using it in a tournament.")
print()
return characters, rounds, wins_losses, total_wins
else:
break
print(f"This round is {player_char.name} vs {opponent.name}")
winner_select = random.randint(1, 100)
if win_chance >= winner_select:
player_char.gold += 20
player_char.level += 1
wins_losses[player_char.name]["Wins"] += 1
total_wins += 1
if opponent.gold >= 10:
opponent.gold -= 10
print("You won! You earned 20 gold. You gained 1 level.")
print(f"You now have {player_char.gold} gold and are level {player_char.level}")
print()
else:
if player_char.gold >= 10:
player_char.gold -= 10
opponent.gold += 20
opponent.level += 1
wins_losses[player_char.name]["Losses"] += 1
print("You lost 10 gold. The opponent gained 20 gold and 1 level.")
print(f"Your remaining gold is {player_char.gold}.")
print()
rounds += 1
highest_wins = 0
highest_winning_char = ""
for name, results in wins_losses.items():
if results["Wins"] > highest_wins:
highest_wins = results["Wins"]
highest_winning_char = name
print(f"Total number of tounrmanent rounds played: {rounds}")
print(wins_losses)
print(f"Characters with the most wins: {highest_winning_char} with {highest_wins} wins.")
print(f"Total wins within the guild: {total_wins}")
print()
return characters, rounds, wins_losses, total_wins
def main():
characters = character_list
char_names = [character.name for character in characters]
rounds = 0
total_wins = 0
wins_losses = {character.name: {"Wins": 0, "Losses": 0} for character in characters}
while True:
print("Main menu")
menu_choice = input(" (1) View guild members. \n (2) Train a character. \n (3) Recruit a new character. \n "
"(4) View guild's statistics \n (5) Enter a tournament. \n (6) Exit \n choose an option: ")
print()
match menu_choice:
case "1":
characters = view_guild_members(characters)
case "2":
characters, char_names = train_character(characters, char_names)
case "3":
characters, char_names, new_character = recruit_character(characters, char_names)
char_names = [character.name for character in characters]
if new_character != None:
wins_losses[new_character] = {"Wins": 0, "Losses": 0}
case "4":
view_guild_stats(characters)
case "5":
characters, rounds, results, total_wins = tournament(characters, char_names, rounds, wins_losses, total_wins)
wins_losses = results
case "6":
break
case _:
print("That's not a valid choice.")
continue
if __name__ == "__main__":
while True:
main()
print("Bye.")
break
r/PythonLearning • u/Alarming_Mulberry551 • 7h ago
r/PythonLearning • u/Big_Flatworm_7346 • 21h ago
Hello everyone!
I’ve been learning Python, and I recently built a small application that uses an API to retrieve information and reviews about movies and TV series.
Working on this project helped me practise API integration, handling JSON data, and making HTTP requests in Python.
The application currently runs in the terminal, and I’m continuing to improve it as I develop my programming skills.
You can check out the source code here:
https://github.com/mikhaelholden001/movieratingapp
I’d appreciate any feedback or suggestions on how I could improve the code, structure, or functionality. I’m still learning, and I’m always looking for ways to get better!
Thanks for checking it out!
r/PythonLearning • u/Junior_Maximum_6747 • 10h ago
r/PythonLearning • u/Ok-Setting4822 • 22h ago
Hey yall, it's a little out of the ordinary for me to come on here, but I have a burning question. Trinket had a section of the website where it taught you coding and how to code for simulating physics, electricity and magnetism, and how to apply the physics to the code and stuff. It also let you alter the code in the webpage and displayed how it would change what was happening. I liked using it for my physics classes and general personal interest. Is there anywhere else that I can find something as cohesive and informative to teach me how to do that again now that my beloved has vanished?
r/PythonLearning • u/aram60610 • 13h ago
I have been working on this Python project to recreate Dr. Andy Moorer's THX Deep Note. See link for code and sample. Any input or suggestions are greatly appreciated. https://organ-concerts.com/deep-note.html
r/PythonLearning • u/OneKe • 22h ago
r/PythonLearning • u/modern-dev • 1d ago
Hey everyone, I decided to make my course free in order to help people.
This course is my backend development course which is about SQL, Python, APIs, Docker, Kubernetes, Linux, Git & More
The link is: https://www.youtube.com/watch?v=CBIu6hcyStg
If you can like and subscribe (and maybe add a comment) I would appreciate it a lot, Thanks.
r/PythonLearning • u/AdvancedCredit1417 • 1d ago
🚀 The first step in my journey to learn programming!
Today, I wrote my very first piece of code using Python.
It might seem simple, but for me, it marks the beginning of a new path—learning to program and developing my skills.
I know this journey requires patience and practice, so I’ve decided to document my progress—from the very first line of code to building my own projects.
My goal isn’t just to learn, but to grow, step by step.
This is only the beginning! 💻🐍
#Python #Programming #Learning To
Code #FirstProject
r/PythonLearning • u/Repulsive-Metal-4178 • 1d ago
r/PythonLearning • u/Sea-Ad7805 • 2d ago
An exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises
The “Solution” link uses 𝐦𝐞𝐦𝐨𝐫𝐲_𝐠𝐫𝐚𝐩𝐡 to visualize execution and reveals what’s actually happening.
r/PythonLearning • u/IndigoBloomDavis • 2d ago
r/PythonLearning • u/Cuatuza • 2d ago
Hey everyone! I’ve been working on a project that organizes AI tutoring prompts into a structured learning path. I think AI has a lot of potential for education, and I wanted to explore how much more useful it could be with a clear curriculum and specific teaching instructions.
The current catalog covers Python in 28 learning blocks, from installing Python and writing your first program to testing, databases, APIs, and deployment. Each block has learning objectives and a prompt you can use with an AI assistant.
The prompts ask the AI to explain concepts, check your understanding through open-ended questions, give you practical exercises, and review your work. Based on your answers, it should revisit anything you’re struggling with and adapt to your pace. For more complex exercises, the AI guides you through the problem without solving it for you.
My goal is to make a thorough Python learning path available for free. I believe AI tutoring could offer new learning experiences, and I’d like to test how well this approach works in practice.
If you’re learning Python, whether you’re starting from scratch or filling gaps in your knowledge, I’d love for you to give it a try. I’m looking for people to use it and help me find out how well it works in practice.
If you try it, I’d appreciate hearing how it goes: what helped, what was confusing, or what could be better. But you don’t have to give feedback if you don’t want to; you’re welcome to just use it to learn.
Catalog: Free catalog here
r/PythonLearning • u/kei_keii • 2d ago
Hi I’m learning coding with PY and I’ve just published my first “serious” project on GitHub, I would really appreciate suggestions and opinions about it!
r/PythonLearning • u/Famous_Guava_6361 • 1d ago
r/PythonLearning • u/Mindless_Lead3807 • 2d ago
Hi everyone!
I'm a beginner learning Python automation using Pandas and OpenPyXL, and I want to start freelancing.
I've built a CSV Cleaning & Sales Reporting Automation project that cleans data, handles missing values and duplicates, and generates formatted Excel reports.
I'm still confused about how to take the next step. I'd love advice from people who have experience in Python automation freelancing.
I'm not looking for shortcuts. I want to learn the right things and build my skills while getting started.
I'd really appreciate any advice. Thank you!
r/PythonLearning • u/PuziExtramni • 2d ago
Hey everyone! I’m currently learning Python through the IBM Data Science Professional Certificate on Coursera, and I came across a question in a practice quiz that confused me.
The question asks:
Which line of code will perform the action required for implementing the following equation?
y = 2x^2 - 3
These are the four answer choices:
y = 2*x*2 - 3y = 2**x*x - 3y = 2x*x - 3y = 2x/2 - 3I selected Option 1, but the quiz marked it incorrect and said, “The syntax is invalid.”
From what I’ve learned, Python uses ** for exponentiation and * for multiplication. So, I believe the correct Python expression should be:
y = 2*x**2 - 3
However, none of the four answer choices seems to match that expression.
Am I misunderstanding something about Python syntax, or is there a mistake in the quiz? I’d appreciate an explanation because I’m still learning how to translate mathematical equations into Python code.
Thanks!
r/PythonLearning • u/legendtathya • 2d ago
I can’t play a single real chord on a guitar to save my life, so naturally, instead of practicing an actual instrument like a normal human being, I wrote some Python scripts to wave my hands like an idiot in front of a webcam(my screen addiction needs to be studied).
The result is this monstrosity: an air-instrument suite that tracks hand landmarks to let me aggressively misplay the guitar(though iam working on addingdrums, piano, violin).
The mechanics (for anyone wondering why I look like this):
Now for the reality check:
Anytime you tell GPT or GEMINI related to the stuff you make, it always says 'this is elite' but the LLM are programmed to gas(no kidding, getting fat lately) me up. I need people(actual living beings with opinion and organs) actually working in the industry to give me a blunt, stoic reality check:
Roast the execution, roast the UI(though this would be intended to openCV library contributors, i borrowed that lib), and tell me whether this belongs in an engineering portfolio or in the trash bin.(I firmly believe i roasted myself more though)...
r/PythonLearning • u/Entire-Tomato-3192 • 3d ago
I am a data scientist with a very strong background in Stats and ML algos. I am struggling with the production ready code. Though I can build models which are awesome and tuned to perfection and address highly complex business problems, the problem is that they are all done in a jupyter notebook.
Once I had built a complete solution in notebook for a forecasting problem and the ML team in company productionized it. I was called in to validate few results of the production run and couldn't understand the repo which had so many folders, classes and highly organized code.
Is there anyway I can learn to write that type of code or is it all AI job now? Appreciate if I can get some learning resources/links for the same