It’s not a ‘Goodbye’

--Originally published at Nihilistic Kirby

Imagine that you enter in this new room full of people you didn’t knew on your past, with this weird teacher who speaks English and Spanish, and doesn’t “grade” the students.

For me, the firsts thoughts about Ken and his class were “Oh, I don’t think I will learn a thing this way” or “wtf, I need a teacher that teaches me”. The point is, that Ken taught us more than a regular teacher could, he was preparing future programmers to THINK, to HELP others, and to ASK for help too. As we live in this planet full of competitions on every corner, why is it good to be rivals when we can become teammates?

I’m not the most talkative persona in the world, I know; however, there’s always the possibility to make a change at any point of our lives and say “It’s OK to fail”, because it’s true, that’s why everyone says it ‘you need to fail in order to learn’, and ‘you need to learn in order to teach’, ‘or not (?’.

Ken taught us what we needed, and even if this journey ends here, it doesn’t mean that I can’t go back to ask Ken for help, I think he’s became a friend for each one of his students, he’s not afraid to fail, he’s always open in order to think and to do new things, even if the people says he will fail.

If you wan’t to think like a robot, go and study with any teacher, or even internet. If you want to think like a programmer (a good one), try everything that’s possible, even the things you’re afraid of.


How I ended up being a teacher

--Originally published at Nihilistic Kirby

Not exactly, I’m “teaching” my cousin that came from the USA. He and I wanted to be programmers since middle school, and we tried our best to learn code; however, things didn’t work out that well, and we got taken apart from each other at the beginning of high school. But now that he’s part of my life again, he asked me for help in order to have a better understanding on coding, specially on python, this wonderful but “easy” tool that every programmer should know as any other working language with good reputation such as C++, Java, etc.

The point is…. that Ken constantly ask us to help other students, as a part of our own study, because we can learn a lot by helping others, and if I was teaching someone who didn’t even know this language, that help me a lot actually. Now I feel like a teacher (a good one) every time he ask me for help, I don’t feel better, not even close to that, but he helps me as much as I can help him.

He’s gonna be part of the crew next semester, and we’re gonna have a lot of time to program and to create things as the perfect team we used to be once in the past. I really hope we (and other people) can help each other to be almost masters on every language and every problem solving algorithms creator this world can know.

 


DRAE or Oxford? Mine (‘Dictionaries’ for those who didn’t get it)

--Originally published at Nihilistic Kirby

For this project I wanted to make something a little bit different as I got inspired with cryptology, as some people may know I kinda know Japanese, and I wanted to create a “translator” for the vowels A I U E O  respectively in:

ア イ ウ エ オ 

My dictionary for katakana, in order to write names (difficult but trying to figure out) is just a future project; however, I already have the first step done, which, as I said, is the representation of each vowel in katakana.

vowels = {‘a’,’i’,’u’,’e’,’o’}
katakana_vowels = {‘a’:’ア’,’i’:’イ’,’u’:’ウ’,’e’:’エ’,’o’:’オ’}

def converter(vowel):
return katakana_vowels[vowel]

print(converter(‘e’))

As you can see, the dictionary works with list of values surrounded by “{}”, and divided by  commas. The wonder of this code is that for each value that exists in the list ‘vowels’, there will be another value that will replace that exact value with another one, which is the katakana.

Is not difficult to understand, think it like if it was a tuple, where there are values that cannot be modified , and each one has another one of itself from another universe.


Physics final project

--Originally published at Nihilistic Kirby

Two weeks ago I made a post about ranges in which I included a piece of code, that was a part of my final project (for Physics class).

Although Ken helped me a lot with the use of tuples on it, the code stopped working for some mysterious reason (people tell me that’s normal) and I had only two options: start again from the beginning, or try to find a solution. Obviously the second option wasn’t the best one for my; however, I tried so just in case I could became any better, and I did.

It wasn’t much of a change, but in the end my constant tries and checking some information on Stack Overflow, I got to an easy solution that worked very well, even today when codes can smell fear and break themselves for no reason.

Well, but that’s a lot of writing, lets move to the fun part, the code:

https://github.com/NihilisticKirby/finalpartialphysics (check the repository plz)

finalcode

I worked really hard on this code, and I want to say THANKS to Ken, as he helped me a lot to understand what I wanted to create.

 


Power ‘Ranges’

--Originally published at Nihilistic Kirby

Ranges are very easy to understand, you can use ranges to print the word “meow” for each int value you give, you can use it to repeat some function in order to make some kind of sum, you just need to THINK OUT OF THE BOX, the same as any other python tool, things can seem to be pretty simple, but even the simpler things can become complicated as hell and create wonderful thousands of lines of code.

For example, in this code (that I got  hell lot of help by Ken with), in which I tried to repeat a function, check it out:

for n in range(0,sd):
forces = force()
sum_forces[0] += forces[0]
sum_forces[1] += forces[1]

This loop works with a range “sd” that is defined as the number I want to repeat the process, and the variable assigned to the function “force()” makes it easier to execute, as every time the function generates values, they will be sum into a unique variable for each value or result (hope you can understand that).


Text files involving Python

--Originally published at Nihilistic Kirby

Did you ever wanted to know if any other forms of files interact with you python code?

Have you ever wanted to use a text file as some kind of dictionary?

Well, don’t worry any longer, because I’ve got the answer you’re looking for. First of all, python codes works with really simple commands, making this one of the most easiest but practical languages to work with. So you might be surprised if I tell you that the simple command of “>>>open()” including the name of the archive between apostrophes.

This will make every line of text a list that you can manipulate with ranges. There’s an example for it in which I opened a text file full of values as number:

cartxt = open(“93cars.dat.txt”)
for line in cartxt:
a = line[52:54]
b = line[55:57]
c = line[42:46]


How to make quick posts (NOT cheating)

--Originally published at Nihilistic Kirby

DID YOU KNOW? You can queue your posts and make they look like daily posts.

Is not like if I invented the wheel, but is a cool idea if you want to make all 8 posts of a partial in just one day and want to make it look like they were created daily.

Just click the right part of the button “Publish”, the one that has a calendar, and define a date and a time. (I think that works as a function)

Funfact: This post was created days before the day it was posted.


A better look on functions. How do they work and when can you use them

--Originally published at Nihilistic Kirby

The first time I was coding I totally felt like a pro; however, everything changed when Ken told me I was kind of a mess, because I wrote too much and nothing had order. Then he explained to me one of the best things that can be done in a program, A FUNCTION. Yes, a function, this little (or larger) thing can do wonderful things for you when you’re coding and need to repeat some algorithm many times. You can also write something really cool that someone else can use inside its code.

When you create a function, it must start with a “>>>def …():” (short for define), this indicates that the whole stuff under that command will be a part of that function and not part of the main code, which can include a lot of variables without affecting the functionality of the whole code. One you define a cool name for you function, you must write something that will be done with respect of some variable (or not). I constantly use functions inside python codes when I feel like an artist and want to create cool patterns using slashes and stuff, that a good idea, instead of printing a lot of lines.

This is a basic example for a function that states 4 variables inside of it that can be changed inside of it by the user of the function, when the function is being called:

def sumsub(a, b, c=0, d=0):
    return a - b + c - d

print(sumsub(12,4))
print(sumsub(42,15,d=10))

How not to crash the system. ONLY numbers.

--Originally published at Nihilistic Kirby

First read my code, then I’ll explain

only

It is as easy as only placing a “while True:” loop in order to save the system to break and crash and mutate every living form on Earth into stellar dust from another dimension.

What this loop does is that prevents the code for failing for some sort of input that is not valid, as you can see, I was only asking for an “int”, that’s why I use the function to change the input, but if the user is too dumb and tries to write using letter, everything will be ruined. At first I didn’t think it was going to be too easy, but it was such an easy topic that I was eating some cake at the time I wrote it (cheese cake).

Resultado de imagen para cheesecake

Funfact: You can use the same method for strings, floats, just let your imagination fly and you’ll be able to do amazing things.


A better explanation on CONDITIONALS

--Originally published at Nihilistic Kirby

The “>>>if” conditional is the easiest one, it just focuses on creating an event ‘if’ some specific event takes place before.

food = 'spam'

if food == 'spam':
    print('Ummmm, my favorite!')
    print('I feel like saying it 100 times...')
    print(100 * (food + '! '))

The “>>>elif” is a combination of the commands “else” and “if”, which works exactly just like the “if”, but this one is closely related to the initial conditional; however, this type of conditional is more relevant in loops that can break, such as “while” loops.

if x < y:
    STATEMENTS_A
else:
    if x > y:
        STATEMENTS_B
    else:
        STATEMENTS_C

The “>>>else” is not exactly a conditional, as it only works for all the events that could happen if the first event is not correct or what it is expected to be.

if choice == 'a':
    print("You chose 'a'.")
elif choice == 'b':
    print("You chose 'b'.")
elif choice == 'c':
    print("You chose 'c'.")
else:
    print("Invalid choice.")

Is important to know that the “if” can be all by its own and will still work, but the other two need to have an “if” that can lead them.