Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

1. What is the nominal interest rate if expected inflation is 0%?

Answered: 1 week ago