Python Forum
Converting pseudocode to Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting pseudocode to Python
#1
hi there,

First python project, need to convert the psuedocode which I wrote below to python. Don't actually need the program to work just need the python code. Brand new to this stuff, would appreciate someone helping me out.
qwerty

number = RAN_NUMBER
count_attempts = 0
answer_status = (“incorrect”)
while answer_status = (“incorrect”)
guess = input (“please guess number)
count_attempts = count_attempts +1
if guess = number then print (“well done. count_attempts”)
answer_status=(“correct”)
else print (“number of digits correct”)
endif
endwhile
Reply
#2
You have to make some effort on your own to convert it.
Recommended Tutorials:
Reply
#3
What have you tried? We are glad to help, but we are not here to do your homework for you.
Please, post your code (in code tags) and ask specific questions. Don't forget to include the full traceback (in error tags) if you get one.
You are lucky as python code is so close to natural language, that your pseudo-code needs very little in order to turn into real python code.
Also, it's funny to say you don't need the program to work, just the python code :-)
Reply
#4
Okay here is my code

import random
number = random.randint(1000,9999)
print number
count_attempts = 0
answer_status = "incorrect"
while(answer_status == "incorrect"):
guess = input ("please guess number")
count_attempts = count_attempts + 1
if guess == number:
print ("well done. The number of attempts it took were")
print count_attempts
answer_status = "correct"
else:
print("number of digits correct")

I need to insert a function which allow me to say when I get the answer wrong it will print the number of digits from the number that i guessed were right. Any ideas?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting String to Integer Python Johnny1998 5 3,014 Aug-02-2019, 08:13 PM
Last Post: Johnny1998
  Can't figure out how to write the correct functions for my pseudocode mkrodick 2 2,675 Jul-30-2018, 12:30 PM
Last Post: ichabod801
  Problem writing code with my pseudocode MattWilk97 1 2,845 Aug-29-2017, 01:54 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020