The goal of the script here for python is to make a program


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. Additionally, there must be an exception for spelling male or female wrong and an exception for ages outside of the 18-65 range. This is what I have so far but loops, lists and exceptions is quite confusing.

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 = []

Solution Preview :

Prepared by a verified Expert
JAVA Programming: The goal of the script here for python is to make a program
Reference No:- TGS02635699

Now Priced at $30 (50% Discount)

Recommended (97%)

Rated (4.9/5)