Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152
‘#45’ Articles at TC101 Fall 2015
Introduction to Programming Python and C++

Tag Archives: #45

Project

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

Hi, this is a blogpost about my I wanted to do this since a few days ago but I had no time, you know its finals and everything gets crazy. First I would like to start saying this was hell, way too difficult. I first had to search all over the internet for information. I had a lot of problems with using the library on mac so I did it in Ubuntu. Once I had it I couldn’t even compile the sample program, that is when I went with Ken and asked for some help, the thing was I had installed another thing I thought it was the library and that is why I could not compile anything. Once everything with magick++ was set up I started the coding process, we have the code know the thing is that, I don´t finish to understand why, but it only works with some images not with all of them. I don´t know if it is something with my code or the Ubuntu software or other thing. Here are some pictures of the process, I first published in github some separated codes that were the sample ones, but with some modifications.

I did this one with the same crop one

 This is the picture that my code lets me modify… I will post the final code later today.

It is in jpeg format. Other different images showed up some error i couldt figure out

 

I will post later tonight more about this and the final project see you…

#Mastery18 – Nesting of conditional statements

Hello this is of nesting statements. It is possible to nest if-else else statements; this means you can use this means using functions one inside another.

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

 

 How to write a nested statement?

 

For example, the syntax is the following…

If (expression 1) {

  If(expression 2) {

   }

}

 

You can also nest an else if… else in a similar way as you nested the if statement.

 

This type of statement allows a choice to be made between two alternatives. A choice must be made between more than two possibilities. For example, the sign function in mathematics returns a negative number if an argument is less than zero, returns a positive number if the argument is more than zero.

 

I took this chart from http://www.programiz.com/sites/tutorial2program/files/flowchart-if-programming_0.jpg

 

That explains a process for an if statement that also can be used nested.

 This program shows an example on how to use a nested statement and how it works.

WATCH MY VIDEO https://youtu.be/hT153pKWogI

 

 

#Mastery25 – Creation and use of strings in C++

 A string means an ordered sequence of characters, and in most programming languages such strings are enclosed in either single or double quotes.

 

In C++ the enclosing delimiters are double quotes. IFor example, the usual first C++ program displays the string literal “Hello, world!” on the screen with the following output statement.

 

Strings are objects that represent characters, it is actually a one-dimensional array of characters. It is kind of like the same way you declare an array but instead you use characters. Which is the structure of a string?

 

 

char name[number of elements] ={‘a’, ‘b’, ‘c’};

or

char name[] ={“abc” };

 

You can represent a string the same way you represent an array.

 

1

2

3

a

b

c

 

 

 

 

A standard library in C++ provides a string class type.

 

There are other ways to declare a different type of string.

 

Using namespace std;

String name;

 

Or

 

Std:: string name;

 

A string can be also assigned to each other or appended together using the + operator.

Strings can also be found as compsrisons…

 One of the most confusing part of using char*s as strings is that comparisons tricky.

Here is a simple example of the usage of a string;

 

WATCH MY VIDEO https://youtu.be/jk3wQsbn3mk

 

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
table.MsoTableGrid
{mso-style-name:”Tabla con cuadrícula”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-priority:39;
mso-style-unhide:no;
border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

 

 

#Mastery17 – Use of “switch” as a conditional

Hello this is that talks about using switch as a conditional. A switch sentence makes a variable to be tested to be equal against some values. Every value is named a case and the value is checked for every case.

 

The structure of a switch is…

 

Switch (the expression)

   

Case and constant expression: statement

 

[default : statement ]

 

When you make a switch statement make sure you are aware of:

       It is easier for the switch expression to work if it is an integer or an enumerated type.

       The number of cases is unlimited, each one has to be separated with the value they are compared to with a : .

       The constant and the expression compared have to be the same type.

       When a variable is equal to a case, the statements net to that case will execute until a break statement appears.

       A break the switch ends and the control jumps to the following line of the switch.

 

 

I found this diagram on http://www.tutorialspoint.com/cplusplus/images/cpp_switch_statement.jpg that may explain better this process.

The behavior of a switch statement goes like this:

 

If s converted value matches the expression – Control is transferred to a statement following the label.

 

If none of the constants match the ones on the case – Control is transferred to a default label.

 

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

If none of the constants match the constants in the case labels – Control is transferred to the statement after the switch statement.

 

I created this simple program as an example for the usage of a switch conditional. It evaluates the number introduced and says if you are an adult or not.

 

WATCH MY VIDEO https://youtu.be/-_8H_XSRJR8

 

WSQ14 – Estimating e

Hello this is about estimating e. This was a little difficult for me because so I had to do a little research on some new libraries that I didn’t know how to use. Here is my code on github…

 

https://github.com/ricardonewton/TC101/blob/master/wsq11

 

I had some difficulties with syntax as always, but nothing too big.

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

 

 

FINAL PROJECT – WEEK 1

Hello! this our first post of Max Bolaños and me for our programming , in which we are going to be working on image processing. This is new for us because it is something we have never done before. First we need to learn how to work with a library made for image processing called image magic. I read that there is a special library designed for c++ called Magick++, so we began downloading it but we are not pretty sure on what to do next. I found the library on the following page,

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

http://www.imagemagick.org/script/index.php but I couldn’t find the version for mac. So I looked it up on another page and started downloading it. The thing is that I am not pretty sure if this is going to work for me, so I guess it will be better if I download another operating system on my computer or an online one. I guess we will have to consult it with Ken.

 

We watched some tutorials on basic usage of the library to understand a little bit more about this.

#Mastery21 – Use of recursion for repetitive algorithms

Hello this is about using recursion in algorithms. A recursion refers to the action of when a function calls itself. It is kind of like creating a loop.

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

Why? Calling the function inside the function creates a series of events which lead to the result that is the same  using a lop with while or for.

 

  • In recursion, a function calls itself but you shouldn’t assume these two functions are same function. 
  • Local variables are defined inside a function and has scope only inside that function. In recursion, a function call itself.

 

Recursion makes it easier to express ideas in which the result of the recursive needs to complete the task.

WATCH MY VIDEO https://youtu.be/i9wo3N8tNzk

#Mastery06 – Install Linux on their own computer

Hello this is on how to download and install Linux in your own computer. Linux is a very free operating system which can be downloaded without cost. You don’t even have to download it directly to your hard drive, instead you can do it on a USB if you prefer to.

Installing Ubuntu on a USB for Windows:

 

First you will need a USB with at least 2GB of free space. How can you put it on the stick? Use the installer in Pendrivelinux.com download the installer and follow the steps…

 

1.     1. Choose Ubuntu from the list

2.     2. Click on browse to open the file.

3.     3. Choose the USB you are going to be using and do a click on create.

 

How can you make a removable USB stick for your Mac? Easy.

1.     1 .Download Ubuntu Desktop.

2.     2. Open the Terminal

 

 

 

 

 

3.     3. Convert the .iso file to .img using hdiutil

4.     4. Try to run it.

5.     5. Then you have to insert your flash media.

6.     6. Run and execute.

 

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

To boot up your mac using linux, restart it and press alt/option to choose the USB stick

#Mastery23 – Creation and use of vectors in C++

This is about creating and using vectors in C++. A vector in c++, is used to store different values in different storage compartments. It works almost the same as an array, the only difference is that the storage space can change. This is one of the differences with the arrays that storage spaces have to be declared.

 

Vectors take more memory space than arrays do. It is a list of values in which each of them are identified with a number. They can be made by any element and type.

These is how you declare a vector.

 

       You declare de type inside the angle brackets.

       You can declare the size of your vector in between parenthesis ( 6).

   

             Vectors can be represented in the same way as arrays, like in a table.

       The count of vectors starts in 0.

 

Now you have located your values inside vectors, how can you access them? It is using the [ ]. You can give some space a value like this:

 

count[4]= 60;

 

The best part of using them is that its size can be modified.

 

           The copy constructor takes one vector and copies it in the same size.

 

   –       You can involve functions with a vector, like size( ). This function gives the size of a vector.

 

Vectors can also be used to create random numbers. Computers are designed to always return back any result with the same process, this is a problem when you are looking for the computer to show up a random number. C++ has a function called random that does all this process for you.

 

It is important to learn how to make use of the different facilities c++ have for you. You just need to be very careful when using them.

 

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

WATCH MY VIDEO https://youtu.be/XRxkoby_RUE

#Mastery24 -Creation and use of arrays in C++

Hey there! This is that is about the creation and the usage of arrays in c++. Arrays are different numbers with the same type placed in separate spaces. It is like to fill drawers with information to use them after. This is used instead of declaring individual variables.

 

Let´s say you want the program to ask for 10 various numbers separately and then get the total of them, in this case you can use arrays. The only “disadvantage” of using an array is that you have to define the number of values to introduce.

Using arrays is easier than it sounds.

 

To understand its use, it is better to imagine them as boxes you are saving info into:

 

0

1

2

3

4

5

6

7

8

 

 

 

 

 

 

 

 

 

 

An array starts it´s count from the box number 0. Declaring an array is as easy as declaring some other thing. The structure of an array is like this:

 

type  nameofarray [number of spaces];

 

       An array can be any type just as a normal variable, but it is a arrangement of variables.

       You can choose whichever name you want for your array.

       The number in between the squared braces [ ] is to set the number of values introduced in the array.

       The number of spaces in the array has to be an integer because it is a whole unit space.

 

The elements of an array can be used to be introduced by the user of the program, or you can type them after declaring in between braces= { }.

 

Then when you want to use the values already stored inside an array, you have to simply type the nameofarray[ number of space of the value]. Be aware that the space number 0 counts as a space.

 

 

96

Normal
0

21

false
false
false

ES-TRAD
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Tabla normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
table.MsoTableGrid
{mso-style-name:”Tabla con cuadrícula”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-priority:39;
mso-style-unhide:no;
border:solid windowtext 1.0pt;
mso-border-alt:solid windowtext .5pt;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-border-insideh:.5pt solid windowtext;
mso-border-insidev:.5pt solid windowtext;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}

WATCH MY VIDEO https://youtu.be/XekmFL6VBwI

What should you work on?

Week #12 and more partial exams for you.

For this week's readings:
C++ (TC1017) should either be looking at support for your project, ImageMagick C++ libraries are a good start.
Python (TC1014) should be finishing chapter 11 (Dictionaries).