[英]How to write Pseudocode for Random Password Generator created using Python?
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有关伪代码的更多阅读,请查看此链接: https://en.wikipedia.org/wiki/Pseudocode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.