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
snow_lady
2 months ago
7

2.3 Code Practice: Question 2 Write a program that inputs the length of two pieces of fabric in feet and inches (as whole number

s) and prints the total.
Computers and Technology
2 answers:
Natasha_Volkova [1K]2 months ago
8 0

Answer:

ft1 = int(input("Enter the Feet: "))

in1 = int(input("Enter the Inches: "))

ft2 = int(input("Enter the Feet: "))

in2 = int(input("Enter the Inches: "))

totalft = ft1 + ft2 + (in1 + in2) // 12

totalin = (in1 + in2) % 12

print("Feet: " + str(totalft) + " Inches: " + str(totalin))

8_murik_8 [964]2 months ago
4 0

Answer:

This example is implemented in Python 3:

fft = input("How many feet for Fabric A? ")

fin = input("How many inches for Fabric A? ")

sft = input("How many feet for Fabric B? ")

sin = input("How many inches for Fabric B? ")

print("Length for Fabric A is:", fft, "feet and", fin, "inches")

print("Length for Fabric B is:", sft, "feet and", sin, "inches")

INPUT:

How many feet for Fabric A? 5

How many inches for Fabric A? 5

How many feet for Fabric B? 1

How many inches for Fabric B? 1

OUTPUT:

Length for Fabric A is: 5 feet and 5 inches

Length for Fabric B is: 1 feet and 1 inches

Explanation:

To begin, define variables as follows:

  • fft - represents the first fabric's feet
  • fin - represents the first fabric's inches
  • sft - represents the second fabric's feet
  • sin - represents the second fabric's inches

Then, prompt the user for input using:

  • input()

This function allows a prompt within the parentheses to guide user input. For example, "How many feet for Fabric A?"

After gathering the input, output the lengths of Fabrics A and B.

  • print("TEXT HERE") - used for displaying a string. For numbers or variables, avoid surrounding them with quotes.

What if you want to combine strings and variables in one print statement?

Use this syntax:

  • print("TEXT HERE", VARIABLE)

This merges the text and the variable within a single print call by placing a comma after the string.

Repeat this format to compose an entire sentence:

  • print("TEXT 1:", VARIABLE1, "TEXT 2", VARIABLE2)

Important Note:

To perform arithmetic operations (+, -, *, /, %) on inputs, convert them to integers or floats. For example:

  • fft = input("How many feet for Fabric A? ") - this input is a string.
  • fft = int(input("How many feet for Fabric A? ")) - wrapping input() inside int() converts it to an integer. Alternatively, use float() if needed.
  • Once converted, you can apply addition, subtraction, multiplication, and division on the variables.
You might be interested in
The engineering firm you work for is submitting a proposal to create an amphitheater at a state park. Proposals must be submitte
Rzqust [1037]
Accessibility is defined as the availability of data to individuals and resources that may have disabilities regarding access, in the context of technical communication. Various regulations exist to create accessible documentation. Section divider tabs and indexes are included in every proposal binder, ensuring every member can understand the proposal's content. Thus, all individuals can access the three-ring binder to gain information about the amphitheater's creation.
8 0
1 month ago
Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
ivann1987 [1066]
Trojan horse. They arrive disguised.
8 0
1 month ago
A colleague asks you to research a CPU for a new server that will run Windows Server 2019. He explains the server roles that he
Rzqust [1037]

Response:

a

Explanation:

I’m just guessing

3 0
18 days ago
When long labels are required, which of these commands can you use to improve readability of a worksheet?
maria [1035]
I think it's text wrapping! I hope this assists you.
6 0
1 month ago
Read 2 more answers
Widget Corp. wants to shift its list of inventory to a cloud so that its different branches can access it easily. The company ne
oksian1 [950]
The most suitable cloud option for Widget Corp, which requires a solution that is both cost-effective and does not risk exposing critical applications and data externally, is a hybrid cloud.
5 0
1 month ago
Other questions:
  • 6. Write pseudo code that will perform the following. a) Read in 5 separate numbers. b) Calculate the average of the five number
    6·1 answer
  • What are the 2 things you are not sure about evaluating functions​
    7·2 answers
  • Which of the following is true of how computers represent numbers?
    9·2 answers
  • To finish creating a design for the webpage, use one shape to cut away part of the other. Create a 700 pixel by 700 pixel square
    10·1 answer
  • What are the set of rules to move data from one computer to another?
    11·1 answer
  • What statement best describes Konrad Zuse?
    6·2 answers
  • Write a function in the cell below that iterates through the words in file_contents, removes punctuation, and counts the frequen
    6·1 answer
  • #Write a function called random_marks. random_marks should #take three parameters, all integers. It should return a #string. # #
    10·1 answer
  • The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
    5·1 answer
  • Huan wants to enter the science fair at his school. He has a list of ideas for his project. Which questions could be answered th
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!