Survey

--Originally published at Python

encuesta

I was completely honest when I answered this survey. In most cases I gave my teachers good grades because I understand where they’re coming from. Just like Ken, I completely disagree with the methods being used for the grading system, but I can’t blame my teachers for that. Some of them are trying to make the best out of it without breaking the rules, I’m sure that most of them would use a very different grading method if they could. That’s why my opinion was independent from the system they are using, and it focused more on what they can do with all its limitations.


John the Ripper

--Originally published at Python

I’ve been asking Ken about this program named “John the Ripper”. What it does is it helps you crack passwords. It might sound easy and simple if I put it that way so let me get more into detail. Whenever you have a user and an account, these pieces of information are stored somewhere. Sometimes you’re able to see the accounts or the usernames, but you never get to see the password. And even if you did, you would always find these encrypted. So if you ever get the encrypted password, John the Ripper sort of “guesses” the password by using algorithms and combinations until it finds one that matches the encryption. This can take a very long time to be done. More than one day in most cases if not all.

Now that I have explained a little bit more about it, you should understand that it isn’t as simple as it sounds. It’s time consuming even after you have gotten the encrypted password, and usually getting it is even more difficult than cracking it. I still want to learn more about the subject so I will keep on researching and understanding better how this program works.

john

Image taken from: http://www.kitploit.com/2013/06/john-ripper-v180-fast-password-cracker.html


Servers

--Originally published at Python

This week I went to Ken’s office to talk and get an explanation on servers. I had an idea of what I could use them for and how, but after his explanation, I now understand why they are so good and how much they can benefit all of us. Turns out the Tec can provide us servers to run and test programs. All we need to do is go with Ken to get it set up.

You might be wondering, what would I want a server? What will it help me for if I can do everything in my computer with no problem? Well, this server is for heavier use. You might not need it right now, but eventually you might want to consider setting one up. When we get to more advanced semesters, we will need to run programs that will take a very long time. Some might even take one complete day or even more. So instead of walking throughout the entire campus with your computer open so that the process isn’t interrupted, you could run the program in the server. This will make life so much easier since you can exit, close your computer, etc. and the program will keep running until it’s done. Once it’s done you can enter the server once again and you will have your results. I highly encourage you to investigate more on this. Maybe not now, but eventually you will need this if you want to avoid some of the stress that the Tec will happily provide to us.

This video might help you get a better understanding on how these servers work


Technical Difficulties

--Originally published at Python

This blog is just about technical difficulties you might encounter while programming. I’m not gonna name or label them, I’m just going to  talk about the topic.

If you plan to program, then you must know that you will have a lot of errors, mistakes, however you want to call them. This is something natural and the only way to stop getting these errors is by practicing. With time, you will become better at what you are doing and you will stop making the same mistakes as before. But these mistakes aren’t bad. In fact, they’re what help you learn the most. Whenever you do something wrong, you feel frustrated, maybe even angry. You research, ask others, do everything possible to fix these errors. After you finally solve the problem, something stays in your head. You never want to do the same mistake again because you know how tedious it is to solve it. In case you make the same mistake again, well at least now you have a better idea on how to solve it.

Making mistakes is natural and good for you. Don’t try to make every program perfect, there’s always room for improvement. This is something you need to understand before you become a good programmer. Technical difficulties aren’t necessarily bad? Speaking of which…


Recursion

--Originally published at Python

Recursion is when you call a function inside of itself. It can be used in several ways, for example, you could create a function that will give you a final result after repeating itself several times, or it could give you several answers, depending on how many times it went through itself. The most common and probably the easiest example to understand on this subject is when writing a program that gives you the factorial of a number.

Code:

num = int(input(“Type a number: “))

def Factorial(num):
if num<=1:
return 1

else:
return num*Factorial(num-1)

print(Factorial(num))

2recursion

If the number is 1 or 0, the function won’t call itself, it will just return 1. If the number is bigger, then the recursion begins. Every time it goes through the else, it multiplies n by the answer to factorial n-1. This answer will depend on the number you get in the new factorial, and it will keep on decreasing until you get to 1, which is when all the previous numbers will start multiplying. These answer will stack up until the program gets to the first time the function was called, and it will return the final answer. It might be confusing at times, but ultimately, it follows this idea.


Validated user input

--Originally published at Python

When writing a user influenced program you need to ensure that the user does what he is expected to. Usually you want the user to type a certain type of variable, and there’s times when the user will type in something else. You need to validate the user input, otherwise, the program will crash and it won’t work. The simplest way I could find to do this is by using a While Loop using “try” and “except”. Here’s some code that you can use as a guide.

Code:

while True:
try:
age = int(input(“Please enter your age in years: “))

except ValueError:
print(“Only numbers please”)

else:
break

print(“Thanks for the info”)

2validating

The program enters a while loop and asks for an input. When the input is given, the program will check for exceptions, the exception here being when there’s a value error. This means that when someone inputs something that isn’t an integer, the program will enter the exception part which tells the user to type numbers only. Then it will continue looping until an integer is given. Once it is, the program will move on to the else, in case no exception was made. This else has a break which will end the loop, and after that, the processes outside the loop are done, and the program ends.


Importing and using modules/libraries

--Originally published at Python

Importing helps you use libraries or modules already available in Python 3. This means you don’t have to create functions from scratch, instead you can use the ones that already exist to save time and effort. There are a lot of libraries you can import, each has specific functions, in this blog, I will only focus in the import Math.

Code:

import math

print(math.fabs(-8))
print(math.ceil(1.1))
print(math.factorial(4))

2import

As you can see, the first thing you need to do is import the module/library, then you have to call it with a variable. For example, I used “math.fabs” which returns the absolute value of a number. So as a variable I used -8 and the program returned 8. There are 2 more examples below, but there are way more libraries you could use. If you want to learn more about them, check this link. It has all the functions you can use, as well as other modules/libraries.


Nesting Conditional Statements

--Originally published at Python

Nesting conditional statements refers to the process of writing a conditional statement inside of another. For example, if we were to use “if” we could write another “if” inside of it but with a more specific condition. It’s like having several filters in order to see which condition is true. And depending on that condition, a specific process will be done. Here’s an example:

Code:

num = int(input(“Type a number: “))

if num<=0:
if num<=-10:
if num<-100:
print(“Your number is smaller than -100”)
else:
print(“Your number is between -10 and -100”)
else:
print(“Your number is between 0 and -10”)
else:
print(“Your number is bigger than 0”)

2nesting

 


Basic Types

--Originally published at Python

Basic types in Python 3 refers to most common variables that are used to program. These are known as numbers, string (words), List (group of variables), Tuple (similar), and Dictionary (again, very similar to the lists). Here’s a picture showing every basic type in use:

Code:

num = int(5)
print(“Number: “, num)

word = str(‘Hello’)
print(“String: “, word)

list1 = [‘Dog’, ‘Cat’, 9, 15]
print(“List: “, list1)

tuple1 = (‘Cat’, ‘Dog’, 15, 9)
print(“Tuple: “, tuple1)

dict = {‘Animal’ : ‘Dog’, ‘Age’ : 5, ‘Breed’ : ‘Pug’, ‘Name’ : ‘Bono’}
print(“dict[Animal]: ” , dict[‘Animal’])
print(“dic[Name]: ” , dict[‘Name’])

2basic

It may be hard to understand the difference between List, Tuple, and Dictionary by just looking at the program. List stores different types of variables that can be modified later on. Tuple does the same but can’t be changed. Finally, the variables in a Dictionary are accessed through keywords, not the position of the variable itself. Well that’s pretty much it for the basic types, hope you understood.


Zen of Python

--Originally published at Python

2zen

I’ve been looking more into the Zen of Python and what it actually says. First I disregarded it because I knew most of the things it talks about, but the I thought “What about people who are just starting?” Of course they won’t know how to guide themselves through the world of programming. So I decided to talk about the points that I believe are the most important in the Zen of Python.

The first one being “simple is better than complex”. It is important to understand this point because there are times when people try to do a super complex programs when in reality, it can be simplified into something everyone can understand. Making something complex will only bring you trouble in the future. If something goes wrong, then you will have to go through your complex program, understand the problem, why it is there, and then come up with a solution. Keeping things simple makes your life way easier.

Next is “Readability counts”. It is important that your code is readable. This point is similar to the last one, but a little more general. You want your code to be readable so that you can understand it, as well as others. If it is hard to understand, then you won’t be able to figure out your problem as easy as you could if it was. Also, if you ever show this code to others, they will be just as confused as you because they won’t understand anything.

Finally, I just want to talk about the point stating “Now is better than never.” Everyone that is starting to program has to take this one into account. Leaving everything for later won’t help you at all. If you want to be good at programming, you need to start

Continue reading "Zen of Python"