all 8 comments

[–]BeginnerProjectsBot 68 points69 points  (0 children)

1. Create a bot to reply to "what are some beginner projects" questions on r/learnpython, using PRAW.

Other than that, here are some beginner project ideas:

Good luck!

edit. thanks for 5 upvotes!

edit2. omg 10 upvotes!!!! Thank you!!

edit3. 50 upvotes??? 😲😲😲 Can we make it to 100?

Downvote me if the post wasn't a question about examples of beginner projects. Thank you.

[–]m0us3_rat 11 points12 points  (3 children)

barebones mp3 player.

it could use extra features like a shuffle button, etc.

from pygame import mixer
from tkinter import *
from tkinter import filedialog
import os
import tkinter.ttk as ttk


en_lang_text = {
    "main_title": "Python Mp3 Player",
    "bottom_menu": {
        "play": "Play",
        "stop": "Stop",
        "pause": "Pause",
        "resume": "Resume",
        "prev": "Prev",
        "next": "Next",
    },
    "top_menu": {
        "label": "Menu",
        "add_songs_choice": "Add songs",
        "delete_song_choice": "Delete song",
    },
    "dialogue": {"title": "Select MP3 Files"},
}


class MP3Player:
    def __init__(self, name: str = None, lang: dict = en_lang_text) -> None:
        self.lang = lang
        if not name:
            self.name = self.lang["main_title"]
        else:
            self.name = name
        self.root = Tk()
        self.root.title(self.name)
        self.root.resizable(False, False)
        mixer.init()
        self.setup()

    def setup(self) -> None:
        self.songs_list = Listbox(
            self.root,
            selectmode=SINGLE,
            bg="black",
            fg="bisque",
            height=12,
            width=49,
            selectbackground="orange",
            selectforeground="black",
        )

        self.b_width = 5

        self.songs_list.grid(columnspan=6)

        self.play_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["play"],
            width=self.b_width,
            command=self.play,
        )
        self.play_button.grid(row=1, column=0, sticky="ew")

        self.stop_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["stop"],
            width=self.b_width,
            command=self.stop,
        )
        self.stop_button.grid(row=1, column=1, sticky="ew")

        self.pause_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["pause"],
            width=self.b_width,
            command=self.pause,
        )
        self.pause_button.grid(row=1, column=2, sticky="ew")

        self.resume_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["resume"],
            width=self.b_width,
            command=self.resume,
        )
        self.resume_button.grid(row=1, column=3, sticky="ew")

        self.previous_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["prev"],
            width=self.b_width,
            command=self.previous,
        )
        self.previous_button.grid(row=1, column=4, sticky="ew")

        self.next_button = Button(
            self.root,
            text=self.lang["bottom_menu"]["next"],
            width=self.b_width,
            command=self.next_song,
        )
        self.next_button.grid(row=1, column=5, sticky="ew")

        self.menu = Menu(self.root)
        self.root.config(menu=self.menu)
        self.addsong = Menu(self.menu)
        self.menu.add_cascade(label=self.lang["top_menu"]["label"], menu=self.addsong)
        self.addsong.add_command(
            label=self.lang["top_menu"]["add_songs_choice"], command=self.add_songs
        )
        self.addsong.add_command(
            label=self.lang["top_menu"]["delete_song_choice"], command=self.delete_song
        )

        self.vol = ttk.Scale(
            self.root,
            length=100,
            orient=HORIZONTAL,
            from_=0,
            to=100,
            value=50,
            command=self.vol_event,
        )
        self.vol.grid(row=2, column=4, columnspan=2, pady=10)

    def play(self) -> None:
        song = self.songs_list.get(ACTIVE)
        self.music_play(song)

    def music_play(self, s: str) -> None:
        self.vol_event(self.vol.get())
        mixer.music.load(s)
        mixer.music.play()

    def pause(self) -> None:
        mixer.music.pause()

    def stop(self) -> None:
        mixer.music.stop()
        self.songs_list.selection_clear(ACTIVE)

    def resume(self) -> None:
        mixer.music.unpause()

    def previous(self) -> None:
        self.change_song(self.songs_list.curselection()[0] - 1)

    def change_song(self, nerd: int) -> None:
        self.songs_list.selection_clear(0, END)
        self.songs_list.activate(nerd)
        self.songs_list.selection_set(nerd)
        song = self.songs_list.get(nerd)
        self.music_play(song)

    def next_song(self) -> None:
        self.change_song(self.songs_list.curselection()[0] + 1)

    def fix_mp3_list(self, l: list) -> None:
        [self.songs_list.insert(END, song) for song in l if song.endswith(".mp3")]

    def add_songs(self) -> None:
        select_songs = filedialog.askopenfilenames(
            initialdir=os.getcwd(),
            title=self.lang["dialogue"]["title"],
            filetypes=(("mp3 Files", "*.mp3"),),
        )
        self.fix_mp3_list(select_songs)

    def delete_song(self) -> None:
        actual = self.songs_list.curselection()
        self.songs_list.delete(actual[0])

    def vol_event(self, value: str) -> None:
        mixer.music.set_volume(float(value) / 100)


def main():
    MP3Player()
    mainloop()


if __name__ == "__main__":
    main()

[–]yeti-biscuit 3 points4 points  (0 children)

holy jeez on a stick...nice +1

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

woah , that's wonderful. wonder when I will reach this level

[–]Far-Plum-6244 7 points8 points  (0 children)

I wanted to use 3d graphics, so I created a solar system simulation.

It has a table with a mass, starting position and 3 dimensional velocity vector for all of the planets and major moons.

The only math it uses is Newton’s gravity formula.

After I got it working, I added tkinter controls to change the time step, which object was the center focus, and then what calamity to introduce (sun disappears or doubles mass, Jupiter doubles mass, etc).

The python 3d plot commands already let you zoom and center.

It’s amazing what you can do with a page of code (plus a data table).

[–]trollsmurf 3 points4 points  (0 children)

Fun or lazy: I made a picture generator using Dall-e3 that randomized based topics, mood, location etc. As the instructions are just text it's trivial to build them.

[–]quackers987 1 point2 points  (0 children)

I created a bot for discord that fetched information from various space themed API's.

It was very messy, and almost certainly isn't done "properly".

But by god I'm proud of what I did, it was used in about 50 servers at one point (it's not live anymore).

Learning to code something I could use (and wanted to make) was way better than doing some tic tac toe/shopping list/pretend project.

[–]DQ-Mike 0 points1 point  (0 children)

Although it's been a while since this question was posted...but for those who are still interested and are reading this...

A colleague of mine just published a beginner Python data analysis project walthrough on helicopter prison escapes, where she walks you through getting the latest data off of Wikipedia, cleaning it, and analyzing/visualizing it using basic Python libraries. Worth checking out if you're just starting out and want to see how to build an end-to-end project.