The Student Room Group

I made a completely pointless thing in python that was kinda easy to make

ARE YOU PROUD OF ME?


lmao learning python because why not, and wanted to make something using the basics before moving on to slightly more complicated stuff like lists, arrays, dictionaries etc.

EDIT: Some parts of it aren't showing up properly




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":wink:

while guessing_1:
digit_1_guess = input('Guess the first digit: ':wink:

if digit_1_guess == digit_1:
print("You guessed the first digit correctly, try guessing the next":wink:
guessing_1 = False
guessing_2 = True
else:
print('Guess again':wink:
points = points + 1

while guessing_2:
digit_2_guess = input('Guess the second digit: ':wink:

if digit_2_guess == digit_2:
print("You guessed the second digit correctly!":wink:
guessing_2 = False
points = str(points)

else:
print("Guess again":wink:
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!":wink:



(edited 6 years ago)
There are a bunch of semicolons in there that I didn't put in and a big space lmao
lol I remember doing this in btec level 2 ict back in the day
randintpic.PNG


Yeah if you wanna see it (for whatever reason) here is a picture of it
(edited 6 years ago)
Original post by Bill Nye
ARE YOU PROUD OF ME?


lmao learning python because why not, and wanted to make something using the basics before moving on to slightly more complicated stuff like lists, arrays, dictionaries etc.

EDIT: Some parts of it aren't showing up properly





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":wink:

while guessing_1:
digit_1_guess = input('Guess the first digit: ':wink:

if digit_1_guess == digit_1:
print("You guessed the first digit correctly, try guessing the next":wink:
guessing_1 = False
guessing_2 = True
else:
print('Guess again':wink:
points = points + 1

while guessing_2:
digit_2_guess = input('Guess the second digit: ':wink:

if digit_2_guess == digit_2:
print("You guessed the second digit correctly!":wink:
guessing_2 = False
points = str(points)

else:
print("Guess again":wink:
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!":wink:







There’s a book called automate the boring stuff with python it’s online, I recommend it!
Original post by yellowcopter
lol I remember doing this in btec level 2 ict back in the day


BTEC?

wtf noob you did a level 2 BTEC that means you won't go to oxbridge.

That means you dumb boi



Spoiler

Reply 6
Original post by yellowcopter
lol I remember doing this in btec level 2 ict back in the day


This is a bit of a self drag since you admit to doing btec lol
Original post by Bill Nye
BTEC?

wtf noob you did a level 2 BTEC that means you won't go to oxbridge.

That means you dumb boi



Spoiler




How will I ever live with myself :lol:

Oh wait I did A Level Computing and have no desire to go to Oxbridge nor study Comp Sci, already feel better. :tongue:

There was a once upon a time I did want to do computer science tho. Then I realised being a programmer would be the most boring job in the world for me. Simply not my personal passion. :smile:

Original post by romil332
This is a bit of a self drag since you admit to doing btec lol


Well not really, as everyone at my secondary school did mandatory level 2 ICT. :smile: They didn't do GCSE ICT, and Computing GCSE didn't exist back then...
Well done! Everyone starts somewhere! :smile:

TSR's forums have got more bugs than a bait shop, sometimes it's easier to paste code on somewhere like https://repl.it instead

Small programs like this are a good way to practice and get better, even once you've mastered the basics, otherwise you forget things that you don't do very often, so writing small programs on a regular basis is a good way to stay sharp. Actually, there's even a name for it - Code Kata - http://codekata.com/


Maybe the next step is to make a more general solution - for example, changing the program so that it could cope with 3, 4, 5 or 10 digits without writing code which is almost copy+pasted. Being able to take some existing code solution and generalise it is an important skill!

Quick Reply

Latest

Trending

Trending