0% found this document useful (0 votes)
2 views

Cs project

The document describes a simple Dice Rolling Simulator that allows users to simulate rolling a 6-sided dice. Users can input a number between 1 and 6 to simulate a roll, and the program checks for valid input before displaying the result. The game continues in a loop until the user chooses not to play again.

Uploaded by

Bhavya Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Cs project

The document describes a simple Dice Rolling Simulator that allows users to simulate rolling a 6-sided dice. Users can input a number between 1 and 6 to simulate a roll, and the program checks for valid input before displaying the result. The game continues in a loop until the user chooses not to play again.

Uploaded by

Bhavya Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Dice Rolling Simulator without imports or functions

# A list representing the faces of the dice

dice_faces = [1, 2, 3, 4, 5, 6]

# Print a welcome message

print("Welcome to the Dice Rolling Simulator!")

print("This program will simulate rolling a standard 6-sided dice.")

# Start an infinite loop to keep the game running

while True:

# Ask the user to press Enter to roll the dice

print("\nPress Enter to roll the dice!")

input() # Wait for the user to press Enter

# Simulate a dice roll by randomly selecting a number from the dice faces

# Since there's no random import, we will manually choose a dice face

user_choice = int(input("Enter a number between 1 and 6 to simulate the


dice roll: "))

if user_choice < 1 or user_choice > 6:

print("Oops! You need to enter a number between 1 and 6.")

continue # If the input is invalid, we ask the user again

# Simulate the dice roll (choosing a random number from the list)

roll_result = dice_faces[user_choice - 1]
# Display the result of the dice roll

print(f"\nYou rolled a {roll_result}!")

# Ask the user if they want to play again

play_again = input("\nDo you want to roll the dice again? (y/n): ")

# If the user doesn't want to play again, exit the loop

if play_again.lower() != 'y':

print("\nThanks for playing! Goodbye!")

break # Exit the loop and end the program

You might also like