Question

Question 1 Select all the choices producing a string which contains multiple lines? Examples of each of the choices are presented below. #---------Option A--------------- s = ("Line 1","L...

Question 1 Select all the choices producing a string which contains multiple lines?

Examples of each of the choices are presented below.

#---------Option A---------------
s = ("Line 1","Line 2")

#---------Option B---------------
s = """Line 1
Line 2"""

#---------Option C---------------
s = "Line 1\nLine 2"

#---------Option D---------------
s = "Line 1" + "Line 2" #Option D

Make your statements look the same as the examples.

A.

Using commas to separate lines

B.

Using triple-quotation marks

C.

Adding the newline character between lines (\n)

D.

Using the '+' operator to add strings together

Question2

  
Consider a list x=[0,5,2,3]

Write the command to extract the third element of this list.

Remember not to include blank spaces in your answer

Question 3

Execute the following statements

lst1 = [1,3,5,7,9]

lst2 = [6,8,19,10]

lst = lst1 + lst2

lst = (lst[-2:] * 3)*5

lst.sort()

del lst[2:-5]

what is the sum of all the elements in the lst after executing above statements.

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

Answer of Question 1:-

qestion 1 in incomplete and ununderstand able

Answer of Question 2:-

to extract the third element from the list

syntax <variable assign to list>[postion -1]

answer of question:- x[2] # will print the third element as list starts from zero

Answer of question 3

lst1 = [1,3,5,7,9]

lst2 = [6,8,19,10]

lst = lst1 + lst2 // this will generate acombine list [1,3,5,7,9,6,8,19,10]

lst = (lst[-2:] * 3)*5 // this will replace elements of list will [19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10, 19, 10]

lst.sort() // this command will sort the list an the sorted list will be [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]

del lst[2:-5] // this command will delete list from element 2 to -5 an new list will be [10, 10, 19, 19, 19, 19, 19]

and sum will be 115

please rate good

Add a comment
Know the answer?
Add Answer to:
Question 1 Select all the choices producing a string which contains multiple lines? Examples of each of the choices are presented below. #---------Option A--------------- s = ("Line 1","L...
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