# WSQ06 – Pick A Number

El programa nos preguntará acerca de un número del 1 al 100(hablando de números enteros), el cual el usuario tiene que adivinar, para eso, el programa te va ayudando cada vez que se selecciona un número diciéndote si el número que seleccionaste es mayor o menor al que se tiene que adivinar.

El propósito de: int x= rand () % 101; es para que efectivamente el programa solo nos de adivinar números del 1 al 100.

El programa termina cuando logras acertar el número.

Haga click para ver el pase de diapositivas.

Link GitHub: WSQ06 – Pick A Number

# #WSQ06 – Pick a Number

The main purpose of this program is that the user guess a number from 1 to 100. Display the user the number of tries  and it give you hints of low and high, close to the number.

The first thing you need to do is import the random library in order to generate a random number each time the program executes, this random number will be between 1 and 100. Also you need to use a counter staring at 0, later you will use it to display the number of times until the user guess the number.

In this case I use a while loop because I know that the point to stop its when the guess of the user its equal to the random number, so as long as the guess of the user its different, the while loop will repeat but with several conditions using if, elif that includes when the number its out of both boundries and when the number is high or low.

At the end when the user wins, the while loop ends and the random number is printed, the number of time you try as well.

I did two runs, you can see the random number its not the same.

#TC101

# WSQ6

Encontre un error desde el principio , consulte a varios compañeros y nadie encontro el error.
https://github.com/carbajal13itesm/Fundamentos-/blob/master/WSQ06

# Pick a number (WSQ06)

This homework is really fun, because I need to create a game, so the user should guess which number the program did choose.

I didn’t know how to print/choose a random number, this website helped me out. The variable for the random number will be “x”

Alright, the range that I need is from 1 to 100. While proving the code, I’ll print the random number, but I’ll erase line 3 when I end up the homework.

Then I need the user to guess my number, so I enter an input. And of course I assign it a variable, “y”.

As we want our user to guess, we need to give him/her some clues. If he/she typed a lower or higher number, the program should print which is the problem.

Up to here, the result is this:

Now I’ll say the user how many times he/she needed to guess the right number, and I’ll also comment line 3.

Aaand there we go… 😀 Here’s my code, you can download it if you need/want to.

See ya..!

# WSQ06 – Pick a number

In this WSQ, we created a programm that works like a mini simple viodegame. Guess the correct number.
So, for the computer to choose a random number we use “rand()%100” = x, that will be the mysterious number. Also use srand(time(NULL)) because Ken told to use it. Something about everytime, would be a different number, or something like that. But in the class I’ll ask him again.

Also I checked various blogs from my co-students LOL.

I did something extra here. I Put inly 7 chances to guess the right number, ’cause if you don’t, you’ll lose every talent that you think you have.

Just kiddin, you only will lose the game.

https://github.com/antonioangelm24/TC101/blob/master/WSQ06

# Guess the number

This WSQ was about making a program that picks a random number between 1 and 100 and then give you clues for you to know if you are near of the random number or not. Also the user is able to know how many guesses did he had to make to get the correct answer.

Even I had an idea of how to do this program, I needed to search how to generate a random number. Here are some links that I used for making this task: Tool 1, Tool 2, Tool 3. Also a video, it was not the same thing but it was really similar.

After searching I noticed that I had to use some other libraries: stdlib.h and time.h . The first one was needed so I could be able to use ” rand() ” for generating the random number, and the second one was a library to know the actual hour of the system, this because if not it would always generate the same number. So if we use that library it would not be possible to generate a same number twice because its not possible to use the program twice or more in a second.

I need to make this program twice because for any reason the first one that I made was not working (Yes, I compared them and they said the same but one was working and the other one not 🙁 ).

I had already use Do – While before on C# also If – else. So the main problem on this task was generating a random number and the fact that I was using new libraries.

You can see my program on github: Random number.
I attach a picture of my program working (You can notice that

# WSQ06 – Randomising randomness

Hello, people. We’re feeling random today. Random as in python’s random library. Think about libraries as groups of functions that python doesn’t always have at hand. You see, when you use python, your code may have many purposes and python is no medium to tell which functions you are going to use, you actually can do a lot with just python’s basic functions but for example, if you’re working on a  math-related code you might as well import the math library, if you’re just generating random numbers or using a specific distribution, then you should import the random library, as we’re doing today :

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

Editor :

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

Now we can use any of the functions included in the random library. You might be asking what kind of wicked code is it that we’re working on today, but it’s not that crazy, and not hard at all. Today’s code just needs to pick a random integer from 1 to 100, then ask for a user input from 1 to 100 to make the user guess the random generated number :
————————————————————————–

Editor :

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

Notice that every time you use a function from a library you’ve imported, you need to type the name of a library and a period before calling the function. There’s a way to avoid this which is to import a specific function from any library, for example :

from random import randint

In this case, you wouldn’t need to type “random.” in your current code, but it is recommended to use the first method, as it lets you remember, and anyone know, where each function was imported from.

Anyways, back on our practice, this code let’s the user play only one time. Maybe we’d like the user to play until he’s got the number

# Pick a number WSQ06

Hi again!! honestly this task was a little difficult, I had to do some research for this WSQ, and i found some great videos that I leave here. The WSQ consist in creating a program  that ask the user a random number between 1 and 100, the user have to guess and the program won’t stop running until you get the right number, but the machine give you hints and the number of attempts.

Chis is my link for my code, GitHub.