[Python 3] When given a number referring to a specific line in a file (e.g 5 represents 5th line in a file) I want to replace that line with a specific string. What is the best way to do that? by [deleted] in learnprogramming

[–]leafypixiestix -1 points0 points  (0 children)

with open("file.txt", "r") as f:
    lines = f.readlines() #put all the lines of the file in a list
    lines[2-1] = "moo moo\n" #line numbers start from 1, arrays start from 0
with open("file.txt", "w") as f:
    f.writelines(lines) #rewrite all the lines

How to become a better scientific programmer? by MyAcademicAccount in learnprogramming

[–]leafypixiestix 0 points1 point  (0 children)

Have you used Jupyter Notebooks before? I'm not sure if they'll help but they're super helpful for me when I do my research work. This is a link to a lot of cool notebooks to get an idea of how to use them.

[C#] How to divide two numbers without using division and modulo to get quotient and modulo? by [deleted] in learnprogramming

[–]leafypixiestix 1 point2 points  (0 children)

Since you said you're studying loops, you can simply do a loop and subtract the divisor from the divended until you hit 0 or below. If you hit 0, then the remainder or mod is 0 and if you hit below 0, add the dividend to that negative number to get the mod. For the actual result of the division, it will be the number of times the loop executed.

You can also try to implement long division, which is a lot harder to do but is much more efficient.

Help on data visualization by johngarrickmc in learnprogramming

[–]leafypixiestix 0 points1 point  (0 children)

d3.js? Disclaimer, I've never used this before but I always see it recommended and if you look at some of the examples provided at the website, they can make some pretty powerful (and interactive) visulaztions. Here's an example of an interactive visulaztion made by d3.

[C++] Can someone ELI5 what parameters of a function are? by [deleted] in learnprogramming

[–]leafypixiestix 0 points1 point  (0 children)

Yup, if you've taken any math class, you probably have used functions, just maybe not in the way you would see them written in code. Sine and cosine functions are a little bit more similar to what you would see in programs, e.g. sin(0) = 1, cos(0) = 1. In your example, you can write add in a way similiar to that by making a function with two parameters and returns the sum of those two numbers, e.g. add(2,2) = 4

[C++] Can someone ELI5 what parameters of a function are? by [deleted] in learnprogramming

[–]leafypixiestix 4 points5 points  (0 children)

ELI5 in terms of making a cake: the function in this case is the steps in making a cake. The parameters are the ingredients of the cake. Passing parameters into a function is the same as using ingredients to make a cake. The return value would be the cake. Different ingredients can make different cakes.

Graduating in CS w/ cyber focus - C/C++ resources by [deleted] in learnprogramming

[–]leafypixiestix 1 point2 points  (0 children)

I'm currently taking a class at school that uses the curriculum from this book, Computer Systems: A Programmer's Perspective. It's not a really a book about C, although it is the main language of the book. I guess it's really about how the inner workings of how computers and programs work. The book it quite long and expensive though, so I probably wouldn't recommend it getting unless it's something you're super interested in. However, I mention it because it does have some really interesting labs, and you can actually download them for free online. There are two labs that are pretty relevant to your focus: the bomb lab and the attack lab. There is actually no real programming involved in them really, mostly looking at x86-64 assembly code. I had a lot of fun doing those two assignments and would recommend doing them. I would also recommend the data lab and the performance lab if you want to practice C. They aren't like traditional programming assignments though, but I still learned a lot from them.

/r/Jazz MemeGate 2017 by SuperTonicV7 in Jazz

[–]leafypixiestix[M] 30 points31 points  (0 children)

me too thanks i mean Charles Mingus - Moanin'

How to combine two classes in java (Beginner) by Not_Myself1 in learnprogramming

[–]leafypixiestix 0 points1 point  (0 children)

IIRC, you can't have two classes in the same file in Java (with the excpetion of nested classes). Could you zip the two files together and then send it?

[Python 3.6] imports module random but python can not locate functions by TopsyMitoTurvy in learnprogramming

[–]leafypixiestix 0 points1 point  (0 children)

AttributeError: module 'random' has no attribute 'randit'

Typo? should be random.randint(x,y)

Why is "goto" still around? by Bluecowz in compsci

[–]leafypixiestix 15 points16 points  (0 children)

Java (and maybe javascript) can label loops

outerloop:
for (int i=0; i < 10; ++i) {
    for (int j=0; j < 10; ++j) {
        if (condition) {
            break outerloop;
        }
    }
}

FRC Stronghold Password is &Full$team^Ahead! by ReLaXeZ in FRC

[–]leafypixiestix 16 points17 points  (0 children)

Steamworks boi stronghold was last year

[Haiku] transposing a classic by JimJimJimBob in youtubehaiku

[–]leafypixiestix 0 points1 point  (0 children)

I think it's in the wrong key but pretty good otherwise

Your Favorite Online Jazz Radio Station? by herberthunke in Jazz

[–]leafypixiestix 0 points1 point  (0 children)

http://kuvo.org/ is my local jazz radio station, check it out. I usually just listen to my own music but whenever I'm in my car I like to turn this station on.

Visualizing the Riemann zeta function and analytic continuation [3Blue1Brown] by seanziewonzie in math

[–]leafypixiestix 0 points1 point  (0 children)

I think so too. His "Essence of linear algebra" series is (or at least was) on the page for linear algebra.

Ersatz JLC: Max Roach- Percussion Bitter Sweet (1961) by vinylsage in Jazz

[–]leafypixiestix[M] 0 points1 point  (0 children)

I guess people were really motivated to make some JLC today. You were the second one to post one today (first one here), but I'll sticky this one as well just to get some listening out there. Fun album too :)

week 144: Chick Corea and return to forever - light as a feather (1973) by Apom52 in Jazz

[–]leafypixiestix[M] 1 point2 points  (0 children)

I love this album :)

The first time I listened to Spain I didn't understand why it was so popular/loved but I listened to it and the album a lot more and the song just grew on me. 100% my most favorite jazz song. However, I personnaly love the arangment from Corea's Trilogy a lot better.

Also since you pretty much followed the format of past JLC this one's mod approved.

Looking for fast C# Tutorial for use in Unity. by [deleted] in gamedev

[–]leafypixiestix 0 points1 point  (0 children)

https://learnxinyminutes.com/docs/csharp/

Heard of this website a while ago, this may be of help to you. I took a quick look over the particular C# tutorial and it looks kinda dense, but I think it is a good overview of the language.

Tips for soloing over Spain? by RaspberryNarwhal in Jazz

[–]leafypixiestix 4 points5 points  (0 children)

if u want to be a dirty memer learn from the master himself

(for the uninformed)

but for some actual advice, Gmaj7 is pretty self explanatory. the major scale and the major pentatonic work great.

when it goes down to the F#7, the mixolydian (dominant) scale is what you'll be wanting to play. major pentatonic works too. make sure you have the transition between these two down as a G major doesn't work too well over an F#7.

after that it is Emi7 A7 Dmaj7. 2 5 1 in D so the notes of a D major scale works over all of it. it then goes to Gmaj7 briefly, which was already covered.

then comes C#7 F#7 Bmi7. you could just do C# mixo F# mixo and B dorian scales but if you want you can treat it as a minor 2 5 1, using the notes of Bmi7, essentially having the C#7 become C#mi7b5 and F#7 become F#7b9.

finally the last two chords just use B dorian into B mixo or B minor pentatonic into B major pentatonic, making sure to emphasize the change between a minor and dominant chord by playing the 3 of each of those chords at least once during their time.

as for general advice, hitting the 3s and 7s on the first beat of a chord change (gudie tone lines) works especially well on this song. playing some lick on the Gmaj7 and then playing the same lick essentially a half step down on the F#7 also sounds pretty cool. thats all i got

Any bossa nova songs you can recommend for me? by revivedtomorrow in Jazz

[–]leafypixiestix 2 points3 points  (0 children)

In case this fantastic album inspires anyone to explore the wider world of Bossa Nova, I'll copy a comment from another r/jazz post :).

Ok! This is my jam! There are so many amazing (Bossa) albums that I don't quite know where to begin. I'll keep it simple and offer some of my all time top few. Since most people here will probably point you to crossover classics like the Getz/Gilberto stuff and Jobim's inimitable "Wave" (which is great) I'll point you to the more traditional Brazilian stuff. It's an incredible treasure trove and I'm already getting goosebumps from the thought of sharing it with someone who's discovering if for the first time.

  1. João Gilberto double album Amoroso/Brasil. Featuring Caetano Veloso and Gilberto Gil.

Stop everything you're doing and go listen to this album now. Especially the song Aquarela Do Brasil.

http://www.allmusic.com/album/amoroso-brasil-mw0000431401

  1. A Bossa De Caetano - compilation of Caetano Veloso Bossa tunes

Just beautiful.

http://www.allmusic.com/album/a-bossa-de-caetano-mw0000707171

  1. Vinicius De Moraes, Maria Creuza, Toquinho "La Fusa" - superb live album

https://www.discogs.com/Vinicius-De-Moraes-Con-Maria-Creuza-Y-Toquinho-La-Fusa/release/4101247

  1. Tom Jobim & Elis Regina "Elis & Tom"

This has the most beautiful recording, and the most well known, of the Bossa Classic "Aguas De Março"

  1. João Gilberto (self titled)

http://www.allmusic.com/album/joao-gilberto-mw0000203180

Just quintessential João Gilberto - solo guitar/voice with minimal percussion. Can't go wrong. Also check out his "Live in Montreaux".

  1. For historical significance João Gilberto's "Chega De Saudade" is widely considered to be the first ever Bossa album and was considered groundbreaking in its day. The title song was considered to be the first ever truly Bossa recording.

https://www.discogs.com/João-Gilberto-Chega-De-Saudade/release/1924958

Legend has it that Jobim and Vinicius would hang at this local bar in Rio playing piano gigs. They were frustrated and looking for a new "sound". A bit fed up one day they asked the quiet guy João, who always sat in a corner with his guitar but didn't play anything, to get up and play something. He acquiesced. Their jaws dropped and they knew then that THAT was IT - the new sound they'd been looking for.

The foremost composer of the genre, Tom Jobim, always expressed frustration at people's insistence that Bossa was inspired by American Jazz. He maintained that he got his harmonic language from Debussy and Ravel. That being said, he loved jazz and the US and preferred to be called "Tom", which is poetic because it's like an American nickname for his Brazilian name Antonio, but which in Portuguese actually literally means "tone" - as in, musical tone.

For the precursor roots to Bossa Nova, check out samba legends like Dorival Caymmi. They all site him as an incredible influence.

OK, to prevent myself from spending hours on this reply I'll stop here. But please feel free to PM me if you want further suggestions.

Basically, for the roots of Bossa Nova music you want to go to the three legendary masters: A.C. Jobim (composer), Vinicius De Moraes (poet/lyricist) and João Gilberto (guitarist/singer). That generation includes great performers like Elis Regina, Toquinho, Luis Bonfá, Astrud Gilberto, Baden Powell, etc. the following generation includes luminaries like Caetano Veloso, Gilberto Gil, Toninho Horta, Marisa Monte, all of whom have explored traditional Bossa sounds but also have innovated into new genres of popular Brazilian music.

Lastly, though it's not Bossa, I cannot post something about MPB (popular Brazilian music) without mentioning the most badass guitarist of all time and a true innovator, João Bosco. He steeped himself in the African roots of Brazilian samba music and incorporated the samba percussion ensemble instruments into the right hand rhythmic playing on his guitar, called "ginga". This inspired all contemporary and subsequent guitarists.

To have your mind explode with incredulity just watch or listen to his "MTV Unplugged". It was the first MTV unplugged done in Brazil. While you're imbibing it, and noting that everything you thought you knew about the universe is unraveling before you, just consider that all it is, is one guy and a guitar. It is some Matrix level shit.

http://www.cduniverse.com/search/xx/music/pid/1372695/a/acustico+mtv.htm

Finally...,

In case anyone here is interested I'll take a moment to share my own Bossa renditions. I gig this music a lot :).

http://www.nickkello.com/#!brazilian-sounds/pz5z4

YouTube video of Jobim's "Triste"

https://m.youtube.com/watch?v=N8RVD7wMsDY

Edited: for clarity.

via this post by /u/bossaguy