# IN PYTHON ONLY I am looking for 4 columns, Age, Gender, Ideal Age of a Spouse, and the message. I will have 6 rows in th...

IN PYTHON ONLY

I am looking for 4 columns, Age, Gender, Ideal Age of a Spouse, and the message.

I will have 6 rows in the table, and 4 columns, followed by  averages.

Calculate the ideal age of a spouse. Enter either m or f from the keyboard in lower case. You may use string data for the gender. Convert the gender to upper case

Enter an age from the keyboard, probably an integer

You will need prompts telling the user what to enter.

Use an IF statement to determine if the person is a male or female. You do one calculation if the person is a male else you do another calculation if the person is a female.

Use a loop where you enter this data (loop for 1 to 6 or 1 to 7 in Python)

m 28

m 70

m 18

f 32

f 60

f 13

For each set of data, print out the Gender, age, and Ideal Spouse's age, along with the following messages when they apply (the messages will be in the last column):

If a male over 60, print “robbing the cradle.”

If a male under 25, print “too young to be married”

if a female over 60, print “a gold digger”

if a female < 19 print “jail bait”

Plato's formula. A little bit out of date. You will be a gold digger or robbing the cradle if your age is over 40 because back then people only lived to be about 35 or so on the average.

For a male, his ideal spouse’s age is his age/2+7

For a female, her age*2-14

So, inside the loop

1. Input from the keyboard either m or f and an age

2. convert the m or f to upper or upper case

3. enter age from keyboard

4. Use an if to determine if user is a male or female. Use the appropriate syntax for your language. Calculate Ideal age.

5. Print the Gender as “Male” or as “Female”, and the age, and the ideal age you calculated.

6. Then print any matching messages on the same line

7. Accumulate the total idea age of a male spouse and of a female spouse and the count of males and females.

8. When you exit the loop the print the average idea age of a spouse for a male and the average ideal age of a spouse for a female.

if gender=="M"

do male calculation

else

do female calculation

In Python, you will need colons after the if and else.

remember two = signs for comparison

You will need braces for code blocks except in Python where you indent.

Here is code:

data = []

idea = {"male" : 0 , "female" : 0,"maleCount" : 0,"femaleCount" : 0}

count = 6

print("Enter an age from the keyboard, probably an integer")

for i in range(0,count):

userInput = input().split(" ")

g = userInput[0]

age = int(userInput[1])

if (g.upper() == 'M'):

spouse = age/2+7

idea["male"] += spouse

idea["maleCount"] += 1

message = ""

if(age > 60):

elif(age < 25):

message = "too young to be married"

data.append({

"gender" : g,

"age" : age,

"spouse" : spouse,

"message" : message

})

elif (g.upper() == 'F'):

spouse = age*2-14

idea["female"] += spouse

idea["femaleCount"] += 1

message = ""

if(age > 60):

message = "a gold digger"

elif(age < 19):

message = "jail bait"

data.append({

"gender" : g,

"age" : age,

"spouse" : spouse,

"message" : message

})

print("Gender\tAge\tIdeal Spouse\tMessage")

for i in range(0,count):

print(data[i]["gender"],"\t",data[i]["age"],"\t",data[i]["spouse"],"\t\t",data[i]["message"])

print("Average idea age of a spouse for a male ", idea["male"] / idea["maleCount"])

print("Average idea age of a spouse for a female ", idea["female"] / idea["femaleCount"])

print("Total male count : ",idea["maleCount"])

print("Total female count : ",idea["femaleCount"])

Output:

#### Earn Coin

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
• ### In PYTHON ONLY PLEASE You will use a dictionary in Python You only have string in Python so you have to use a string dat...

In PYTHON ONLY PLEASE You will use a dictionary in Python You only have string in Python so you have to use a string data type Use a Switch statement.A switch statement is just another way of writing an IF statement. The user will enter f, s, j, or r from the keyboard for freshman, sophomore, junior, or senior. Use character data type for c++. Then you can say something like: char level ='f'; level=toupper(level); You would need a loop...

• ### HEy GUYS PLZ I WROTE THIS CODE BUT I WAS ASKED TO ADD SOME ASSERTION TESTS AND I HAVE NEVER DONE SUCH THING. CAN YOU GUY...

HEy GUYS PLZ I WROTE THIS CODE BUT I WAS ASKED TO ADD SOME ASSERTION TESTS AND I HAVE NEVER DONE SUCH THING. CAN YOU GUYS HELPS ME OUT ON HOW TO TEST A SIMPLE CODE SINCE ITS A GUESSING GAME! THANK YOU. PYTHON import random # here it allows us to use the benefits of the functions random #function 1 which is just a screen organized wordings def screen): screeninstructions () name input("Your Name : ") print('Welcome, name, 'This...

• ### so i have my c++ code and ive been working on this for hours but i...

so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

Free Homework App