Question
can you turn the below python code into pseudocode? #Part 1: #This section prompts for name, age, and sex, looping until the name is not
can you turn the below python code into pseudocode?
#Part 1:
#This section prompts for name, age, and sex, looping until the name is not
entered. The inputs are
#stored in their associated lists for later computation.
male = []
female = []
user = []
name = " "
while name <> "":
name = raw_input("Enter a name or press enter to exit: ")
user.append(name)
if name == "":
break
age = int(raw_input("Enter age: "))
sex = raw_input("Enter sex(m/f): ")
if sex == 'm':
male.append(age)
if sex == 'f':
female.append(age)
print "Loop Completed"
#Part 2
#This command will give me the number of males vs females
print ("The total number of males is")
print len(male)
print ("The total number of females is")
print len(female)
#Part 3
#This command will calculate and display the average age of males and females
if len(male)>0:
print ("The average age of the males is")
print sum(male)/len(male)
if len(female)>0:
print ("The average age of the females is")
print sum(female)/len(female)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started