b. [10] What is the output of the following code? def partstring(astr, newstr = '' i...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
b. [10] What is the output of the following code? def partstring(astr, newstr = '' i = 0 while i < num: newstr=newstr+astr[i+2] i=i+1 return (newstr) print (partstring('1:NYCity', 2)) print (partstring('4: Houston', 3)) num): c. [10] Consider the following code def simple (a, b): tempa = 2*a b = 2*b d = tempa+b return d alpha = 11 beta = 7 delta simple (alpha, beta) print (alpha, beta, delta) print(a, b) For the two print statements in the code, state what will be printed. If an error will occur, state that and the reason for the error. i) print (alpha, beta, delta) ii) print (a, b) b. [10] What is the output of the following code? def partstring(astr, newstr = '' i = 0 while i < num: newstr=newstr+astr[i+2] i=i+1 return (newstr) print (partstring('1:NYCity', 2)) print (partstring('4: Houston', 3)) num): c. [10] Consider the following code def simple (a, b): tempa = 2*a b = 2*b d = tempa+b return d alpha = 11 beta = 7 delta simple (alpha, beta) print (alpha, beta, delta) print(a, b) For the two print statements in the code, state what will be printed. If an error will occur, state that and the reason for the error. i) print (alpha, beta, delta) ii) print (a, b)
Expert Answer:
Answer rating: 100% (QA)
Lets analyze the code provided For part b def partstringastr num newstr i 0 while i num newstr newst... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Describe, in detail, how the heapsort algorithm works. [10 marks] Show that the worst-case cost of heapsort is O(n log n). [6 marks] Would it be possible to implement a variant of heapsort based on a...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Walmart Stores has run into opposition when it has tried to open stores in certain towns in the United States. Walmarts capital budgeting process has determined that these locations would be...
-
What is the purpose of a partnership's obtaining life insurance policies on each of the partners?
-
In this problem, we ex.plore the use of small packets for Voice-over IP applications. One of the drawbacks of a small packet size is that a large fraction of link bandwidth is consumed by overhead...
-
What key elements should be included in a typical job description?
-
The Town of Thomaston has a Solid Waste Landfill Enterprise Fund with the following trial balance as of January 1, 2012, the first day of the fiscal year. During the year, the following transactions...
-
18 What is the GCD of the numerator and the denominator of -? 28 (Type an integer or a simplified fraction.)
-
The figure shows a ball with mass m = 0.398 kg attached to the end of a thin rod with length L = 0.667 m and negligible mass. The other end of the rod is pivoted so that the ball can move in a...
-
Fleet Foot Podiatry is a sole proprietorship clinic that is owned by Usain Bolt, who recently retired from running and became a podiatrist in Thunder Bay. They produce quarterly financial statements...
-
You work for a municipal park and recreation department. Your town has operated a recreation center and athletic complex near the center of town since its construction in 1963. The town is...
-
Presented below is the Income Statement of ABC Company. ABC is in its sixth year of operations. Gross Business Income - Philippines Cost of Sales - Philippines Selling and Administrative Expenses -...
-
What number of diluted weighted-average common shares outstanding was used by P&G in computing earnings per share for 2014, 2013, and 2012? (Round answers to millions upto 1 decimal places, e.g....
-
Hydrogen sulphide (a weak diprotic acid) is added to pure water at a concentration of 10- M. Assuming a temperature of 25 C and assuming ionic strength effects are negligible, determine the pH (to...
-
Let p , q , and r represent the ff statements: p : Chloe went to school. q : Her mom washed the dishes after dinner. r : Alfred made a surprise gift. Write the symbolic form of this statement:...
-
Marc Company assembles products from a group of interconnecting parts. The company produces some of the parts and buys some from outside vendors. The vendor for Part X has just increased its price by...
-
The transfer function of a LTI system is (a) Use the Laplace transform to find the unit-step response s(t) = (h x) (t). (b) Find the response due to the following inputs (i) x 1 (t) = u(t) u(t 1),...
-
The warping effect of the bilinear transformation also affects the phase of the transformed filter. Consider a filter with transfer function G(s) = e 5s . (a) Find the transformed discrete...
-
Consider the following problems related to the modulation and power properties of the Fourier transform. (a) The carrier of an AM system is cos(10t), consider the following message signals i. m(t) =...
-
Thermos flask is an example of ................ system.
-
In a ................, mass, momentum and energy may flow.
-
The thermodynamic properties which depend on the mass of the system are called ................ properties.
Study smarter with the SolutionInn App