1 Replies - 149 Views - Last Post: 08 July 2019 - 04:41 AM Rate Topic: -----

#1 tgytxd   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-July 19

Dice game question please covert to python from pseudocode

Posted 08 July 2019 - 04:15 AM

Password = password
User1username=input(“Enter a username “)
User1 read to file
User1 = (“enter a password “ )
If password == password
Print (“you can play the game “ )
Else
Print (“you can’t play the game “ )
User2username = input (“Enter a username”)

if User2username == User1username
Print (“try a different username “ )
Else
Print (“you can play the game “ )
User2 = input (“enter a password”)

if password == password
Print (“you can play the game “ )
Else
Print (“you can’t play the game “ )
#game
Dice1 = random (1, 6)
Dice2 = random (1, 6)
User1Score= Dice1 + Dice2
If Dice1 == %0 then
User1Score= User1Score + 10
Else
User1Score = User1Score – 5
If Dice1== Dice2
Print (“you may roll again”)

Else
Print (user1Score)
Dice3 = random (1, 6)
Dice4 = random (1, 6)
User2(“press enter to roll the dice “ )


User2Score= Dice3 + Dice4
Print (User2Score)

If User2Score == %0 then
User2Score= User2Score + 10
Else
User2Score = User2Score – 5
If Dice3== Dice4
Print (“you may roll again”)
Else
Print (user2Score)
If user1Score>user2Score
Print (“User1 wins “ )
Winner = user1

if user2Score> User1Score
Print (“user2 wins “ )
Winner = User2
else
User1Score= user1Score+ random (1, 6)
User2Score = user2Score + random (1, 6)
If
User1Score > User2Score
Print (“User1 wins “ )
Winner= User1
else
Print(“ user2 wins”)
Winner=User2

#leaderboard
print("The true winner is ", winner, well done”)

file = openAppend("highscores.txt")


n = 4
top5players = readline(1)

WHILE leaderboard[n] < highscore AND n >= 0

IF n != 4 THEN

Top5players[n+1] = top5players[n]

ENDIF

leaderboard[n] = WinnerScore

n = n - 1
ENDWHILE

close file


Is This A Good Question/Topic? 0
  • +

Replies To: Dice game question please covert to python from pseudocode

#2 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 551
  • View blog
  • Posts: 1,730
  • Joined: 27-December 13

Re: Dice game question please covert to python from pseudocode

Posted 08 July 2019 - 04:41 AM

Hello tgytxd, welcome to Dream.In.Code - I hope you will find it helpful.

Please observe, however, our rule #1: We won't do your work for you.

I suggest that you make a decent attempt of converting your pseudokode to real python.
If you run into problems, you are most welcome back here.

When submitting code, please place it between code tags. You can use the icon that appears right above the input field.

Happy coding.

This post has been edited by DK3250: 08 July 2019 - 04:42 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1