1answer.
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
Rom4ik [11]
3 years ago
14

Question 29: Returns a string based on input string The function below takes a single string parameter: input_string. If the inp

ut contains the lowercase letter z, return the string 'has the letter z'. Otherwise, return the string 'not worthwhile'. contain.py 1. def string contains(input_string): Que Best s Availat Awarde Restore original file Save & Grade Save only Atta No attach Attacha Attache
Engineering
1 answer:
kirill [66]3 years ago
8 0

Answer:

Two Python codes are explained for the problem. Modify as appropriate

Explanation:

<u>CODE 1:</u>

def string_contains(input_string): # called function

if(input_string.__contains__('z')): # Check input_string contains 'z'

print('has the letter z.') # print input_string contains 'z'

else:

print('not worthwhile.') # print if input_string not contains 'z'

input_string = input('Please enter the string: ') # ACeept string from user

string_contains(input_string) # calling function where we pass input_string as actual parameter

<u>CODE 2:</u>

def string_contains(input_string):

   for x in input_string:

       if x=='z':

           return 'has the letter z'

   return 'not worthwhile'

You might be interested in
The number of weaving errors in a twenty-foot by ten-foot roll of carpet has a mean of 0.8 What is the probability of observing
Viktor [21]

Answer:

0.14% probability of observing more than 4 errors in the carpet

Explanation:

When we only have the mean, we use the Poisson distribution.

In a Poisson distribution, the probability that X represents the number of successes of a random variable is given by the following formula:

P(X = x) = \frac{e^{-\mu}*\mu^{x}}{(x)!}

In which

x is the number of sucesses

e = 2.71828 is the Euler number

\mu is the mean in the given interval.

The number of weaving errors in a twenty-foot by ten-foot roll of carpet has a mean of 0.8.

This means that \mu = 0.8

What is the probability of observing more than 4 errors in the carpet

Either we observe 4 or less errors, or we observe more than 4. The sum of the probabilities of these outcomes is 1. So

P(X \leq 4) + P(X > 4) = 1

We want P(X > 4). Then

P(X > 4) = 1 - P(X \leq 4)

In which

P(X \leq 4) = P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4)

P(X = x) = \frac{e^{-\mu}*\mu^{x}}{(x)!}

P(X = 0) = \frac{e^{-0.8}*(0.8)^{0}}{(0)!} = 0.4493

P(X = 1) = \frac{e^{-0.8}*(0.8)^{1}}{(1)!} = 0.3595

P(X = 2) = \frac{e^{-0.8}*(0.8)^{2}}{(2)!} = 0.1438

P(X = 3) = \frac{e^{-0.8}*(0.8)^{3}}{(3)!} = 0.0383

P(X = 4) = \frac{e^{-0.8}*(0.8)^{4}}{(4)!} = 0.0077

P(X \leq 4) = P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) = 0.4493 + 0.3595 + 0.1438 + 0.0383 + 0.0077 = 0.9986

P(X > 4) = 1 - P(X \leq 4) = 1 - 0.9986 = 0.0014

0.14% probability of observing more than 4 errors in the carpet

5 0
3 years ago
At the instant shown, slider block B is moving with a constant acceleration, and its speed is 150 mm/s. Knowing that after slide
Xelga [282]

Answer:

a) aA = - 13.33 mm/s²

aB = - 20 mm/s²

b) aD = - 13.33 mm/s²

c) vB = 70 mm/s

d) xB = 440 mm

Explanation:

Given

The initial speed of B is: v₀B = 150 mm/s

Distance moved by A is: xA = 240 mm

Velocity of A is: vA = 60 mm/s

Assuming:

Displacement of blocks are denoted by:

A = xA

B = xB

C = xC

D = xD

From the pic shown, the total length of the cable is:

xB + (xB - xA) + 2*(d - xA) = L

⇒ 2*xB - 3*xA = L - 2*d

where L - 2*d is constant. Differentiating the above equation with respect to time:

d(2*xB)/dt - d(3*xA)/dt = 0

⇒ 2*vB - 3*vA = 0    (i)

Substituting in equation (i)

2*(150 mm/s) - 3*vA = 0

⇒ v₀A = 100 mm/s  (initial speed of A)

Then, we use the equation

vA² = v₀A² + 2*aA*xA

Substituting the values in above equation:

(60 mm/s)² = (100 mm/s)² + 2*aA*(240 mm)

⇒ aA = - 13.33 mm/s²

If  2*vB - 3*vA = 0

Differentiating the above equation with respect to time:

d(2*vB)/dt - d(3*vA)/dt = 0

⇒ 2*aB - 3*aA = 0    (ii)

Substituting in equation (ii)

2*aB - 3*(- 13.33 mm/s²) = 0

⇒ aB = - 20 mm/s²

b) From the pic shown,

xD - xA = constant

If we apply

d(xD)/dt - d(xA)/dt = 0

⇒ vD - vA = 0

then

d(vD)/dt - d(vA)/dt = 0

⇒ aD - aA = 0

⇒ aD = aA = - 13.33 mm/s²

c) We use the formula

vB = v₀B + aB*t

Substituting the values in above equation:

vB = 150 mm/s + (- 20 mm/s²)*(4 s)

⇒ vB = 70 mm/s

d) We apply the equation

xB = v₀B*t + 0.5*aB*t²

Substituting the values in above equation:

xB = (150 mm/s)*(4 s) + 0.5*(- 20 mm/s²)*(4 s)²

⇒ xB = 440 mm

4 0
3 years ago
Que es resistencia ?
IRINA_888 [86]
It is when you don’t give up and you stand for your rights
5 0
3 years ago
5) /
Tpy6a [65]

Answer:

I don't understand...

4 0
3 years ago
Consider two different versions of algorithm for finding gcd of two numbers (as given below), Estimate how many times faster it
juin [17]

Answer:

Explanation:

Step 1:

a) The formula for compute greatest advisor is

     gcd(m,n) = gcd (n,m mod n)

the gcd(31415,14142) by applying Euclid's algorithm is

    gcd(31,415,14,142) =gcd(14,142,3,131)

                                  =gcd=(3,131, 1,618)

                                   =gcd(1,618, 1,513)

                                   =gcd(1,513, 105)

                                   =gcd(105, 43)

                                    =gcd(43, 19)

                                     =gcd(19, 5)

                                      =gcd(5, 4)

                                      =gcd(4, 1)

                                      =gcd(1, 0)

                                      =1

STEP 2

b)  The number of comparison of given input with the algorithm based on  checking consecutive integers and Euclid's algorithm is

     The number of division using Euclid's algorithm =10 from part (a)

      The consecutive integer checking algorithm:

      The number of iterations =14,142 and 1 or 2 division of iteration.

        14,142 ∠= number of division∠ = 2*14,142

         Euclid's algorithm is faster by at least 14,142/10 =1400 times

          At most 2*14,142/10 =2800 times.

5 0
3 years ago
Other questions:
  • The uniform dresser has a weight of 90 lb and rests on a tile floor for which the coefficient of static friction is 0.25. If the
    6·1 answer
  • If there are 16 signal combinations (states) and a baud rate (number of signals/second) of 8000/second, how many bps could I sen
    7·1 answer
  • More discussion about seriesConnect(Ohm) function In your main(), first, construct the first circuit object, called ckt1, using
    10·1 answer
  • A soil has the following Green-Ampt parameters Effective porosity 0.400 Initial volumetric moisture content-15% Hydraulic Conduc
    6·1 answer
  • An 80 kg man descends to the ground from an aeroplane using a parachute. If the drag coefficient of the parachute is 0.5 and the
    12·1 answer
  • Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    15·1 answer
  • which acpi power state allows a system to start where it left off, but all other components are turned off? sleeping mechanical
    13·1 answer
  • What is the placement of a lock out device on an energy isolating device?.
    12·1 answer
  • What is chemical engieering ?​
    9·1 answer
  • Which of the following situations best describes student engaged in active learning
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!