Chapter unknown

--Originally published at Programming Blog

Day 3:
Good way to start this blog, not by the very beginning but by the part where i needed something to corroborate with random people (or just none, reading this). In this blog I will only write about my issues with anything inside my life, for example: My ex right now, she drives me crazy, we spoke 2 days ago and i don’t know how should I take that talking (I was the one to take the chance and talk face to face), i still have feeling for her, and I don’t really know if she has feelings for me, I know I should go looking for an answer, but right now I don’t have the guts to do it, by the simple decision that i’m still not ready to accept a no, maybe it’s just me pressuring stuff, but I’m really liking this part, where I have no clue what she is thinking and speak by anything and just have a normal conversation like we used to have when we were a couple, we lasted over a year.
Most of my friends have told me to move on, and i believe i did move on, i learned my mistakes and learn to really appreciate what she was doing for me unconsiously, but thats because my lame past have tormented me with this, the reason of breaking up  i don’t have it, i guess we just made it toxic and start to push ourself to the crazy part, me ignoring her, she ignoring me (both feeling like crap), and in the end we just couldn’t, maybe I will let this part for other ocasion, but for now this is day 3. Although I’m not really sure if i will type every day, only every day meaningful worthy of typing, Continue reading "Chapter unknown"

Road To Masterball! (4/4)

--Originally published at Programming Blog

This is the last road to our adventure, i hope everyone liked it, please remember to thank Ken for having this type of course.

The only little problem with our road is.. Red!, (for the ones that don’t know is the person that is after the elite 4 in the games that is stronger than the elite)

So our mission for defeating Red and actually getting the Masterball (Screw you, Red) is the creation and use of ranges in Python and the creation and use of dictionaries.

So our last 2 starts now!

Ranges in Python

http://pythoncentral.io/pythons-range-function-explained/

It starts with the function Range() that generates a list of random numbers, but it must be integers, and parameters can be positive or negative

and it has different entrances for the typing.

Start: Starting number of the sequence (LUL)

Stop: Generate numbers up to, but not include this number

Step: Difference between each number in the sequence.

 ranges

And for extra information you can get more by this video

http://interactivepython.org/courselib/static/thinkcspy/PythonTurtle/TherangeFunction.html

Last but not least

Creation and use of dictionaries in Python

First the syntaxis

{} The braces that contains the dictionary

: The colon separates the key from the value of the key

“A” This is the key, it holds the value next to it

A very important way to organize the values can be with dictionaries, since each element it’s a key with it’s respective value. An example would be the alphabet, and the dictionary starts to get useful the moment that you need a variable for each element of the list.

alphabet = {“A”:0,”B”:0,”C”:0,”D”:0…}

 

And an important function that we need to know is .keys(), this only returns the values as a list, so we can check the key of a value before calling it

Continue reading "Road To Masterball! (4/4)"

Road to Masterball (3/4)

--Originally published at Programming Blog

Since there is missing several topics to myself the 4th part will be postponed but DON’T WORRY! it will be done faster than you think

7!

  • Validated user input (ensure correct/expected data entry)

Just as the topic says, you gotta make sure that what the input that any person is giving to you is the one that you code into, for example: enter your age, and if you put three it shows you that’s not a number, type a number, that means it requires you to type an integer.

And the way that i did it is with, errors and exceptions, that means using while True, you know what? it’s better to see the explanation of the documentation (link) and my code

validation

I think the documentation is really nice written but if you still have problems with it or don’t understand this guy really know’s how to explain it (starts at1:52) https://www.youtube.com/watch?v=nqGhjLUhyDc

http://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response

https://docs.python.org/3/tutorial/errors.html#handling-exceptions

 

8!

 

  • Reading and writing of text files

 

In Python you have it really simple, first, you don’t need to import any libraries to read text files (yei) but you need to get a file object and the way to do this is with the open function, to read a text file is rather easy and it’s only with a simple file.read() function, also you can decide if you want the whole text or several characters and it would be inside the file.read(x), being x this time

And for writing inside it will be with the function file.write (“text”).

Tip! after you are done calling the text file you gotta close it to free memory with the function call f.close().

reading

my code won’t work since i don’t have a text file to use

Continue reading "Road to Masterball (3/4)"

Road to Masterball (2/4 or 1/2)!

--Originally published at Programming Blog

Check the 1st part to know why the name!

3!

 

  • When to use what type of repetition in a program

 

There’s a trick for what type of repetition you need in a program and it’s the following

For (loop)

You have a small part of your code that you want to repeat “x” number of times.

While (loop)

Keeps running the code until the condition is met, basically it has code and inside a condition.

Nested (loops)

Loop inside a loop

Break (not a loop but a helper)

To be free from a loop, you use the function “Break”.

Continue (not a loop, but to enter one)

Basically is to skip the rest of the statements in the current loop and to continue to the next part of the code (but can be used to enter another loop if you have a loop inside another loop).

http://www.pythonforbeginners.com/loops/for-while-and-nested-loops-in-python

meme-24

4!

 

  • Creation and use of Lists/Tuples (Python) or Arrays/Vectors (C++)

 

tuples

The creation of lists and tuples in python are rather easy and there is just a little difference in how to type it.

A tuple is written with parentheses, but you gotta name the list, and you can’t alter the data inside.

While a list, is written with square brackets and list their elements, and the difference is that you can actually alter the data inside.

if you require more information about this topic you can see a video about both topics.

https://www.youtube.com/watch?v=RVXIBZvg-W8

5!

Creation and use of strings

Strings are the most popular types in Python, we can create them simply by enclosing characters in quotes (‘’) python treats single quotes the same as double quotes, and the fast way to know what is creating string is coding (LUL)strings

so.. well that’s basically

Continue reading "Road to Masterball (2/4 or 1/2)!"

Road to Masterball (1/4)

--Originally published at Programming Blog

Many of you might think, why Masterball? but in every game to get to the Masterball you need to learn the history of that region of Pokemon, and when you get the Masterball you are almost finishing the game (or in this blog, the class)

Anyway 1st!

 

  • Nesting of conditional statements

 

There may be a situation where you need double conditions to apply an action, and for this you can use the nested If construct, in a nested if construct, you can have an if/elif/else construct inside another if/elif/else construct

nesting

this is a graphic example of a nested conditional, and for coding it will be the same one if and inside another one for a more specific answer for example, giving a more precise answer or statement.

elif-code

nesting-conditionals

For more information about how to do it, and that’s how we learned was with this video, https://www.youtube.com/watch?v=8lR9JU-7bZA a rather easy to explain video that actually starts coding in 1:26.

https://www.tutorialspoint.com/python/nested_if_statements_in_python.htm

 

 

2!

 

  • Use of recursion for repetitive algorithms

 

First of all to know this topic we need to know what is recursion, and that is a method of programming or coding a problem, in which a function calls itself one or more times in its body. Usually, it is returning the return value of this function call, if a function definition satisfies the condition of recursion, we call this function a recursive function.

But what does the recursive function?

Well first it has to fullfil an important condition to be used in a program: it has to terminate, a recursive function terminates, but can end up in an infinite loop if the base case is not met in the calls.

This might look difficult but on code it’s rather easy and

factorial
fibonacci
part1.png
Continue reading "Road to Masterball (1/4)"