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

  Foreign company acquisition

Acquisition by a foreign company and the effects of that decision and the results of foreign exchange in Euro and the exchange rate differences.

  Financial management for profit and non profit organizations

In this essay, we are going to discuss the issues of financial management in a non-profit organisation.

  Method for estimating a venture''s value

Evaluate venture's present value, cash and surplus cash and basic venture capital.

  Replacement analysis

This document show the Replacement Analysis of modling machine. Is replacement give profit to company or not?

  Business finance task - capital budgeting

Your company is considering using the payback period for capital-budgeting. Discuss the advantages and disadvantages of this technique.

  Analysis of the investment

In this project, you will focus on one of these: the additional cost resulting from the purchase of an apple press (a piece of equipment required to manufacture apple juice).

  Conduct a what-if analysis

Review the readings and media for this unit, including the Anthony's Orchard case study media. Familiarise yourself with the Anthony's Orchard company and its current situation.

  Determine operational expenditures

Organisations' behaviour is guided by financial data. In the short term, such data will help determine operational expenditures; in the long term, historical data may help generate forecasts aimed at determining strategic plans. In both instances.

  Personal financial management

How much will you have left over each half year if you adopt the latter course of action?

  Sources of finance for expansion into new foreign markets

A quoted company is considering several long-term sources of finance for expansion into new foreign markets.

  Long term financial planning

This assignment is designed for analyze Long term financial planning begins with the sales forecast and the key input in the long term fincial planning.

  Explain the role of fincial manager

This assignment explain the role of fincial manager, function of manger. And what are the motives of financial manager.

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