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
Katarina [22]
2 years 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:
Sati [7]2 years 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 + int((in1+in2)/12)

totalin= (in1+in2) % 12

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

9966 [12]2 years ago
4 0

Answer:

This is written using Python 3:

<em />

<em>fft = input("How many feet for Fabric A? ") </em>

<em>fin = input("How many inches for Fabric A? ") </em>

<em>sft = input("How many feet for Fabric B? ") </em>

<em>sin = input("How many inches for Fabric B? ")</em>

<em> </em>

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

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

<em />

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

<em />

Explanation:

First is to declare the variables:

  • fft - stands for First Feet
  • fin - stands for First Inches
  • sft - stands for Second Feet
  • sin - stands for Second Inches

Then we ask the user to input a value by using:

  • input()

By using this, you can add a label inside ( and ) to provide guidance to the user. As such, I wrote "How many feet for Fabric A?"

After which, we print the answers for Fabric A and B.

  • print("TEXT HERE") - this is the simplest way to print a string. If you want to print an integer or variables, you don't have to include the quotation marks.

But what if you want to print both string and variables on the same line?

In which case, you can write it this way:

  • print("TEXT HERE", VARIABLE)

What this does is it concatenates the string and the variable in one go. After the quotation marks, simply add a comma right after. There are other ways of doing this but this is the most straightforward answer.

Now, repeat the process to print the entire sentence:

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

Important Note:

If you need to do calculations (+, *, /, -, %) it is important to convert the inputs into integers or floats. Using the answer above:

  • fft = input("How many feet for Fabric A? ")  - the value entered here is only considered as a string.
  • fft = int(input("How many feet for Fabric A? ") ) - meanwhile, by enclosing input() inside int(), this effectively becomes an integer. You may also use float() when necessary.
  • In which case, you can add, subtract, multiply, and divide the variables.
You might be interested in
Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The
marin [14]

Answer:

Following are the program in the Python Programming Language

#set variable to input sentence to replace words

sen = input()

#split that sentence

sen = sen.split()

#set variable to input whole sentence

get = input()

#set the for loop to replace words

for i in range(0, len(sen), 2):

 #check condition when words of sen is in get

 if sen[i] in get:

   #then, replace words

   get = get.replace(sen[i], sen[i+1])

#print the whole string after replacing

print('\n',get)

Explanation:

<u>Following are the description of the program</u>.

  • Set a variable 'sen' that get a sentence for replacing the word.
  • Split that sentence by split() method and again store that sentence in the following variable.
  • Set a variable 'get' that gets the whole sentence from the user.
  • Set the for loop for replacing words then, set the if conditional statement that checks the condition that the variable 'sen' in the variable 'get' then replace the words.
  • Finally, print the whole sentence after the replacement.
4 0
2 years ago
Which of the following is NOT a benefit of virtual memory? speed up of process creation increases in the effective access time o
lubasha [3.4K]

Answer:

speed up of process creation increases in the effective access time of memory

Explanation:

Virtual memories are often used in order to save up ram for other applications and not being limited by the actual physical memory that we have, in this case the virtual memory is slower than normal memories since they are not actual memories and are restricted to the spee of the connection or the speed of the disk where they are located.

8 0
2 years ago
Define a structure type auto_t to represent an automobile. Include components for the make and model (strings), the odometer rea
yulyashka [42]

Answer:

see explaination

Explanation:

#include <stdio.h>

#include <string.h>

#define BUFSIZE 1000

struct auto_t scan_auto(char *);

struct date_t {

char day[2];

char month[2];

char year[4];

};

struct tank_t {

char tankCapacity[10];

char currentFuelLevel[10];

};

struct auto_t {

char make[50];

char model[50];

char odometerReading[10];

struct date_t manufactureDate;

struct date_t purchaseDate;

struct tank_t gasTank;

};

int main(int argc, char *argv[]) {

/* the first command-line parameter is in argv[1]

(arg[0] is the name of the program) */

FILE *fp = fopen(argv[1], "r"); /* "r" = open for reading */

char buff[BUFSIZE]; /* a buffer to hold what you read in */

struct auto_t newAuto;

/* read in one line, up to BUFSIZE-1 in length */

while(fgets(buff, BUFSIZE - 1, fp) != NULL)

{

/* buff has one line of the file, do with it what you will... */

newAuto = scan_auto(buff);

printf("%s\n", newAuto.make);

}

fclose(fp); /* close the file */

}

struct auto_t scan_auto(char *line) {

int spacesCount = 0;

int i, endOfMake, endOfModel, endOfOdometer;

for (i = 0; i < sizeof(line); i++) {

if (line[i] == ' ') {

spacesCount++;

if (spacesCount == 1) {

endOfMake = i;

}

else if (spacesCount == 2) {

endOfModel = i;

}

else if (spacesCount == 3) {

endOfOdometer = i;

}

}

}

struct auto_t newAuto;

int count = 0;

for (i = 0; i < endOfMake; i++) {

newAuto.make[count++] = line[i];

}

newAuto.make[count] = '\0';

count = 0;

for (i = endOfMake+1; i < endOfModel; i++) {

newAuto.model[count++] = line[i];

}

newAuto.model[count] = '\0';

count = 0;

for (i = endOfModel+1; i < endOfOdometer; i++) {

newAuto.odometerReading[count++] = line[i];

}

newAuto.odometerReading[count] = '\0';

return newAuto;

}

8 0
2 years ago
Becky is preparing a document for her environmental studies project. She wants to check her document for spelling and grammar er
Sunny_sXe [5.5K]
If it's MS Word (it probably is), then it's Alt + F7
7 0
2 years ago
Read 2 more answers
Suppose you are given an unknown chip which could be any one of the of the following: 7400, 7402, 7404, 7408, 7410, 7420, 7427,
Olenka [21]

The answer & explanation for this question is given in the attachment below.

3 0
2 years ago
Other questions:
  • Lukas entered the date 9-17-2013 in an Excel workbook. He wants the date to appears as “Tuesday, September 17, 2013.” Instead of
    12·1 answer
  • You have been tracking your exercise routine, which involves running, lifting weights, yoga, and stretching. You want to see wha
    15·2 answers
  • Joe runs a handyman service. He enjoys writing and keeping up on the latest trends. He wants to share this information with his
    7·1 answer
  • c++ Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is c
    14·2 answers
  • Consider the following code: x = 17 y = 5 print (x % y) What is output?
    10·1 answer
  • You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember there
    15·1 answer
  • Collaboration online increases students' motivation by
    5·2 answers
  • You decide to buy some stocks for a certain price and then sell them at anotherprice. Write a program that determines whether or
    11·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • (Java) Which of the following code segments correctly declare a Strings and gives it a value of "fortran".
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!