Create the guess the number game course project

Assignment Help Financial Management
Reference no: EM132382350

Question

This week we will create the Guess the Number game course project. In addition, add some new feature to your Guess the number game.

Smarter computer guessing (if it is too high, the computer will decrease its guess by 1 or too low increase its guess by 1)

A limited number of guesses (for example - only 5 guesses)

Asking the user for his/her name and greeting the user by name

Here is the code you need to add to:

from random import randint

def menu():

print("1. You guess the number.")

print("2. You type a number, computer randomly guesses it")

print("3. Exit")

def user_guess():

#random number between 1 and 10 to be guessed by the user.

guess_number = randint(1,11)

user_guesses = []

count = 0

while True:

try:

guess = int(input("Guess a number between 1 and 10: "))

except ValueError:

print("Invalid value provided")

continue

if guess>10 or guess<1:

print("Invalid value provided")

continue

count+=1

user_guesses.append(guess)

if guess==guess_number:

print("You guessed it in ", count, " attempts!!")

print("You picked the following numbers: ", user_guesses)

break

elif guess>guess_number:

print("Too high!")

else:

print("Too low!")

#Random number, loop while true

def computer_guess():

#ask user to enter a value which computer should guess

count = 0

comp_guesses = []

#if number is too high or too low, tell user, if they guessed it break out of loop

while True:

try:

guess_number = int(input("Enter the guess number between 1 and 10 which computer will try to guesss: "))

if guess_number<1 or guess_number>10:

print("Invlid value entered")

continue

break

except ValueError:

print("Invalid value entered")

continue

while True:

#get computer random number between 1 and 10

guess = randint(1,11)

count += 1

comp_guesses.append(guess)

if guess == guess_number:

print("The computer guessed it in ", count, " attempts!!")

print("The computer guessed the following numbers: ", comp_guesses)

break

elif guess > guess_number:

print("The computer guessed ", guess, " which is too high")

else:

print("The computer guessed ", guess, " which is too low")

def main():

print("Welcome to my Guess the number program!")

while True:

menu()

try:

choice = int(input("Enter your choice: "))

except ValueError:

print("Please Enter a valid option: ")

continue

if choice >3 or choice <0:

print("Please Enter a valid option: ")

continue

if choice ==1:

user_guess()

elif choice ==2:

computer_guess()

elif choice==3:

print('Thank You for playing guess the number game!!!!')

break

main()

Reference no: EM132382350

Questions Cloud

How can organizations mitigate risk : How can organizations mitigate risk? Describe a company or organization that has adopted each risk mitigation strategy.
Use the api to get a list of all inventory parts in that set : For each set returned in part a, use the API to get a list of all inventory parts in that set. Since we are only interested in the parts that are used.
Consider a centers for disease control and prevention : Need help with this question. Answer need to be one to two paragraphs long. Thanks.
Main sources of healthcare high cost : Please explain what are the main sources of healthcare high cost and why these factors are increasing the cost
Create the guess the number game course project : Create the Guess the Number game course project. In addition, add some new feature to your Guess the number game. Smarter computer guessing.
Responsible management challenges hp inc faces : What recommendations could meet these challenges in terms of actions and corporate systems and structures?
Multi cultural employees from different countries : What are some of the factors affecting an organisation with multi cultural employees from different countries?
Which shopping centers are not attracting enough customer : How can foreign retailers be successful in a country in which shopping centers are not attracting enough customer?
BUS5CA Customer Analytics and Social Media Assignment : BUS5CA Customer Analytics and Social Media Assignment - Customer Segmentation and Profiling, Assessment Help and Solution - La Trobe University, Australia

Reviews

Write a Review

Financial Management Questions & Answers

  Use the binomial option pricing model

Use the binomial option pricing model with ?t = 1/12 (one month) to estimate the price of an American call option with an exercise price of 100.

  How large should the lump-sum deposit be

How much must you deposit annually to accumulate this amount. how large should the lump-sum deposit be?

  How much did the seller of the put earn as profit

You purchased a put option for $6.89 fifteen days ago. The call has a strike price of $95 and the stock is now trading at $91. If you exercise the put today, what is the value of the option? What is the profit you will make on the put? How much did t..

  Expected return on equally weighted portfolio of stocks

What is the expected return on an equally weighted portfolio of these three stocks?

  Similarities and differences between bear and bull spreads

What are the similarities and differences between bear and bull spreads?

  Subject merger and acquisition

What is the effect of such amendments on firm’s stock price based on empirical evidence?

  Most they will allow jim to spend on monthly mortgage

Apple bank has a maximum front end DTI limit of 28%, what is the most they will allow Jim to spend on a monthly mortgage?

  What is biweekly mortgage payment

What is the effective annual rate on Ms. Juliet’s mortgage? What is Ms. Juliet’s biweekly mortgage payment?

  Calculate the price of two year european put option

Calculate the price of a two year European put option on Excel Network Systems stock with a strike price of £60.

  Which of these cash flow streams has the higher present

Which of these cash flow streams has the higher present value if the discount rate is 5 percent? If the discount rate is 15 percent?

  Do you think the project should be accepted and why

Do you think the project should be accepted? Why? Assume the company has a P/B (payback) policy of not accepting projects with life of over 3 years.

  Prices will have gone down to a more reasonable level

You want to buy a new 3D/UHD television in 3 years, when you think prices will have gone down to a more reasonable level. You anticipate that at that time the television will cost $2,400. If you can invest your money at 8% compounded annually, how mu..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd