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.
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.
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...
Python #Exercise 1 #Assign the following first names to a variable name as a list: peter,paul,mary...
Python #Exercise 1 #Assign the following first names to a variable name as a list: peter,paul,mary #Assign the following last names to a variable name as a list: ng,lo,lau #Display each first name in a separate line in turn so that your screen shows (ignore the #): #peter #paul #mary #Combine the elements in the list in turn so that you display the full names of each person in separate lines #Output should look like the following (ignore the #):...
using python #You've been sent a list of names. Unfortunately, the names #come in two different...
using python #You've been sent a list of names. Unfortunately, the names #come in two different formats: # #First Middle Last #Last, First Middle # #You want the entire list to be the same. For this problem, #we'll say you want the entire list to be Last, First Middle. # #Write a function called name_refixer. name_refixer should have two #parameters: an output filename (the first parameter) and the #input filename (the second parameter). You may assume that every #line will...
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...
In C#, declare structure named Person. The structure should have the following attributes of first name,...
In C#, declare structure named Person. The structure should have the following attributes of first name, last name, zip code, and phone number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT