my code stock.com

description necessary

Snippet options

Download: Download snippet as numgame.py.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

"""nodesritpion"""

from random import randint
from time import sleep

def get_user_guess():
  guess = int(raw_input("Guess Number: "))
  return guess

def roll_dice(number_of_sides):
  first_roll = randint(1, number_of_sides)
  second_roll = randint(1, number_of_sides)
  max_val = number_of_sides * 2
  print("The max value is %d") % max_val
  guess = get_user_guess()

  if guess > max_val:
    print("Your number is invalid")
  else:
    print("Rolling...")
    sleep(2)
    print("The first roll is: %d") % first_roll
    sleep(1)
    print("The second roll is: %d") % second_roll
    sleep(1)
    
    total_roll = first_roll + second_roll
    print("Total value is: %d") % total_roll
    print("Result...")
    sleep(1)
  if guess == total_roll:
    print("Excellent!")
  else:
    print("Wrong! Try again")

roll_dice(6)

 

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.