Question

In: Computer Science

Create individual python code cells for each of the three problems below. In each code cell,...

Create individual python code cells for each of the three problems below. In each code cell, use any additional variables and comments as needed to program a solution to the corresponding problem. When done, download the ipynb file and submit it to the appropriate dropbox in the course's canvas page

. 1.

a. Cell Number 1 * Recreate the same list of dictionaries you used during assignment 2.09. (Scroll down to see assignment 2.09 instructions) * Create another variable and define it as an empty list. It will store middle names, so name the variable appropriately. * Loop through the list of dictionaries using a `for` loop, and add each middle name to the list created to hold middle names in the previous bullet point.

b. Cell Number 2 * Create a variable and assign it the length of the middle names list created in the previous cell. Use the appropriate instruction to calculate the length instead of just typing the correct number, which is known as hard-coding. (Hint: You don't have to redefine the list in the new cell as long as you ran the previous cell recently) * Use a `while` loop to count up to the length of the middle names list, and print out the index and value of each item in the list using a format string. (Hint: start your counter at `0` and stop iterating before you reach the length by using a `<` operator)

c. Cell Number 3 * Loop through the list of dictionaries defined in the first cell using another `for` loop. (Hint: Again, you do not need to redefine the list of dictionaries from the previous cell as long as you executed it recently) * Nested inside of that loop, loop through the keys in the current dictionary using another `for` loop and the `enumerate()` instruction. * Nested inside of the nested loop, print out the key and value using a format string. (Hint: You'll need to use the key to get the value out of the dictionary) * Also inside of the nested loop, once the index is greater than or equal to 2, break out of the loop.

2.09 assingment instructions for question 1

**Requirements:** * Create a list containing separate dictionaries for at least 3 people (family members, actors, invisible friends, etc.) and assign the list to a variable. Instead of using your actual family members' names, I want you think of different names starting with the same letter as your family member so that I can't be accused of identity theft. * Each person dictionary should have at least 4 key/value pairs: * first name * middle name. * age (rounded to the nearest decade) * your favorite thing about them * Be sure to use the same keys for each person (eg. "first_name" for everyone's first names). * Print out the entire list.

Solutions

Expert Solution

****This requires some effort so please drop a like if you are satisfied with the solution****

I'm providing the solution cell by cell so please refer to the code screenshot for better reference...

Code:

#cell-1

#assignment 2.09

peopleDicts=[{'firstname':'Mark','middlename':'Evans','age':22,'favourite_thing':'behaviour'},{'firstname':'John','middlename':'Wick','age':42,'favourite_thing':'style'},{'firstname':'Tom','middlename':'Holland','age':26,'favourite_thing':'acting'}]

#cell-2

middleNames=[]
for x in peopleDicts:
middleNames.append(x['middlename'])
print(middleNames) #this line is just for reference

#cell-3

for people in peopleDicts:
for details in enumerate(people.keys()):
if(peopleDicts.index(people)>=2):
break
print("%s - %s"%(details[1],people[details[1]]))

Code and output screenshot:

If I run it on normal python compiler this how the code and output looks:

output:


Related Solutions

Create individual python code cells for each of the three problems below. In each code cell,...
Create individual python code cells for each of the three problems below. In each code cell, use any additional variables and comments as needed to program a solution to the corresponding problem. When done, download the ipynb file and submit it to the appropriate dropbox in the course's canvas page . 1. a. Cell Number 1 * Recreate the same list of dictionaries you used during assignment 2.09. (Scroll down to see assignment 2.09 instructions) * Create another variable and...
create a new Python 3 Jupyter Notebook.. Create one python code cell for the problem below....
create a new Python 3 Jupyter Notebook.. Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order. Problem: Define a function with the following characteristics: The function's purpose will be checking that a number matches another, so it should be named appropriately. It must accept one parameter, which is the number...
Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below....
Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order. When done, download the ipynb file and submit it to the appropriate dropbox in the course's canvas page. Problem: Define a function with the following characteristics: The function's purpose will be calculating a factORRial...
Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below....
Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order. *Problem:* 1. Define a function with the following characteristics: * The function's purpose will be checking that a number matches another, so it should be named appropriately. * It must accept one parameter, which...
PYTHON PROGRAMMING Using tktinker, create a gui that surrounds the code below that has buttons and...
PYTHON PROGRAMMING Using tktinker, create a gui that surrounds the code below that has buttons and labels and an overall theme. # Meet the chatbot Eve print('Hi there! Welcome to the ChatBot station. I am going to ask you a series of questions and all you have to do is answer!') print(' ') print('Lets get started') #begin questions firstName = input('What is your first name?: ') lastName = input('What is your last name? ') print("Hi there, ", firstName + lastName,...
can you please convert this python code into java? Python code is as shown below: #...
can you please convert this python code into java? Python code is as shown below: # recursive function def row_puzzle_rec(row, pos, visited):    # if the element at the current position is 0 we have reached our goal    if row[pos] == 0:        possible = True    else:        # make a copy of the visited array        visited = visited[:]        # if the element at the current position has been already visited then...
Normal Distribution Create an example of each of the three types of normal distribution problems. The...
Normal Distribution Create an example of each of the three types of normal distribution problems. The project will be graded on: (3 points each) Each example of one of the problem types. (1 point) Clear writing style and examples
In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
Create a Python program that includes each feature specified below. Comments with a detailed description of...
Create a Python program that includes each feature specified below. Comments with a detailed description of what the program is designed to do in a comment at the beginning of your program. Comments to explain what is happening at each step as well as one in the beginning of your code that has your name and the date the code was created and/or last modified. The use of at least one compound data type (a list, a tuple, or a...
Create a code showing Arduino IMU data being plotted by your Python code.  
Create a code showing Arduino IMU data being plotted by your Python code.  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT