Question

Using Python What will the following code display? names = [‘Vernon’, ‘Cooper’, ‘Ronnie’, ‘Clay’] if ‘Jordan’...

Using Python

  1. What will the following code display?

names = [‘Vernon’, ‘Cooper’, ‘Ronnie’, ‘Clay’]

if ‘Jordan’ not in names:

              print(‘Cannot find Jordan.’)

else:

              print(‘Jordan is a dog’)

              print(names)

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

Solution:

Since names list does not contain element name as 'Jordan', therefore, if condition will satisfy and output will be printed as Cannot find Jordan.

Code:

# defining names list with names of dogs
names = ['Vernon', 'Cooper', 'Ronnie', 'Clay']

# checking with if condition whether Jordan is in names list or not
# since 'Jordan' is not present in names list of dogs, we will go inside
# the if condition and execute the statement inside it.
if 'Jordan' not in names:
   print('Cannot find Jordan.')

# this condition will not get executed since if condition is satisfied.
else:
   print('Jordan is a dog')
   print(names)

Screenshot of Code:

Screenshot of output:

Add a comment
Know the answer?
Add Answer to:
Using Python What will the following code display? names = [‘Vernon’, ‘Cooper’, ‘Ronnie’, ‘Clay’] if ‘Jordan’...
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
ADVERTISEMENT