1. Write a Python function avgNum() that keeps prompting user to enter a positive number. Enter...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a Python function avgNum() that keeps prompting user to enter a positive number. Enter a non-positive number to terminate the loop. Calculate & display the average of all positive numbers. Call your function with testing example (25 pts) Test case: Enter a positive number: 10 Enter a positive number: 50 Enter a positive number: 30 Enter a positive number: 0 30.0 2. Write a function named sumSequence (n) that receives a positive integer n as the argument and calculates the sum of sequence 1, 3, 5, 7 ... n. (25 pts) Test case: print (sumSequence (5)) 9 3. Using nested loop to write a function named pattern (n) to print n rows of full pyramid patterns. Call your function with testing example. (25 pts) Test case: pattern (5) * * * * * * * * 4. Write a function named convertDays (days) that receives days as its input arguments and then return the number of (years, months, and days). Assuming there are 365 days per year and 30 days per month. Call your function with testing example. (25 pts) Test case: print(convertDays (2000)) (5, 5, 25) 1. Write a Python function avgNum() that keeps prompting user to enter a positive number. Enter a non-positive number to terminate the loop. Calculate & display the average of all positive numbers. Call your function with testing example (25 pts) Test case: Enter a positive number: 10 Enter a positive number: 50 Enter a positive number: 30 Enter a positive number: 0 30.0 2. Write a function named sumSequence (n) that receives a positive integer n as the argument and calculates the sum of sequence 1, 3, 5, 7 ... n. (25 pts) Test case: print (sumSequence (5)) 9 3. Using nested loop to write a function named pattern (n) to print n rows of full pyramid patterns. Call your function with testing example. (25 pts) Test case: pattern (5) * * * * * * * * 4. Write a function named convertDays (days) that receives days as its input arguments and then return the number of (years, months, and days). Assuming there are 365 days per year and 30 days per month. Call your function with testing example. (25 pts) Test case: print(convertDays (2000)) (5, 5, 25)
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Use the activities and precedence relations in Exhibit 8.13 to do the following: a. Draw a precedence diagram for this assembly line. b. Balance the assembly line for an eight-hour-shift output of 30...
-
The number of elements in the universal set, n(U), given n(x)=58 and n(X')=219, is
-
The park planners have decided to add basketball courts to the park. They have decide to place them between Archimedes Alley and the tobogganing hill. Each court will be a standard high school size,...
-
Suppose a country's productivity last year was 84. If this country's productivity growth rate of 5 percent is to be maintained, this means that this year's productivity will have to be: A. 88.2. B....
-
Find the volume of the largest circular cone that can be inscribed in a sphere of radius r.
-
List and detail the hardware and software requirements for a failover cluster. (Windows Server 2016)
-
What issues might arise during and as a result of the implementation of HRIS T&D applications?
-
Vice Oil received the following selected information from its pension plan trustee concerning the operation of the companys defined-benefit pension plan for the year ended December 31, 2014. The...
-
A scientific instrument that accurately measures the strength of adhesives (sticky tape). -Tape Adhesion strength testing . How it works: The stepper motor drives the probe vertically down and...
-
Sam Mc Kenzy is a founder and CEO of McKenzy Restaurants Inc., a regional company. Sam is considering opening several new restaurants. Sally Thorton, the company CFO has been put in charge of the...
-
Use any open source package, like openssl, to apply RSA considering the following scenario: Alice decides to use RSA with the public key N = P.Q. She designs the system by selecting two prime numbers...
-
Differentiate between tax evasion and tax avoidance.
-
What factors should you consider when deciding whether to refinance your mortgage to reduce the monthly payment? How can the refinancing decision be made?
-
Chris Ricci has several credit cards, on which she is carrying a total current balance of $12,500. She is considering transferring this balance to a new card issued by a local bank. The bank...
-
What are mortgage points? How much would a home buyer have to pay if the lender wanted to charge 2.5 points on a $125,000 mortgage? When would this amount have to be paid? What effect do points have...
-
Kathleen and Sean Madden have been notified that they are being audited. What should they do to prepare for the audit?
-
Write an equation of the line containing the given point and parallel to the given line. Express your answer in the form y = mx + b. (5,6); x + 4y = 7 The equation of the line is (Type an equation....
-
The swap spread is the difference between the swap rate and the equivalent-maturity Treasury bond yield. Explain why a widening swap spread may be a signal of deteriorating economic conditions. Plot...
-
Explain the purpose of an instance variable.
-
State whether each of the statements that follows is true or false. If false, explain why. a) Its possible to treat base-class objects and derived-class objects similarly. b) All methods in an...
-
Which of the following C# statements contain variables whose values are modified? a) p = i + j + k + 7; b) Console.WriteLine("variables whose values are modified"); c) Console.WriteLine("a = 5"); d)...
-
Using Mendels data from the experiment in Figure 2.8, conduct a chi square test to determine if the data agree with Mendels law of independent assortment. Mendels data: THE DATA P cross F1 generation...
-
On rare occasions, an organism may have three copies of a chromosome and therefore three copies of the genes on that chromosome (instead of the usual number of two copies). The alleles for each gene...
-
Outline the steps that occur when piRITS or piRISC silences transposable elements by repressing transcription and by directly inhibiting TE RNAs, respectively. What is the role of piRNAs in this...
Study smarter with the SolutionInn App