Answer to Question #321386 in Python for JoJo

Question #321386

Q5:     Create a list containing the following 3 elements:


your favorite color

the number of pets you have

a boolean value describing whether you have previous programming experience


Q6:     Complete the following print and if statements by accessing the appropriate elements from my_list.


Hint: Use the list indexing notation [].

 

print('My favorite color is', ???) print('I have {} pet(s).'.format(???)) if ???:

print("I have previous programming experience") else:

print("I do not have previous programming experience")


Q7:     Add your favorite single digit number to the end of the list using the appropriate list method.

Q8:     Remove the first element of the list, using the appropriate list method.

Q9:     Complete the print statement below to display the number of elements in my_list. print("The list has {} elements.".format(???))


1
Expert's answer
2022-06-23T08:19:37-0400
color: str = "green"
num_of_pets: int = 0
have_prog_experience: bool = True

my_list: list = [color, num_of_pets, have_prog_experience]

print('My favorite color is', my_list[0])
print('I have {} pet(s).'.format(my_list[1]))
if my_list[2]:
    print("I have previous programming experience")
else:
    print("I do not have previous programming experience")

print('My list: {}'.format(my_list))
my_list.append(7)
print("My list after appending new digit number: {}".format(my_list))
my_list.pop(0)
print("My list after removing the first element: {}".format(my_list))
print("The list has {} elements.".format(len(my_list)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS