Complete the function asn

Assignment Help Basic Computer Science
Reference no: EM132264022

1. Complete the function asn2_1() so it prints the string that is passed to it as a parameter.

2. Modify and complete the function asn2_2() so it accepts one parameter-a list of numbers-and returns the average (rounded to 2 decimal places) of the numbers in the list. For full credit, use a loop to calculate the average of the numbers in the list.

3. Add a new function, asn2_3(), that draws a rectangle. The function should take five parameters: a turtle, the length of the horizontal side, the length of the vertical side, the x location of the bottom left corner, and the y location of the bottom left corner.

4. Complete the function main() to do the following:

a. Prompt the user for a string then call asn2_1() with that string as the argument; print the string in asn2_1().

b. You are given two lists, num1 and num2. Use asn2_2() to calculate their averages, then print those averages (calculate the average of each list using asn2_2() but print them in main()).

c. Use asn2_3() to draw different-sized rectangles at locations (-150, 150), (-150, -150), (150, 150), (150, -150)

import turtle

def asn2_1(s):

  '''Prints string s'''

  pass #This statement does nothing - you can delete it or leave it

def asn2_2():

  '''

  Add a parameter - that parameter will be a list of numbers

  Return the average of the list

  '''

  pass #This statement does nothing - you can delete it or leave it

#Add function asn2_3() to draw rectangles

  '''

  asn2_3 takes the following parameters:

   a turtle and 4 integers; the integers are

   the length of horizontal side, the length of vertical side,

   x position of lower left corner, y position of lower left corner

  '''

def main():

  #Get a string from the user; use asn2_1() to print it

  nums1 = [17, 12, 42, 11, 19] #This list will be sent to asn2_2()

  nums2 = [110, 212, 411, 256, 119, 57, 98] #This will be sent to asn2_2()

  #Get the average of nums1 by sending it to asn2_2()

  #Print the average of nums1

  #Get the average of nums2 by sending it to asn2_2()

  #Print the average of nums2

  wn = turtle.Screen()

  jacinda = turtle.Turtle()

  #Use asn2_3() to draw four rectangles, using jacinda, as...

  #...specified in the specs

main()

Reference no: EM132264022

Questions Cloud

Context switch operations are instantaneous : Fill in the Gant chart based on these conditions: (P, V, and context switch operations are instantaneous).
Is the united nations necessary : Is the United Nations necessary? If it is, what should be changed or reformed to make it more effective, or do any changes need to be made at all?
Pivot chart and a line chart : What are the differences between a Pivot Chart and a Line Chart?
In which respect does iraq have very shallow roots : Explain how this feature has constituted an obstacle to the country's political and economic development?
Complete the function asn : 1. Complete the function asn2_1() so it prints the string that is passed to it as a parameter.
What can he or she share about workplace politics : What does the Leader do to maintain relationships with stakeholders? What can he/she share about workplace politics?
Prepare a bank reconciliation statement for rana company : What is a bank reconciliation and why is it important for companies to do it periodically? Prepare a Bank Reconciliation Statement for Rana company that has.
Parameters needed in the goal seek section : What are the three parameters needed in the Goal Seek section of What-if Analysis? Explain each of them and what they do.
Conduct a swot analysis by analyzing the strengths : Conduct a SWOT analysis by analyzing the strengths, weaknesses, application opportunities, and threats from competitors of the chosen topic.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd