from random import randint
digit_1 = str(randint(0, 9))
digit_2 = str(randint(0, 9))
random_number = digit_1 + digit_2
guessing_1 = True
guessing_2 = False
points = 0
print("Get a score as close to 0 as possible"
while guessing_1:
digit_1_guess = input('Guess the first digit: '
if digit_1_guess == digit_1:
print("You guessed the first digit correctly, try guessing the next"
guessing_1 = False
guessing_2 = True
else:
print('Guess again'
points = points + 1
while guessing_2:
digit_2_guess = input('Guess the second digit: '
if digit_2_guess == digit_2:
print("You guessed the second digit correctly!"
guessing_2 = False
points = str(points)
else:
print("Guess again"
points = points + 1
print("Well done, you found the number, it is " + random_number)
print("You scored " + points + " points! Try again and get it even closer to zero!"
from random import randint
digit_1 = str(randint(0, 9))
digit_2 = str(randint(0, 9))
random_number = digit_1 + digit_2
guessing_1 = True
guessing_2 = False
points = 0
print("Get a score as close to 0 as possible"
while guessing_1:
digit_1_guess = input('Guess the first digit: '
if digit_1_guess == digit_1:
print("You guessed the first digit correctly, try guessing the next"
guessing_1 = False
guessing_2 = True
else:
print('Guess again'
points = points + 1
while guessing_2:
digit_2_guess = input('Guess the second digit: '
if digit_2_guess == digit_2:
print("You guessed the second digit correctly!"
guessing_2 = False
points = str(points)
else:
print("Guess again"
points = points + 1
print("Well done, you found the number, it is " + random_number)
print("You scored " + points + " points! Try again and get it even closer to zero!"
Spoiler
Spoiler
Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]