Question

In: Computer Science

In many programming languages you can generate a random number between 1 and a limiting value...

In many programming languages you can generate a random number between 1 and a limiting value named LIMIT by using a statement similar to randomNumber = random(LIMIT). Create the logic for a guessing game in which the application generates a random number and the player tries to guess it. Display a message indicating whether the player’s guess was correct, too high, or too low. (After you finish Chapter 4, you will be able to modify the application so that the user can continue to guess until the correct answer is entered.)

Solutions

Expert Solution

  • Code:-

import random

RandomNumber = int((random.randint(1,100)))

#the range is from 1 to 100

RandomNumber1 = int(input("enter a RandomNumber:"))

#Logic to perform random RandomNumberber game Logic

if(RandomNumber <= RandomNumber1):
    print("the RandomNumber",RandomNumber," is lower than", RandomNumber1)
elif(RandomNumber1 == RandomNumber):
    print("the RandomNumbers",RandomNumber, "are equal")
else:
    print("the RandomNumber",RandomNumber, "is higher than", RandomNumber1)
  
  

  • Output:-

  • Note:- I have choose Python for this game

Thank You...!


Related Solutions

You can use any programming languages Using a random generator, compute 1000 integers between 1 and...
You can use any programming languages Using a random generator, compute 1000 integers between 1 and 1000. There will be duplicates in the array. Sort the array using bubble sort and merge sort. The two sorted arrays should agree. Then pick at random one element from your sorted array and use a binary search to find its position in the array.
9. Generate a random number between 1 and 8, which is the computer’s number. Ask the...
9. Generate a random number between 1 and 8, which is the computer’s number. Ask the user to guess a number between 1 and 8. Write a sentinel-controlled loop to continue to executed until the user’s guess matches the computer’s number. If the user's guess matches the random number, print a message in green on the SenseHat congratulating the user and then break out of the loop. Otherwise, print a message in red on the SenseHat to ask the user...
It is standard in some programming languages for the number zero to represent one of the...
It is standard in some programming languages for the number zero to represent one of the truth values (either true or false) and for positive numbers to represent the other truth value. If assigned correctly, the operations of addition and multiplication will then correspond to conjunction and disjunction, in some order. Figure out how to make this all work out neatly.
Find as many programming languages as possible which fit the following categories. When you find a...
Find as many programming languages as possible which fit the following categories. When you find a language which fits the category, indicate the following information: The name of the language The year the language was released A sample bit of code to prove that the language belongs to the given category. For full marks, you must find at least two languages for each category. To make the assignment more interesting, extra points will be awarded to the person who finds...
Create a class called RandomGuess. In this game, generate and store a random number between 1...
Create a class called RandomGuess. In this game, generate and store a random number between 1 and 100. Then, continuously (in a loop): Ask the user to enter a number between 1 and 100 Let the user know if the guess is high or low, until the user enters the correct value If the user enters the correct value, then display a count of the number of attempts it took and exit
JAVA Write a number guessing game that will generate a random number between 1and 20 and...
JAVA Write a number guessing game that will generate a random number between 1and 20 and ask the user to guess that number. The application should start by telling the user what the app does. You should then create the random number and prompt the user to guess it. You need to limit the number of times that the user can guess to 10 times. If the user guesses the number, display some message that tell them that they did...
Some languages support many modes of parameter passing. Provide 2 examples using two different programming languages...
Some languages support many modes of parameter passing. Provide 2 examples using two different programming languages which support the user of the programming language deciding which to use when creating their method. (Programming Languages)
Collect the Data: Use a random number generator to generate 50 values between 0 and 1...
Collect the Data: Use a random number generator to generate 50 values between 0 and 1 (inclusive). Theoretical Distribution In words, X = The theoretical distribution of X is X ~ U(0, 1). In theory, based upon the distribution X ~ U(0, 1), find μ = __________ σ = __________ 1st quartile = __________ 3rd quartile = __________ median = __________ Construct a box plot of the data. Be sure to use a ruler to scale accurately and draw straight...
Create a class called RandomWhen. The program must continuously generate a random number between 1 and...
Create a class called RandomWhen. The program must continuously generate a random number between 1 and 100 inclusive. The program must stop when the number 1 is generated, and the loop iteration will be printed. Run the program 3 different times. Sample output: It took ## iterations to generate a 1. It took ## iterations to generate a 1. It took # iterations to generate a 1.
What can you say in general about the limiting behavior of a random walk on an...
What can you say in general about the limiting behavior of a random walk on an even-length cycle compared to that of the lazy random walk?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT