answer.
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
joja
2 months ago
15

NEEDS TO BE IN PYTHON:ISBN-13 is a new standard for indentifying books. It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13 . The la

st digit d13 is a checksum, which is calculated from the other digits using the following formula:10 - (d1 + 3*d2 + d3 + 3*d4 + d5 + 3*d6 + d7 + 3*d8 + d9 + 3*d10 + d11 + 3*d12) % 10If the checksum is 10, replace it with 0. Your program should read the input as a string. Display "incorrect input" if the input is incorrect.Sample Run 1Enter the first 12 digits of an ISBN-13 as a string: 978013213080The ISBN-13 number is 9780132130806Sample Run 2Enter the first 12 digits of an ISBN-13 as a string: 978013213079The ISBN-13 number is 9780132130790

Engineering
1 answer:
mote1985 [299]2 months ago
4 0

Answer:

Below is the code relevant to this question:

n=input("Enter the first 12 digits of an ISBN-13 as a string:")#this defines isbn as the input variable

if len(n)!=12: #this if statement checks if the input is 12 digits long

   print("incorrect input") #outputs an error message

elif n.isdigit()==False: #this else if statement checks if the input is all digits

   print("incorrect input") #outputs an error message

else:#defining the else block

   s=0 #initializes the integer variable s to 0

   for i in range(12):#a loop to sum the input digits

       if i%2==0: #checks if the index is even

           s=s+int(n[i])#adds even digits to s  

       else: #this else block handles odd indices

           s=s+int(n[i])*3 #adds odd digits multiplied by 3 to s

   s=s%10#calculates the remainder

   s=10-s#finds the complement of the remainder

   if s==10: #checks if s equals 10  

       s=0#sets s to zero if the condition is met

   n=n+s.__str__() #final output is generated

Output:

please find attached file.

Explanation:The Python code above uses the variable "n" to accept user input as a string and utilizes conditional statements to validate the input length and composition, as outlined below:

  • The if block verifies that the length is exactly 12; if it isn't, an error message will be displayed.
  • The else if block checks if the input is numeric; if it's not, an error notification is printed.
  • In the else block, a for loop computes the sum for even and odd index digits (with odd index digits being multiplied by 3), which are then added to the variable s.
  • Finally, the remainder is calculated and adjusted based on whether it equals 10; if true, a 0 is appended to n, or else, the calculated value is used.

You might be interested in
A technician has been dispatched to assist a sales person who cannot get his laptop to display through a projector. The technici
mote1985 [299]

Answer:Ensure the correct cable is connected between the laptop and the projector. Check for HDMI inputs or 15-pin video output interfaces.

Also, make sure the laptop is set to project to the correct display output.

Explanation:

7 0
2 months ago
Steam flows at steady state through a converging, insulated nozzle, 25 cm long and with an inlet diameter of 5 cm. At the nozzle
iogann1982 [368]

Answer:

The velocity at exit U_2 is 578.359 m/s

The exit diameter d_e is 1.4924 cm

Explanation:

Provided data includes:

Length of the nozzle L = 25 cm

Inlet diameter d_i = 5 cm

At the nozzle entrance (state 1): Temperature T_1 = 325 °C, Pressure P_1 = 700 kPa, Velocity U_1 = 30 m/s, Enthalpy H_1 = 3112.5 kJ/kg, Volume V_1 = 388.61 cm³/gAt the nozzle exit (state 2): Temperature T_2 = 250 °C, Pressure P_2 = 350 kPa, Velocity U_2, Enthalpy H_2 = 2945.7 kJ/kg, Volume V_2 = 667.75 cm³/g To determine:a. Exit Velocity U_2b. Exit Diameter d_e

a.The Energy Equation can be represented by:ΔH + ΔU² / 2 + gΔz = Q + WAssuming Q = W = Δz = 0Substituting the values yields:

(H_2 - H_1) + (U²_2 - U²_1)  / 2 = 0From which we can derive U_2 = sqrt((2* (H_1 - H_2 )) + U²_1) with the calculations leading to U_2 = sqrt ( 2 * 10^3 * (3112.5 -2945.7) + 900) yielding U_2 = 578.359 m/s

b.

Using mass balance approach, we have U_1 * A_1 / V_1 = U_2 * A_2 / V_2

Here, A = π*d² / 4

This leads to U_1 * d_i² / V_1 = U_2 * d_e² / V_2, thus d_e = d_i * sqrt((U_1 / U_2) * (V_2 / V_1)). Hence, d_e = 5 * sqrt((30 / 578.359) * (667.75 / 388.61)) computes to d_e = 1.4924 cm

6 0
2 months ago
8. When supplying heated air for a building, one often chooses to mix in some fresh outside air with air that has been heated fr
pantera1 [306]
Refer to the explanation for a detailed breakdown.
5 0
1 month ago
The critical resolved shear stress for iron is 27 MPa (4000 psi). Determine the maximum possible yield strength for a single cry
grin007 [323]

Answer:

The following represents the answer.

Explanation:

Calculation for the maximum yield strength of a single crystal of Fe subjected to tension can be found in the attached image.

The maximum yield strength value is 54 MPa.

7 0
3 months ago
Other questions:
  • Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    14·1 answer
  • On a given day, a barometer at the base of the Washington Monument reads 29.97 in. of mercury. What would the barometer reading
    6·1 answer
  • Write multiple if statements. If car_year is 1969 or earlier, print "Few safety features." If 1970 or later, print "Probably has
    12·1 answer
  • Soap is a very interesting chemical. We even discussed it on the discussion board. How does it work, exactly?
    7·1 answer
  • Consider a very long, slender rod. One end of the rod is attached to a base surface maintained at Tb, while the surface of the r
    8·1 answer
  • 4.68 Steam enters a turbine in a vapor power plant operating at steady state at 560°C, 80 bar, and exits as a saturated vapor at
    15·1 answer
  • A sequential circuit has two inputs, w1and w2, and an output, z. Its function is to compare the input sequences on the two input
    9·1 answer
  • A 10-ft-long simply supported laminated wood beam consists of eight 1.5-in. by 6-in. planks glued together to form a section 6 i
    5·1 answer
  • A solid steel shaft has to transmit 100 kW at 160 RPM. Taking allowable shear stress at 70 Mpa, find the suitable diameter of th
    15·1 answer
  • According to the EWR specifications, ___ is responsible for picking up and disposing of debris or rubbish from
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!