DEV Community

ramirotorresl
ramirotorresl

Posted on

My first program

So here I am. I started three weeks ago a course on Computer Science by Codecademy. So far I've learnt some Python3 and some other -extra- basics.

And as a part of the course, I was asked to autonomously write a program about something I like. I needed to set up a GitHub repository and track the versions while coding. And the code needed to have classes (that would affect each other). So the idea that came into my mind was to create a database of different songs (that was one class), having among other variables, different parts (that was the other class). So for example, I created a song instance una_rosa_blanca.Song containing info about the song (author, name, optional link). And then I created a part instance riff_urb.Part containing the song it belongs to (una_rosa_blanca), the time of the song where that part starts, and of course, the notes (a list of them).

Actually the program only makes sense for me because I'm learning trumpet, and I find it quite hard to both transpose a trumpet piece I know, or to transfer a guitar piece I know to trumpet. This is because in trumpet the scale of notes are not like in guitar (I mean, just one fret higher or lower is 1/2 tone higher or lower). For example, a G in trumpet can be all three valves open, and then a G# is second and third valves closed. And then A is valves one and two closed. So no straightforward transposing. So, by creating a dictionary containing all the notes (three octaves) : their finger positions, I was able to then just access it and change the index as much as the part.transpose(quantity) required.

Other method was find_fingers that would give me the finger positions for a list of notes (that I could easily input from a guitar piece I already knew).

Anyway, I found it a nice experience to start coding, printing an excessive amount of variables at every piece of the code to understand wth was going on with it. It took me like two days, not because of its complexity, but because of my lack of experience coding.

[https://github.com/ramirotorresl/Band_database]

Top comments (1)

Collapse
 
williamlake profile image
William Lake

Hey- great work! I find the most productive method for learning to code is exactly this- finding a need in your life and meeting it through code. Good on you!

One thing you may find useful is a JSON file to store things like lista_de_notas. For example if you put all that dict data in a .json file named notas.json, you could shorten the first line to

import json

lista_de_notas = json.load(open('notas.json'))
Enter fullscreen mode Exit fullscreen mode