answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kvasek [131]
1 year ago
14

Address the FIXME comments. Move the respective code from the while-loop to the created function. The add_grade function has alr

eady been created.# FIXME: Create add_grade functiondef add_grade(student_grades):print('Entering grade. \n')name, grade = input(grade_prompt).split()student_grades[name] = grade# FIXME: Create delete_name function# FIXME: Create print_grades functionstudent_grades = {} # Create an empty dictgrade_prompt = "Enter name and grade (Ex. 'Bob A+'):\n"delete_prompt = "Enter name to delete:\n"menu_prompt = ("1. Add/modify student grade\n""2. Delete student grade\n""3. Print student grades\n""4. Quit\n\n")command = input(menu_prompt).lower().strip()while command != '4': # Exit when user enters '4'if command == '1':add_grade(student_grades)elif command == '2':# FIXME: Only call delete_name() hereprint('Deleting grade.\n')name = input(delete_prompt)del student_grades[name]elif command == '3':# FIXME: Only call print_grades() hereprint('Printing grades.\n') for name, grade in student_grades.items(): print(name, 'has a', grade) else: print('Unrecognized command.\n') command = input().lower().strip()
Computers and Technology
1 answer:
Sever21 [200]1 year ago
4 0

Answer:

The Python code is given below with appropriate comments

Explanation:

# FIXME: Create add_grade function

def add_grade(student_grades):

print('Entering grade. \n')

name, grade = input(grade_prompt).split()

student_grades[name] = grade

# FIXME: Create delete_name function

def delete_name(student_grades):

print('Deleting grade.\n')

name = input(delete_prompt)

del student_grades[name]

 

# FIXME: Create print_grades function

def print_grades(student_grades):

print('Printing grades.\n')    

for name, grade in student_grades.items():

print(name, 'has a', grade)

 

student_grades = {} # Create an empty dict

grade_prompt = "Enter name and grade (Ex. 'Bob A+'):\n"

delete_prompt = "Enter name to delete:\n"

menu_prompt = ("1. Add/modify student grade\n"

"2. Delete student grade\n"

"3. Print student grades\n"

"4. Quit\n\n")

command = input(menu_prompt).lower().strip()

while command != '4': # Exit when user enters '4'

if command == '1':

add_grade(student_grades)

elif command == '2':

# FIXME: Only call delete_name() here

delete_name(student_grades)

elif command == '3':

# FIXME: Only call print_grades() here

print_grades(student_grades)

else:

print('Unrecognized command.\n')

command = input().lower().strip()

You might be interested in
A news channel runs a two-minute story on phishing scams. The report features the testimonies of a phishing victim and a compute
OverLord2011 [107]

Answer:

to be honest I don't know what the answer is

7 0
1 year ago
g 18.6 [Contest 6 - 07/10] Reverse an array Reversing an array is a common task. One approach copies to a second array in revers
Blababa [14]

Answer:

I am writing C++ program. Let me know if you want the program in some other programming language.  

#include <iostream> //to use input output functions

using namespace std; //to identify objects like cin cout

void reverse(int array[], int size){ //method to reverse an array  

int i, j, temp; //declare variables  

for (i = 0; i < size / 2; i++) { /* the loop swaps the first and last elements, then swap the second and second-to-last elements and so on until the middle of the array is reached */  

temp = array[i];  

array[i] = array[size - i - 1];  

array[size - i - 1] = temp; }  

cout<<"Reversed array: "; //prints the resultant reversed array after swapping process  

for (j = 0; j < size; j++) { //loop to print the reversed array elements  

cout<<array[j]<<" "; } }    

int main() { //start of main() function body  

cout<<"Enter the length of array: "; //prompts user to enter the length of the array

       int n; //stores the value of size of array

       cin>>n; //reads the input size of array

       int A[n]; //declare array A of size n

       cout<<"Enter the elements: "; //prompts user to enter array elements

       for(int i=0;i<n;i++){ //loop for reading the elements of array

           cin >> A[i];        }

         reverse(A,n); } //calls reverse function to reverse the elements of the input array A by passing array A and its length n to function reverse

Explanation:  

The reverse function takes an array and its length as parameter. In the body of reverse function three integer type variables i,j and temp are declared.

for (i = 0; i < size / 2; i++) The for loop has a variable to iterate through the array. The for loop checks if the value of i is less than the array length. Lets say we have an array of elements 1, 2, 3, 4. As i=0 and size/2 = 4/2= 2. So the condition checked in for loop is true as 0<2 which means the body of for loop will be executed.

In the body of the loop there are three swap statements.

temp = array[i] This statement stores the element of array at i-th index to temp variable.

array[i] = array[size - i - 1] statement stores the element of array at size-i-1 to array index i.  

array[size - i - 1] = temp statement stores the the value in temp variable to the array index size-i-1

In simple words first, the first and last elements of array are swapped, then the second and second last elements are swapped. This process keeps repeating and for loop keeps executing these swap statements until the middle of the array is reached. In this program no extra array is used for reversing procedure but just a variable temp is used to hold the array elements temporarily.

array[4] = { 1 , 2 , 3 , 4}  

At first iteration  

i < size/2 is true as 0<2  

So the program control moves in the body of the loop where three swap statement works as following:  

temp = array[i]  

temp = array[0]  

As element at 0-th index which is the first element of array is 1 so

temp= 1  

array[i] = array[size - i - 1];  

array[0] = array[4-0-1]  

           = array[3]  

As the element at 3rd index of array is 4 which is the last element of the array so

array[0] = 4

This means that 4 becomes the first element of array now.

array[size - i - 1] = temp  

As the value in temp was set to 1 so  

array[4-0-1] = 1  

array[3] = 1  

This means 1 is assigned to the 3rd index of array. Which means 1 becomes the last element of the array now.

This is how the first and last elements of array are swapped.  

2nd iteration: value of i is incremented to 1 and now i = 1  

Again for loop condition is checked which evaluates to true as 1<2

temp = array[i]  

temp = array[1]  

As element at 1st index which is the second element of array is 2 so

temp= 2  

array[i] = array[size - i - 1];  

array[1] = array[4-1-1]  

           = array[2]  

As the element at second index of array is 3 which is the last element of the array so

array[1] = 3  

This means that 3 becomes the second element of array now.

array[size - i - 1] = temp  

As the value in temp was set to 2 so  

array[4-1-1] = 2  

This means 2 is assigned to the 2nd index of array. Which means 2 becomes the second last element of the array now.

This is how the second and second to last elements of array are swapped.  

3rd iteration: value of i=2 The for loop body will not execute now as the for loop condition i<size-2 evaluates to false because 2=2. So the loop stops and next for (j = 0; j < size; j++) loop iterates through array[] which has now been reversed and print the elements of this reversed array.

Next the main() method passes length of the array and the array elements to the   reverse function and prints these elements in reverse.  

The output is:

4  3 2  1  

The program and output according to the example 2,5,9,7 given in the question is attached as a screenshot.

3 0
1 year ago
Earlier in the day, you created a user account for Brenda Cassini (bcassini). When she tries to log in, she can't. You realize t
kolezko [41]

Answer:

idk

Explanation:

how bout idk maybe ask ur teacher dont be afraid to ask thats what they're there for

just saying not tryna be rude or anything

7 0
2 years ago
Read 2 more answers
There are two methods of enforcing the rule that only one device can transmit. In the centralized method, one station is in cont
Levart [38]

Answer:

In centralized method, the authorized sender is known, but the transmission line is dominated by the control station, while in decentralized method, one station can not dominate the line but collision on the transmission line may occur.

Explanation:

Centralized method of communication requires for a control station to manage the activities if other stations in the network. It assigns turns to one known station at a time, for transmission.

Decentralized method allows stations in a network to negotiate and take turns in transmitting data. When a station is done with the transmission line, another station on the queue immediately claims the line.

3 0
2 years ago
Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
Varvara68 [4.7K]

Answer:

Explanation:

Farmers are always both directly and indirectly connected to each other

Their network is mostly strong

Networks become weak only on the edges (ends) of the river but doesn't completely dimnish

With the available network length, the center of river bank forms the strongest network of all and becomes a key player in defining the balance property of overall network

The network is very well structurally balanced and we can see that through the below image

20 miles 10 20 30 40 50

See attachment file for diagram

Considering the total length of river as 50miles and and the center of the whole length will be at 25th mile. From that point, if we consider a farmer will be be having friends for a length of 20miles both along upstream and downstream.

By this he'll be in friend with people who are around 80% of the total population. As me move from this point the integrity increases and this results in a highly balanced structural network.

6 0
1 year ago
Other questions:
  • Computer design software requires __________________ to be used properly and successfully by architects.
    9·2 answers
  • When a typeface does not have any extra embellishments on the top and bottom of the letterforms, it is called a ________ font?
    12·1 answer
  • The process of __________ encourages members to accept responsibility for the outcomes of a group and for changing the style in
    8·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • Timing circuits are a crucial component of VLSI chips. Here’s a simple model of such a timing circuit. Consider a complete balan
    10·1 answer
  • An entrepreneur is opening a computer store in a small town and wants to display a few laptops in the store, but is concerned ab
    11·2 answers
  • Ld' is the instruction with the longest latency on the CPU from Section 4.4 (in RISC-V text). If we modified ld and sd so that t
    15·1 answer
  • Information systems cannot solve some business problems. Give three examples and explain why technology cannot help.
    11·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!