Monthly Archives: February 2015

WSQ09. Factorial Calculator

For this WSQ I had to do a factorial calcultaron without importing predifined functions that python already have. For that, I had to define a function for the factorial calculation and a For loop to calculate the result.

Before enter the function in the actual program I did a while loop for the user to do as many calculations as he wants.

The complicated about this was to implement a way to avaoid the user to enter a float number, for this, i used the try and except statements which are explained better here: https://docs.python.org/2/tutorial/errors.html

Here is the link to my program submitted to GitHub:https://github.com/Manuelmv94/TC1014/blob/master/WSQ09.py

#WSQ09

click here for code

in this program we are doing the factorial multiplication of a number:

I crated a fuction to do so, using a counter and an accumulator within a loop. the program also uses many while and if statements, so the program ca repeat itself until the user wants to stop.

#WSQ09

#WSQ09

click here for code

in this program we are doing the factorial multiplication of a number:

I crated a fuction to do so, using a counter and an accumulator within a loop. the program also uses many while and if statements, so the program ca repeat itself until the user wants to stop.

#WSQ09

Factorial Calculator #WSQ09 #TC1014

Este programa funciona como si hicieras math.factorial(), ya que con esta función multiplicas el número dado por el usuario bajando uno a uno multiplicándolos hasta llegar al número 1, Ejemplo: 5*4*3*2*1= 120 así funciona este programa.

https://github.com/ErickViz/WSQ09/blob/master/WSQ09

Factorial Calculator #WSQ09 #TC1014

Factorial Calculator #WSQ09 #TC1014

Factorial Calculator #WSQ09

Here’s a Factorial Calculator I made on Python, with some help from our Teacher:

https://www.dropbox.com/s/uuui2xkxq8952ip/Factorial.py?dl=0

Oscar Ricardo López López A01229116

#WSQ09

Here it is my 😀 it’s really easy 

here it is: https://github.com/Julio1229898/Ken-Work/blob/master/WSQ09.py

WSQ09

 

In this code, I created two variables called n and i. Then, i asked the user to enter an integer value for n, and asigned that value for “i”. After that, i created another variable called “fact” which then would be multiplied by “i” in relation to the “for loop” =((i=n ; i>=1 ; i–), in order to create the factorial. 

# include <iostream>

using namespace std;

 

int main () {

 

int i, n;

int fact=1;

cout<<“Enter the Value of n “<<endl;

cin>>n;

for(i=n ; i>=1 ; i–)

fact = fact*i;

cout<<“Factorial = “<<fact;

 

return 0;

}

Mastery 04

#mastery20

Hello, I have done my in , wich is bucle “for”

 

I am going to explain a little what I did:

A cicle For is compost by three elements: initialization, condition and increment/decrement  and after this you will construct the body of the bucle.

 int a;

for(num1=0; num1<10; num1++) {

cout <<“Hello”>> endl;

}

 

my program is here:

https://www.dropbox.com/s/kor2nw2xlhrv1cb/mastery20.cpp?dl=0

Creation and use of strings.

Hello! this is my

You can create a variable with type string in the usual ways:

string first;
first = "Hello, ";
string second = "world.";

The first line creates an string without giving it a value. The second line assigns it the string value “Hello.” The third line is a combined declaration and assignment, also called an initialization. Normally when string values like “Hello, ” or “world.” appear, they are treated as C strings. In this case, when we assign them to an string variable, they are converted automatically to string values. We can output strings in the usual way:
cout << first << second << endl;