Question

We have a list x = [1,2,3,4,5]. Please write codes to generate in Python: 1. the...

We have a list x = [1,2,3,4,5]. Please write codes to generate in Python:

1. the first element of x

2. the first three element of x

3. the last three element of x. (use the format on page 8 of the slide)

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

x = [1,2,3,4,5]

ans1 = x[0]
print(ans1)

ans2 = x[:3]
print(ans2)

ans3 = x[-3:]
print(ans3)

Add a comment
Know the answer?
Add Answer to:
We have a list x = [1,2,3,4,5]. Please write codes to generate in Python: 1. the...
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