Answered You can hire a professional tutor to get the answer.

QUESTION

The goal of the script here for Python is to make a program that lets users enter their information as long as they want.

Hello,

   I need help with an assignment. The goal of the script here for Python is to make a program that lets users enter their information as long as they want. The information I need is sex, age, and name. Then I have to print the number of males/number of females and an average age. Finally, the user has to be able to exit the program. This is what I have so far. I think I am on the right path but some help would be great in completing this script.

name = " "

gender = " "

age = " "

maleVariable = []

femaleVariable = []

ageVariable = []

name = raw_input ("Enter name here or press enter to end script:")

while True:

   if name == "enter":

       break

   else:

       age = raw_input ("Enter age here:")

       gender = raw_input ("Enter gender here (male or female):")

   if gender == "male":

       maleCount == maleCount + 1

       MaleInfo.append ((name, age))

   if gender == "female":

       femaleCount = femaleCount + 1

       FemaleInfo.append ((name, age))

name = ""

list = [ ]

while name <> " ":

   name = raw_input ("What is your name: ")

age = ""

list = [ ]

while age <> " ":

   age = raw_input ("How old are you: ")

sex = ""

list = [ ]

while sex <> " ":

   sex = raw_input ("Are you a male or female: ")

for i in MaleInfo:

   print i[0] + " is " + i[1] + " year old."

for i in FemaleInfo:

   print i [0] + " is " + i [1] + "years old."

cont = 'y'

cont not in "yes or no"

print femaleCount

print femaleAge/femaleCount

print maleCount

print maleAge/maleCount

print "Loop completed"

maleVariable = []

femaleVariable = []

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question