Question

Python: Write an inline if statement to assign x the value 1 if the variable y...

Python:

Write an inline if statement to assign x the value 1 if the variable y = 'female' and assign x the value 0 if the variable y = 'male'. The variable y has only two possible values, 'male' and 'female'.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Screenshot:

# Declare a variable. y=female # Declare the inline if. x=l if y==female else o # display the result. print (x)

Sample Output:

Code to Copy:

# Kindly indent the code as given in above screenshot.

# Kindly use python 3.5 or 3.6

# Declare a variable.
y="female"

# Declare the inline if.
x=1 if y=='female' else 0

# display the result.
print(x)

Add a comment
Know the answer?
Add Answer to:
Python: Write an inline if statement to assign x the value 1 if the variable y...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT