Question

In: Computer Science

Declare a Python list named famfri with the first names of five friends or family members....

Declare a Python list named famfri with the first names of five friends or family members.

Lists and tuples are examples of what kind of Python construct?

Write a Python for loop that prints the names of the friends or family, one per line, without referencing a range or any literal numeric values.


Write Python code examples of statements to remove the name at position 2 from the list in the first problem, and to remove one of the remaining names by referencing that name.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Question 1:

#python list
famfri=['Virat','Sachin','Rahul','John','Sam']
#using for loop printing items from list
for name in famfri:
print(name) #print name

Output :

Question 2:

Code snippet :

del famfri[2] #delete item at index 2
famfri.remove("Sam") #remove item with name as sam

Screen :

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

Write a program that uses Python List of strings to hold the five student names, a...
Write a program that uses Python List of strings to hold the five student names, a Python List of five characters to hold the five students’ letter grades, and a Python List of four floats to hold each student’s set of test scores. The program should allow the user to enter each student’s name and his or her four test scores. It should then calculate and display each student’s average test score and a letter grade based on the average....
List the names of five parts of your first line of defense IN DETAIL.
List the names of five parts of your first line of defense IN DETAIL.
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the...
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the set of key/value pairs shown below. Create a function named iter_dict_funky_sum() that takes one dictionary argument.    Declare a running total integer variable. Extract the key/value pairs from DATA simultaneously in a loop. Do this with just one for loop and no additional forms of looping. Assign and append the product of the value minus the key to the running total variable. Return the funky...
Explain why there are differences in the kinds of support supervisors, coworkers, friends, and family members...
Explain why there are differences in the kinds of support supervisors, coworkers, friends, and family members can provide. Describe those types of support, give examples of each, and explain why differences exist in the kinds of support each of the people mentioned above can provide.
Creating a list/tuple 3.Given a list of tuples containing student first names and last names e.g....
Creating a list/tuple 3.Given a list of tuples containing student first names and last names e.g. (“John”, “Doe”) that represents a class. Ask the user for a students first and last name and check if that student is a member of the class.
Using LIST and FUNCTION Write a program in Python that asks for the names of three...
Using LIST and FUNCTION Write a program in Python that asks for the names of three runners and the time it took each of them to finish a race. The program should display who came in first, second, and third place.
"PYTHON" Declare a list that is initialized with six of your favorite sports teams. Print out...
"PYTHON" Declare a list that is initialized with six of your favorite sports teams. Print out the number of teams to the shell. Use a for loop to print out the teams to the shell. 2. a. Declare a sporting goods list, initially with no elements. b. Use a while loop to prompt the user for a sporting goods item and append the item to the list. c. Break out of the loop when the user enters exit; do NOT...
use python 1. Write a program that a. defines a list of countries that are members...
use python 1. Write a program that a. defines a list of countries that are members of BRICS (Brazil, Russia, India, China, Sri Lanka) b. Check whether a country is a member of BRICS or not Program run Enter the name of country: Pakistan Pakistan is not a member of BRICS Enter the name of country : India India is a member of BRICS 2. Write a program to create a list of numbers in the range of 1 to...
Python A good friend of yours sent you a long list of recipe names in a...
Python A good friend of yours sent you a long list of recipe names in a text file (where each line is a recipe that also includes information about how long it takes to do the recipe). You only want to know about the recipes that involve chocolate and are fast (i.e., take 15 mins or less to prepare). Write the program for this! Write a program to -       + Find recipes that involve chocolate that can be done...
The following is a list of the first names of 24 fictional students in a statistics...
The following is a list of the first names of 24 fictional students in a statistics class at Cleveland State University. The students are identified by numbering them 01 through 24. A sample of six students is to be selected by using systematic sampling. The first student to be selected is the one with ID 03. Choose the six students that will be included in the sample. ID Student ID Student 01 Ali 13 Sakiya 02 Pedro 14 Mary 03...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT