Try to search your question here, if you can't find : Ask Any Question Now ?

How to turn this pseudocode to python?

HomeCategory: stackoverflowHow to turn this pseudocode to python?
Avatarsourav asked 1 month ago

I am unable to change this pseudocode into python code.
The program needs a function, GetNumber(), to return a valid membership number. A valid
membership number is a four-digit numeric string between “1111” and “9999”. The structured English representing the algorithm for this function is as follows:
1. Prompt and input a membership number.
2. Validate the membership number.
3. Repeat from step 1 if the membership number is invalid.
4. Return the valid membership number as a string.

I have done the pseudocode for it

FUNCTION GetNumber() AS STRING
  DECLARE Valid : BOOLEAN
  DECLARE MemberNumber : INTEGER
REPEAT
Valid ← TRUE
    OUTPUT "Please input a valid member number"
    INPUT MemberNumber
    IF (MemberNumber > 9999) OR (MemberNumber < 1111)
THEN
Valid ← FALSE
    ENDIF
  UNTIL Valid = TRUE
  RETURN STR(MemberNumber)
ENDFUNCTION
1 Answers
Best Answer
Avatarnaveen answered 1 month ago
Your Answer

5 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com