I need to write a pseudocode for the random password generator below. How do I write a pseudocode Do help me out. Thank you.
import random
import string
print('hello, Welcome to Password generator!')
l = False
while not l:
length = int(input('\nEnter the length of password: '))
if length < 8 :
print('You password length is too short(must be more than 8 character)')
print(length, "is the length of your password")
elif length > 16:
print('You password length is too long(must be less than 17 character)')
print(length, "is the length of your password")
else:
print('You password length looks good')
break
lower = string.ascii_lowercase
upper = string.ascii_uppercase
num = string.digits
symbols = string.punctuation
all = lower + upper + num + symbols
temp = random.sample(all,length)
password = "".join(temp)
print(password)
is this good enough?
IMPORT random
IMPORT string
OUTPUT('hello, Welcome to Password generator!')
SET l TO False
WHILE not l:
SET length TO int(INPUT('\nEnter the length of password: '))
IF length < 8 :
OUTPUT('You password length is too short(must be more than 8 character)')
OUTPUT(length, "is the length of your password")
ELSEIF length > 16:
OUTPUT('You password length is too long(must be less than 17 character)')
OUTPUT(length, "is the length of your password")
ELSE:
OUTPUT('You password length looks good')
break
SET lower TO string.ascii_lowercase
SET upper TO string.ascii_uppercase
SET num TO string.digits
SET symbols TO string.punctuation
SET all TO lower + upper + num + symbols
SET temp TO random.sample(all,length)
SET password TO "".join(temp)
OUTPUT(password)
or this one:
DECLARE length<-int(input('\nEnterthelengthofpassword:')) : INTEGER
import random
import string
OUTPUT 'hello, Welcome to Password generator!'
l<-False
WHILE not l DO
INPUT length<-int(input('\nEnterthelengthofpassword:'))
IF length < 8
THEN
OUTPUT 'You password length is too short(must be more than 8 character'
OUTPUT length, "is the length of your password"
ENDIF
elif length > 16: //You will need to change this to CASE OF
OUTPUT 'You password length is too long(must be less than 17 character'
OUTPUT length, "is the length of your password"
ELSE
OUTPUT 'You password length looks good'
break //This might be better as a repeat loop
ENDWHILE
lower<-string.ascii_lowercase
upper<-string.ascii_uppercase
num<-string.digits
symbols<-string.punctuation
all<-lower + upper + num + symbols
temp<-random.sample(all,length)
password<-"".join(temp)
OUTPUT password
Process finished with exit code 0
Pseudocode is kind of code, and is meant to show the steps of a specific algorithm. For this algorithm, it might look like this.
output "Welcome"
l := false
while l is not true do
length := int value of input("Enter length of password: ")
if length < 8 do
output "Your password is too short"
else if length > 16 do
output "Your password is too long"
else do
output "Password length looks good"
break from loop
endif
endwhile
lower := array of lowercase letters
upper := array of uppercase letters
numbers := array of digit characters
symbols := array of punctuation characters
all := lower combined with upper combined with numbers combined with symbols
temp := random sample of all, with length len
password := join "" with temp
output password
For more reading on pseudocode, look at this link: https://en.wikipedia.org/wiki/Pseudocode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.