What's new

Help Badly need help mga boss

Panto

Honorary Poster
Established
Joined
Dec 3, 2021
Posts
364
Reaction
83
Points
179
di talaga kaya ng logic ko mga boss pano bato pasahan na kasi e baka puwede pasagot
Screenshot_20240421-182212.jpg
 

Attachments

Hello! I understand that you're facing difficulties with understanding the logic behind a problem. It's important to remember that asking for direct answers or solutions without attempting to solve the problem yourself won't help you learn and improve your skills in the long run.

Instead of seeking answers outright, I recommend breaking down the problem into smaller parts and working through each step systematically. Try to understand the requirements of the problem, identify the key components, and then start devising a plan to tackle it. If you get stuck on a specific part, feel free to ask for guidance on that particular aspect.

Remember, the process of problem-solving is just as important as arriving at the solution. It's through facing challenges and overcoming obstacles that we truly grow as programmers. Good luck, and don't hesitate to ask for help with specific aspects of the problem!
 
import random

# Function to play the guessing game
def guessing_game():
# Generate a random number between 1 and 50
number_to_guess = random.randint(1, 50)

# Initialize the number of attempts
attempts = 0

while True:
try:
# Increment the number of attempts
attempts += 1

# Get user input
guess = input("Guess the number between 1 and 50: ")

# Convert the guess to an integer
guess = int(guess)

# Check if the guess is outside the range
if guess < 1 or guess > 50:
raise ValueError("The number is outside the range of 1-50.")

# Check if the guess is correct
if guess == number_to_guess:
print(f"Congratulations! You guessed the correct number {number_to_guess} in {attempts} attempts.")
break
elif guess < number_to_guess:
print("Try again! The number is higher.")
else:
print("Try again! The number is lower.")

except ValueError as e:
# Handle non-numeric input and numbers outside of range
print(f"Invalid input: {e}. Please enter a number between 1 and 50.")

# Start the game
guessing_game()

Hope it helps
 
Gamitin mo ChatGPT. Bigay mo instructions then check mo kung tama binigay niya na result sa example output. Para may matutunan ka habang ineexplain mo kay ChatGPT kahit papaano.
 

Similar threads

Back
Top