Language: Python
Topic: Tuples
Function name : todo_tuple
Parameters : todo (list of tuples of strings), completed (list of
strings)
Returns: final_list (list)
Description : Write a function that takes in a list of tuples of
strings that represents the work you have to do in each class, and
a list of strings that represent the work you have already
completed. Each tuple in the todo list represents the work for a
single class. For this function, go through the work for class
(tuple) and remove the work that you have already completed (in the
completed list). Return a new list of tuples representing the
modified class work without the completed work. If you finish all
work for a class, do not add an empty tuple to your final
list..
Notes: Your code should not allow capitalization to change the searching of the work. So for example, if “read book” is the work for one class, and “READ BOOK” is on the completed list, the work “read book” would be eligible to be removed. You will need to add the original casing of the work to your final list.
Test Cases:
>>> todoList = [(“read psyc chapter 5”, “do online survey”), (“write meeting minutes”, “email client back”, “delete unused pictures”), (“look over problem set”,)] >>> completedList = [“read Psyc chapter 5”, “Look over problem set”] >>> print(todo_tuple(todoList, completedList))
[(“do online survey”,), (“write meeting minutes”, “email client back”, “delete unused pictures”)]
>>> todoList1 = [(“complete 1301 HW05”, “read online textbook”), (“Do STATS Worksheet”, “solve linear program”, “”make Stochastic matrix”), (“finish chem lab”, “write lab report”)] >>> completedList1 = [“COMPLETE 1301 HW05”, “WRITE lab Report”]
>>> print(todo_tuple(todoList1, completedList1)) [('read online textbook',), ('Do STATS Worksheet', 'solve linear program', 'make Stochastic matrix'), ('finish chem lab',)]
If you have any doubts, please give me comment...
Code:
def todo_tuple(todo, completed):
final_list = []
for t in todo:
tp = []
for t1 in t:
exist = False
for t2 in completed:
if t1.lower()==t2.lower():
exist = True
break
if not exist:
tp.append(t1)
if tp:
final_list.append(tuple(tp))
return final_list
todoList = [("read psyc chapter 5", "do online survey"), ("write meeting minutes", "email client back", "delete unused pictures"),
("look over problem set",)]
completedList = ["read Psyc chapter 5", "Look over problem set"]
print(todo_tuple(todoList, completedList))
Language: Python Topic: Tuples Function name : todo_tuple Parameters : todo (list of tuples of strings),...
Language: PYTHON Function name : favorite_day Parameters : list of tuples (dates), int (weekday, 0-6, Mondays are 0), int (day of the month 1 to 28) Returns: dates: list of tuples Description: Imagine that you have a favorite weekday, and want to see if certain days fall on that weekday. Using the calendar module from the Python standard library , write a function which takes in a list of tuples formatted like [(month, year), etc.], your favorite weekday, and a...
Python 5. Write a function named grade_components that has one parameter, a dictionary. The keys for the dictionary are strings and the values are lists of numbers. The function should create a new dictionary where the keys are the same strings as the original dictionary and the values are tuples. The first entry in each tuple should be the weighted average of the non-negative values in the list (where the weight was the number in the 0 position of the...
Language: Python Topic: Dictionaries Function name: catch_flight Parameters: dictionary, tuple containing two strings Returns: dictionary Description: You’ve been stuck in NYC for around 8 months all by yourself because you haven’t been able to find a good time to fly home. You’re willing to go to any city but want to see how many flights to each location fit your budget. You’re given a dictionary that has city names (strings) as the keys and a list of prices (list) and...
Language: Python Topic: API and JSON Function name: min_pop_countries Parameters: region (str), num (int) Return: list of tuples Description: You are working on a project for your Demography class and you are tasked with finding the top num most populous countries in a given region . Instead of looking up on the Internet, you decide to apply your CS1301 knowledge of APIs and write a function to solve the problem for you. Develop a function that takes in a region...
Create a new project in BlueJ and name it LastName-lab8-appstore, e.g., Smith-lab8-appstore. If your App class from Lab 4 is fully functional, copy it into the project. (You can drag a file from File Explorer onto the BlueJ project window.) Otherwise, use the instructor's App class: Create a new class using the "New Class..." button and name it App. Open the App class to edit the source code. Select and delete all the source code so that the file is...
linked list operation
/***************************************************************************************
This function creates a new node with the information give as a parameter and looks
for the right place to insert it in order to keep the list organized
****************************************************************************************/
void insertNode(string first_name, string last_name, string phoneNumber)
{
ContactNode *newNode;
ContactNode *nodePtr;
ContactNode *previousNode = nullptr;
newNode = new ContactNode;
/***** assign new contact info to the new node here *****/
if (!head) // head points to nullptr meaning list is empty
{
head = newNode;...
In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...
12:11 7 くBack Week 06 Homework #5.docx CMPR100 Week 06 Homework #5 There are 2 tasks each worth 50% Task #1 Turn to page (EX 109) and complete Lab O1: Insurance Premium Worksheet, when completed submit only the excel file Task #2 In your Discovering Computers 2016 book, read chapter 02 and write a one-page essay on page 77 (Ethics &Issues 2-3). Use a separate word document for the the essay as week 06 Homework #5 Task "2. essay and...
In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...
What happened on United flight 3411?What service expectations
do customers have of airlines such as United and How did these
expectations develop over time?
Thank You!
In early April 2017, United Airlines (United), one of the largest airlines in the world, found itself yet again in the middle of a service disaster this time for forcibly dragging a passenger off an overbooked flight. The incident was to become a wake-up call for United, forcing it to ask itself what to...