# Write a Python program that uses the code provided in the…

# Write a Python program that uses the code provided in the main() function to drive the program.# Do NOT change the code in main(). # Copy all of these comments and provided code to PyCharm# Make sure to submit ALL of your code when you are done.# Scenario: You are writing a script to track contestant performance on a comedy game show.# Code the following functions using the pseudocode to guide you:# 1. get_task_times()#     This function doesn’t relate to the other functions; it’s self-contained.#     This function prompts for 5 task completion times (in seconds) to fill a list with integers.#     You do not need to validate that the time is in any particular range.#     Find the average of the times *with the highest (slowest) one dropped*.#     Print the average to the console, to two decimals of precision.#     This function is called from main and returns nothing.# 2. get_contestant_name()#     This function takes no parameters and returns a string.#     Request a string from the user to be used for the contestant’s name.# 3. get_task_scores()#     This function takes no parameters and returns a list of integers 1 to 5 (inclusive).#     Ask the user to enter a list of scores awarded for different tasks, and to enter “Finish” when done.#     Do not allow them to enter anything outside the bounds of 1 to 5.#     The function returns these numbers in the list.# 4. print_score_board(name, scores)#     This function takes a string (the contestant name) and a list of integers as parameters.#     Print the contestant’s name and a histogram using the list of integers as data.#     Each value in the list is the number of hash symbols (a hash and then a space) to print on that line.#     Each element in the list is a separate line in the graph representing a task score.def main():    get_task_times()    contestant = get_contestant_name()    points = get_task_scores()    print_score_board(contestant, points)main() Sample run Enter a task completion time (in seconds): 45Enter a task completion time (in seconds): 50Enter a task completion time (in seconds): 42Enter a task completion time (in seconds): 120Enter a task completion time (in seconds): 48Average time with the slowest attempt dropped is: 46.25Enter the contestant’s name: Greg DaviesEnter a score between 1 and 5; enter Finish to stop: 4Enter a score between 1 and 5; enter Finish to stop: 5Enter a score between 1 and 5; enter Finish to stop: 0ERROR: Score must be between 1 and 5Enter a score between 1 and 5; enter Finish to stop: 1Enter a score between 1 and 5; enter Finish to stop: 6ERROR: Score must be between 1 and 5Enter a score between 1 and 5; enter Finish to stop: 3Enter a score between 1 and 5; enter Finish to stop: FinishContestant: Greg Davies# # # # # # # # # # # # #

Solve the system of nonlinear equation.  The answer:  (x,y)…

Solve the system of nonlinear equation.  The answer:  (x,y)=[c1] (x,y)=[c2]   If the answer of a linear system is (2, -3) and (-5, 4),  please type ordered pairs (x,y)  with the order from the smallest x value to the largest, for example: (x,y)=(-5,4) (x,y)=(2,-3)      (with comma and no space)  

Question 1 Economic dispatch: A power system includes two ge…

Question 1 Economic dispatch: A power system includes two generators serving load demand \(d=1\) per unit (pu). Their generation costs and limits (in pu and \$/pu) are shown below:\begin{align*}c_1(p_1)&=300p_1^2+200p_1, &&\underline{p}_1=0,~\bar{p}_1=0.9.\\c_2(p_2)&=200p_2^2+300p_2, &&\underline{p}_2=0,~\bar{p}_2=0.8.\end{align*} (a) Formulate the economic dispatch and find the optimal generation dispatch. (b) What is the price of electricity for this system? Calculate the net gain for each generator. (c) How much money does the independent system operator (ISO) collect from the load, and how much money does the ISO distribute to GENs? (d) Compute the participation factors for the two generators.   Question 2 Power flow: Consider the 3-bus power system shown below. Line impedances are given as \(x_{12}=0.2\) and \(x_{23}=x_{31}=0.1\) pu. Bus 1 is set as the reference and slack bus and we adopt the linearized (DC) PF model. (a) Find matrices \(\mathbf{X}\), \(\mathbf{A}\), \(\mathbf{B}\) and the reduced matrix \(\mathbf{B}_r\), involved in the DC-PF model.  (b) The vectors of power flows \(\mathbf{f}\) and power injections \(\mathbf{p}\) are related as\[\left[\begin{array}{c}f_{12}\\f_{23}\\f_{31}\end{array}\right]=\mathbf{S}\left[\begin{array}{c}p_{1}\\p_{2}\\p_{3}\end{array}\right]\quad \quad \text{where}\quad \quad\mathbf{S}=\left[\begin{array}{ccc}0 & -0.5 & -0.25\\0 & +0.5 & -0.25\\0 & +0.5 & +0.75\end{array}\right].\] Find the bus voltage angles for injections \(\mathbf{p}=[+0.7~+0.3~-1]^\top\). Question 3 Network-constrained optimal power flow: Using the generation/load data of Q1) and the network data of Q2), the ISO solves a DC-OPF. Line capacities are given as \(\bar{f}_{12}=0.4\),  \(\bar{f}_{23}=0.4\), and \(\bar{f}_{31}=0.8\) pu. The optimal dispatch is \(\mathbf{p}=[+0.7~+0.3~-1.0]^\top\). The marginal energy component is $620. Among the three lines, line \((2,3)\) gets congested and reaches its upper limit. The corresponding Lagrange multiplier is $400. (a) Find the vector \(\boldsymbol{\pi}\) of locational marginal prices at all buses. (b) How much money does the ISO pay each generator? How much money does the ISO collect from the load? Calculate the congestion surplus. Question 4 Contingency analysis: For the system of Q3) and power injections \(\mathbf{p}=[+0.7~+0.3~-1.0]^\top\), find the post-contingency flow on line \((2,3)\) if line \((3,1)\) trips.  Is the system in this post-contingency state secure? Question 5 For each of the following statements related to the (lossless) DC-OPF model, mark if they are true or false: (a) Building more transmission lines can only decrease the total generation cost.  (b) Building more generators can only decrease the total generation cost. (c) LMPs are equal across all buses only if there is no congestion. (d) The power injections obtained from the DC-OPF are also feasible for the AC-OPF. (e) The corrective security-constrained SC-DC-OPF yields a lower total generation cost compared to the preventive SC-DC-OPF. (f) The corrective SC-DC-OPF may yield lower total generation cost compared to the plain DC-OPF. Question 6 Unit commitment: The generators of Q1) are given the price of $500/pu to generate power for the next hour. (a) If GEN1 is currently off and its start-up cost is $50, what would be the self-dispatch for GEN1? (b) If GEN2 is currently off and its start-up cost is $100, what would be the self-dispatch for GEN2? Congratulations, you are almost done with this exam.  DO NOT end the Honorlock session until you have submitted your work to Brightspace.  When you have answered all questions:  Use your smartphone to scan your answer sheet and save the scan as a PDF. Make sure your scan is clear and legible.  Submit your PDF as follows: Email your PDF to yourself or save it to the cloud (Google Drive, etc.).  Click this link to go to submit your work: Midterm exam Return to this window and click the button below to agree to the honor statement. Click Submit Quiz to end the exam.  End the Honorlock session.