Author Archives: Gilberto Rogel García

#mastery18 Nesting of conditional statements

Sometimes when you are programming you want to check another condition  if the first condition you made is true.

This is a lazy example i did to show how to nest conditionals:

This program just compares the number that the user gives to the numer 10.

 

 

#mastery14 Creating and using a Python module

To create a python module you first have to create a new python program (in this case masteries.py) which contains functions (in this case hw() and gb())

Then, in order to use the module’s functions in another program you use import (name of the program)

After you have imported your module you can now use it’s functions by writing the name of the module (masteries) followed by a point and the name of the function inside that module (.hw() or .gb()) 

This will show the user:

Hello World (for hw())   and

Good bye (for gb()) (as shown in the picture above)

#mastery06 Install Linux on their own computer

To install Linux on my computer i followed the instructions shown in this website: Linux 

I used this website because it clearly explains how to do it.

#mastery04 Submit work via Blog RSS and GitHub

This is an example of a work submission via blog RSS (Any post on this site is an example)

To submit a work via withknown blog:

1-Sign up to withknown and log in.

2-Click Post.

3- Add a title and whatever you want to include in your blogpost.

4-Click Publish.

;D

This is a work submission via Github:  https://gist.github.com/gilrg18/f9f5a9fe4b1842fcda3c

To submit a work in github:

1-Go to https://gist.github.com/ ,sign up and log in.

2-Write a gist description and a name for the file.

3-Copy and paste your code into the blank space.

4-Click the button that says Create public Gist in the down right corner.

😀

#mastery02

This shows how to run Python programs in the python IDLE directly from Notepad++

First you have to click Run->Run

Then you have to write this in the blank space C:Python34Libidlelibidle.py “$(FULL_CURRENT_PATH)” .This will run the current program in which you are working on.

 

This will show up after you click Run.

 

Now in order to run and test your program you have to click Run->Run Module

Final result.

#TC1014 #WSQ10 Lists

This program shows the user the total, average and standard deviation of the numbers that he/she provided in a list. 

I didn’t know how to do the standard deviation part so i had to look at someone else’s code (Venkon Programming)

Click here to see my code

#WSQ09 Factorial Calculator #TC1014

In this wsq i had to create a function that gets the factorial of a number that the user gives you. After that i made a while with two other whiles inside of it so the program can work as it should.

Link for my code:

https://gist.github.com/gilrg18/f9f5a9fe4b1842fcda3c

#mastery17 Use of “elif” with a conditional

This is similar to an “else” but instead of doing something if the first condition is not fulfiled, this will make another condition in case the first one isnt fulfiled. For example:

num=2

if (num>3):

print (“Hello”) #  wont print this because the condition is not fulfiled (false)… this line must be idented so it can be part of the “if”

elif (num==2):

print (“Goodbye”) # the condition wasnt fulfiled the “elif” will take place and it’ll print Goodbye… this line must be idented so it can be part of the “elif”

#mastery16 Use of “else” with a conditional

This is the alternate ending to an if function. If the condition is not fulfiled you put an “else” and it will do what is inside of that “else” for example:

num=2

if (num>3):

print(“hello”) wont print this because the condition is not fulfiled (false)… this line must be idented so it can be part of the “if”

else :

print (“goodbye”) the condition wasnt fulfiled the “else” will take place and it’ll print goodbye… this line must be idented so it can be part of the “else”

This program will show the user:

goodbye

 

#mastery15 Use of the conditional “if”

What the “if” does is that if a condition is fulfiled it will do what it is inside of it.

An example of this is

num=1+1

if (num>3):

print (“Hello”) must be idented so it can be part of the if

This program wont print anything because the condition num>3 is not fulfiled , in order for it to print something it must be num<3 or num=2 because num equals 2

num=1+1

if (num<3):

print(“Hello”) must be idented so it can be part of the if

This program will show the user:

Hello the condition is now fulfiled (2<3)