Skip to content

This is a console program that rolls a pair of dice and asks the user to guess the sum. If the user's guess is equal to the total value of the dice roll, the user wins. Otherwise, the computer wins.

Notifications You must be signed in to change notification settings

candytale55/Number_Guess_Python_2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Number_Guess_Python_2

General info

This is a console program that rolls a pair of dice and asks the user to guess the sum. If the user's guess is equal to the total value of the dice roll, the user wins. Otherwise, the computer wins.

Features

The program should do the following:

  • Roll a pair of dice.
  • Add the values of the roll.
  • Ask the user to guess a number.
  • Compare the user's guess to the total value.
  • Determine the winner (user or computer).

More info:

To make sure that the rolls are random we imported the randint function from the random module.

To simulate dice rolls: we imported the sleep function from the time module to sleep the program for 2 seconds to simulate the dice rolling.

get_user_guess() : prompt the user for their guess

roll_dice(number_of_sides) : used to simulate the rolling of a pair of dice. A single die can land on any value that’s at least 1 and no greater than the die's number of sides. The randint functions generates a random integer between 1 and number_of_sides. max_val calculates the maximum value the program can possibly roll, which is the number_of_sides times the _number_of_dice.

Table of contents

Screenshots

Example screenshot

Technologies

  • Python 2 - Probably will also work for Python 3

Setup

NA

Status

Project is: finished

References

From course Learn Python 2 here: https://www.codecademy.com/learn/learn-python

About

This is a console program that rolls a pair of dice and asks the user to guess the sum. If the user's guess is equal to the total value of the dice roll, the user wins. Otherwise, the computer wins.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages