wsq12

#Contador de palabras

 

def contador(p):

return text.count(p) #cuenta las veces que aparece la palabra(p) en el texto

 

palabra = input(“Ingrese la palabra a buscar: “).lower() #lo convierte en minusculas

texto=input(“Cuál es el nombre del archivo?: “)

 

with open(texto, “rt”) as Txt:

text = Txt.read().lower() #abre el archivo y convierte todo en minusculas

 

print (“la palabra”, palabra, “se repite estas veces: “,(contador(palabra)))

quiz6

#include <iostream>

using namespace std;

 

int euclidianAlgo(int first, int second){

int tem=0;

int res=first%second;

while(res!=0){

first=second;

second=res;

res=first%second; }

 

return second; }

 

 

 

int main() {

int first, second, val;

cout<<“This program does the Euclidian Algorithm of the range of numbers you give”<<endl;

cout<<“Type the lower value”<<endl;

cin>>first;

cout<<“Ok now type the higher value”<<endl;

cin>>second;

val=euclidianAlgo(first, second);

cout<<“The greatest denominator of the two numbers is: “<<” “<<val<<endl; }

quiz5

#include <iostream>
using namespace std;
bool palindrome(string word){
int c=1;
string invert=string(word.rbegin(), word.rend());
int z=word.size();
for(int i=0; i<z; i=i+1){
if (word[i]==invert[i]) {
return true; }
else {
return false; }
return 0; } }
int main(){
string word;
cout<<“This program calculate if a single word is a palondrome or not”;
cout<<“Give the word to prove if its a palindrome or not”<<endl;
cin>>word;
if(palindrome(word)==false) {
cout<<word<<” “<<“Its NOT palindrome”<<endl; }
else{
cout<<word<<” “<<“It´s a Palindrome”<<endl; }
return 0;
}

CÓDIGO 2.

#include <iostream>
using namespace std;

int threesAdd(int range[], int numOfNum) {
int total=0;
int divi=0;
int val;
for(int i=0; i<numOfNum; i=i+1){
val=range[i];
if(val%3==0){
cout<<val<<” “<<“Is divisible so it goes to the addition”<<endl;
divi=divi+1;
total=total+val;}
else { } }
cout<<“The total divisble numbers:”<<” “<<divi<<” “;
return total; }

int main() {
int values;
cout<<“This program evaluates a range of numbers and make a total addition”<<endl;
cout<<“But it only add the ones which are divisibles by 3″<<endl;
cout<<“How many values you will type?”<<” “;
cin>>values;
int range[values];
for(int i=0; i<values; i=i+1){
cout<<“Type the”<<” “<<i+1<<” “<<“number”<<endl;
cin>>range[i]; }
cout<<“The total addition of the no.3 divisibles is:”<<” “<<threesAdd(range, values)<<endl;
return 0;
}

quiz4

#include <iostream>
using namespace std;

int factorial(int x) {
if(x==0) {
return 1; }
else {
return x*factorial(x-1); }
}
long double eulerCal(float precision) {
long double e=0, previous=e;
int n=0;
do {
previous=e;
e=e+1.0/factorial (n);
n=n+1; }
while((e-previous)>precision);
return e;
}

int main() {
long double prec;
cout<<“Give the precision to determinate until wich value the program will run”<<endl;
cin>>prec;
cout<<“The Euler value with precision of:”<<” “<<prec<<” “<<“is: “<<” “<<eulerCal(prec)<<endl;
return 0;
}

YoSoy196

#include <iostream>
using namespace std;
#include “BigIntegerLibrary.hh”
BigInteger swap(BigInteger val) {
BigInteger changed=0;
while(val>0) {
changed=(changed*10)+(val%10);
val=val/10;
}
return changed;
}

int LychrelConver(BigInteger val) {
BigInteger add;
int resp, tries=0;
if(val==swap(val)) {
resp=1; }
else {
add=val+swap(val);
while(tries!=30 && add!=swap(add)) {
add=add+swap(add);
tries=tries+1; }
if(tries==30) {
resp=2;
cout<<“Lychrel candidate is “<<” “<<val<<endl;
}
else {
resp=3; }
}
return resp;
}
int main() {
int high, low, lychrel, first, moreTries, resp;
BigInteger val;
lychrel= 0;
first = 0;
moreTries = 0;
cout<<“Give the lower bound of the range of numbers”<<endl;
cin>>low;
cout<<“Give the upper bound of the range of numbers”<<endl;
cin>>high;
for(int i=0; val!=high; i=i+1){
val=low+i;
if(LychrelConver(val)==1) {
first=first+1; }
else if(LychrelConver(val)==2){
lychrel=lychrel+1; }
else {
moreTries=moreTries+1; }
}
cout<<“Lychrel´s”<<” “<<lychrel<<endl;
cout<<“Natural palindrome”<<” “<<first<<endl;
cout<<“More tries palindromes”<<” “<<moreTries<<endl;
return 0;
}

WSQ10

#include <iostream>
#include <cmath>

using namespace std;

int suma (int numeros[], int x){
int suma=0;
for(int i=1; i<=x; i++){
suma=suma+numeros[i];
}
return (suma);
}

float DE (int numeros[], int p, int x){
float des;
float var =0.0;

for(int i=1; i<=x; i++){
var=var+ pow(p-numeros[i],2);
}
cout << var<< endl;
var=var/n-1;
des=sqrt(var);
return (des);
}

int main (){
//int num;
int n, prom, s;
int nums[n];

cout << “cuantos numeros quieres insertar?” << endl;
cin >> n;
cout << “Inserta “<< n << “numeros” << endl;

for (int i=1; i<=n; i++){
cin >> nums[i];
}

s=suma(nums, n);
prom = s/n;
cout <<“El promedio de esos numeros es: “<< prom << endl;
cout << “desviacion estandar es ” << DE (nums, prom, n)<< endl;
return 0;
}

#wsq04

Estoy  favor del Abolish Grading Policy y el Flipped Clasroom ya que siento que le dan al alumno mas libertad y le quitan mucho estres innecesario ya que hacen que el alumno quiera aprender genuinamente y no solo para “cumplir” con lo que le piden, por consecuente hace innecesario el hecho de copiar (fenomeno que se da mucho), siento que este deberia de ser el futuro de la educacion, promover el autoaprendizaje y no solo sentarte a escuchar un maestro, ya que esto te hace mas independiente, util y habil para investigar, y por supuesto eliminar la estructura actual de calificaciones porque hacen que el alumno solo se preocupe por un numero o por “pasar” mas que por en realidad aprender, que es en realidad lo mas importante.

quizz3

Este programa es para sacar la distancia entre 2 puntos con pitagoras.

#include <iostream>
#include <cmath>

using namespace std;

float distance(int x1, int x2, int y1, int y2){
float d;
d= sqrt(pow(x2-x1,2)+pow(y2-y1,2));
return (d);
}

int main(){
int a1, a2, b1, b2;
cout << “Introduzca el valor de x1: ” << endl;
cin>>a1;
cout << “Introduzca el valor de x2: ” << endl;
cin>>a2;
cout << “Introduzca el valor de y1: ” << endl;
cin>>b1;
cout << “Introduzca el valor de y2: ” << endl;
cin>>b2;
cout<< “La distancia entre esos puntos es: ” << distance(a1, a2, b1, b2) << endl;

return 0;
}

—————————————

#include <iostream>

using namespace std;

int fibo(int n){
if(n<=1){
return (n);
} else
return fibo(n-1)+fibo(n-2);
}

int main(){
int num;
cout << “Introduce el numero sobre el cual quieres saber su fibonacci:”<< endl;
cin>>num;
cout << “El numero en la posicion ” << num << ” de la serie de fibonacci es: “<< fibo(num)<< endl;

return 0;
}

quizz2

#include <iostream>

using namespace std;

int r=1;
int superpower(int a, int b){
for (int c=1; c<=b; c++){
r=r*a;
}
return(r);
}

int main(){
int num1, num2;
cout<< “Escribe el valor del numero que quieres elevar a una potencia: ” << endl;
cin>> num1;
cout << “Escribe a que potencia lo quieres elevar: ” << endl;
cin>> num2;
cout << “El resultado es: ” << superpower(num1, num2) << endl;

return 0;

}

————————————————

#include <iostream>

using namespace std;

void stars(int s){ // void se escribe ya que significa vacio, que quiere decir que la funcion no va a regresar ningun valor como tal sino solo un output de string o texto.
for (int c=1; c<=s; c++){
cout<<“*”;
}
}

int main(){

int num;
cout<< “Enter the number of stars you want to print: ” << endl;
cin>>num;
stars(num);

return 0;

}

—————————————————

 

quizz 1

#include <iostream>

using namespace std;

int main(){

float r, h, v;

cout << “Give me the radius value:” << endl;
cin >> r;
cout << “Give me the height value: ” << endl;
cin >> h;
v=3.1416*(r*r)*h;
cout << “The volume of the cilinder is: ” << v << endl;

return 0;

}

———————————————————–

#include <iostream>

using namespace std;

int main(){
int i1, i2, m, d, r;

cout << “Give the value of two integer numbers” << endl;
cin>> i1;
cin>> i2;
m=i1*i2;
d=i1/i2;
r=i1%i2;
cout << “The product of the number is: ” << m << endl;
cout << “The division result is: ” << d << endl;
cout << “The remainder from the division is: ” << r << endl;

return 0;

}

—————————————-

#include <iostream>

using namespace std;

int main(){
float i1, i2, m, d, a, s;

cout << “Give the value of two numbers” << endl;
cin>> i1;
cin>> i2;
m=i1*i2;
d=i1/i2;
a=i1+i2;
s=i1-i2;
cout << “The product of the number is: ” << m << endl;
cout << “The division result is: ” << d << endl;
cout << “The adittion is: ” << a << endl;
cout << “The subtraction is: ” << s << endl;

return 0;
}