Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.8 kB
0
Indexable
Never
import random

def guess_number():
    number = random.randint(1, 100)
    attempts = 0

    print("Welcome to the Guessing Game!")
    print("I have picked a number between 1 and 100. Can you guess it?")

    while True:
        guess = int(input("Enter your guess: "))
        attempts += 1

        if guess < number:
            print("Too low!")
        elif guess > number:
            print("Too high!")
        else:
            print(f"Congratulations! You guessed the number in {attempts} attempts.")
            break

guess_number()
In this game, the guess_number() function generates a random number between 1 and 100 using the random.randint() function. It then prompts the player to enter their guess in a loop. The program provides feedback ("Too low!" or "Too high!") based on whether the guess is lower or higher than the actual number.

Once the player guesses the correct number, the program displays a congratulatory message along with the number of attempts it took to guess correctly.

This is just a basic example, but you can expand and modify it based on your requirements and add more features to make it more interesting.





User
code a horror game
ChatGPT
Creating a complete horror game is a complex task that goes beyond the scope of a simple response. However, I can provide you with a high-level overview and some key elements you might consider when coding a horror game. Keep in mind that building a full-fledged horror game requires advanced programming skills and potentially a team of developers, artists, and designers. Here are some key components to consider:

Game Engine: Choose a game engine that suits your needs and skillset. Popular choices for horror games include Unity, Unreal Engine, or Godot.

Environment and Atmosphere: Design a dark and eerie