Subtraction + Decision and Loop
This is a twist on the previous exercise that will help you review loops and decision structures. You will again ask the user to enter two numbers. However, you will ALWAYS subtract the smaller number from the larger number to ensure that you never get a negative number for an answer. You do this by checking the numbers and switching them if they are not in the right order (larger then smaller). All of this checking, switching, subtracting, and output of the answer should occur in a function.
((( THIS WAS THE PREVIOUS EXERCISE
Function Basics - Arguments and Parameters
This is another easy exercise to test your knowledge of the fundamentals. In main(), ask the user to enter two integers. Pass those two integers to a function that will subtract one number from another. This function must also output the answer to the user.
Output:
Enter two integers (separated by a space) and this program will subtract them: [user enters: 5 7]
5 - 7 = -2
Notes and Hints:
1) From now on, you must use a function prototype for all programs that use functions. Don't expect me to ask for it in each exercise. )))
Finally, ask the user if they would like to run the program again. By now, you should know exactly what type of loop to use.
Output:
Enter two integers (separated by a space) and this program will subtract the smaller from the larger: [user enters: 7 5]
7 - 5 = 2
Do you want to run this program again? [user enters: y]
Enter two integers (separated by a space) and this program will subtract the smaller from the larger: [user enters: 5 7]
7 - 5 = 2
Do you want to run this program again? [user enters: n]
Notes and Hints:
1) As always, make sure you accept an upper or lower case 'Y'

Answers

Answer 1

Answer:

In Python:

def subsmall(num1,num2):

   if num1 > num2:

       return num1 - num2

   else:

       return num2 - num1

   

repeat = True

while(repeat):

   num = input("Enter two integers: ")

   nums = num.split(" ")

   print(subsmall(int(nums[0]),int(nums[1])))

   runagain = input("Run program again? ").lower()

   if  runagain == "y":

       repeat=True

   else:

       repeat = False

Explanation:

The function begins here

def subsmall(num1,num2):

This subtracts num2 from num1 if num2 is smaller

   if num1 > num2:

       return num1 - num2

If otherwise, subtract num1 from num2

   else:

       return num2 - num1

The main begins here

This initialiazes a boolean variable to true    

repeat = True

This loop is repeated until the boolean variable is false

while(repeat):

Prompt to enter two integers

   num = input("Enter two integers: ")

Split the string by space

   nums = num.split(" ")

This passes the two integers to the function and also prints the differences

   print(subsmall(int(nums[0]),int(nums[1])))

Prompt to run the program again

   runagain = input("Run program again? ").lower()

If input is Y or y, the loop repeats

   if  runagain == "y":

       repeat=True

The program ends if otherwise

   else:

       repeat = False


Related Questions

Which entry by the user will cause the program to halt with an error statement?
#Get a guess from the user and update the number of guesses.
guess = input("Guess an integer from 1 to 10:")
guess = int(guess)

A two
B 100
C 3
D -1

Answers

Answer:

A

Explanation:

king(a. has eaten b.ate c.had eaten) when Airah called​

Answers

Answer:

c

Explanation:

king had eaten when Airah called


Please help meeee , you will get 20 points

Answers

Answer:

true

Explanation:

true trueee 3uehehehdgeyeyehhehehegegegrhrtggrevegrgrhehehru

I THINK IT FALSE

#Carry on learning

How can a user restore a message that was removed from the Deleted Items folder?


by dragging the item from Deleted Items to the Inbox

by dragging the item from Deleted Items to Restored Items

by clicking on "Recover items recently removed from this folder"

by clicking on the Restore button in the Navigation menu

Answers

Answer:

by clicking on "Recover items recently removed from this folder".

Answer:

c

Explanation:

Why each of the six problem-solving steps is important in developing the best solution for a problem

Answers

Answer:

The Answer is below

Explanation:

Each of the six problem-solving steps is important in developing the best solution for a problem because "each of these steps guarantees consistency, as every member of the project team understands the steps, methods, and techniques to be used."

For illustration, step one defines the problem to be solved.

Step two seek to find the main or underlying issue that is causing the problem

Step three: assist in drawing the alternative ways to solve the problem.

Step four: this is where to choose the most perfect solution to the problem

Step five is crucial as it involves carrying out the actual solution selected.

Step six is the step in which one check if the solution works fine or meets the intended plan.

Hence, all the steps are vital

Helllp me you will git 16 points

Answers

Answer:

False

Hope it helps...

Have a great day :P

Answer is false.................

paisa pay is facilitated in which e commerce website​

Answers

Answer:

The answer is "Option A".

Explanation:

The PaisaPay is the digital payment service of eBay, whereby buyers can pay sellers through credit card or Online Money Order. For quick, safe transactions or their cash back, their buyers must use PaisaPay. So, it is easier to go to eBay.co.in, was its digital payment service of eBay, whereby purchasers can charge vendors by credit card or Online Bank Transfer.

1. Define Primary Key. Why do we need primary key ?

2. Define Field size.

3. Define Validation Rule.

4. . Not leaving the house and a lack of exercise can cause health problems like obesity. TRUE OR FALSE

5. Rebecca only works 3 days in a week but she works longer hours each day to ensure she hits the 40-hour work week.
-art-time working
-Compressed hours
-Job sharing
-Flexible hour

Answers

Answer:

1 .The main purpose of primary key is to identify the uniqueness of a row, where as unique key is to prevent the duplicates, following are the main difference between primary key and unique key.

Explanation:

2. Field size means the dimensions along the major axes of an area in a plane perpendicular to the central axis of the useful beam of incident radiation at the normal treatment distance and defined by the intersection of the major axes and the 50 percent isodose line.

3.5.6 Introduce Yourself, Part 2


please hellllpp it keeps saying the code is wrong

Answers

Answer:

In Python:

name = "Arthur"

age = "62"

print("Hi! My name is "+name+" and I am "+age+" years old")

Explanation:

Given

See attachment

Required

Write a code to introduce yourself

Initialize name

name = "Arthur"

Initialize age

age = "62"

Print introduction

print("Hi! My name is "+name+" and I am "+age+" years old")

PLEASE HELP IM STUCK!!!!!!!!!!!!!!!!!!!!! Which of the following terms is described as "the art and design of using text”?
O typography
O elements of design
O typos
O graphic design

Answers

typography is the correct answer

You are asked to write a program that will display a letter that corresponds with a numeric rating system. The program should use a switch statement. The numeric rating is stored in a variable named rate and rate may equal 1, 2, 3, or 4. The corresponding letter is stored in a variable named grade and grade may be A, B, C, or D. Which is the test expression for this switch statement

Answers

The switch statements are similar to the if statements in a computer program

The test expression for the switch statement is the variable rate

How to determine the test expression

From the question, we have the following highlights

The program displays a corresponding letter of a rateThe rating is stored in the variable rate

This means that, the numerical value of the variable rate would be tested and the corresponding letter would be printed

Hence, the test expression for the switch statement is the variable rate

Read more about computer programs at:

https://brainly.com/question/16397886

Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum number of elements allowed). We studied two different ways to represent partially filled arrays: 1) using an int variable for the numElems and 2) using a terminating value to indicate the end of elements called the sentinel value. In the code below, please fill in the details for reading values into the latter type of array that uses a sentilnel value. Don't forget to complete the printArray function.
#include
using namespace std;
void printArray(int array[]);
// Implement printArray as defined with one array parameter
int main()
{
const int CAPACITY=21;
int array[CAPACITY]; // store positive/negative int values, using 0 to indicate the end of partially filled array
cout <<"Enter up to " << CAPACITY-1 << " non-zero integers, enter 0 to end when you are done\n";
//To do: Write a loop to read up the int values and store them into array a.
// Stop reading if the user enters 0 or the array a is full.
//To do: store 0 to indicate the end of values in the array
//Display array function
printArray(array);
return 0;
}
// To do: implement display for the given array
void printArray(int array[])
{
}

Answers

Answer:

Complete the main method as follows:

int num;

cin>>num;

int i = 0;

while(num!=0){

array[i] = num;  

cin>>num;

i++;

}

Complete the printArray function as follows:

void printArray(int array[]){

int i =0;

while(array[i]!=0){

   cout<<array[i]<<" ";

   i++;

}}

Explanation:

Main method

This declares a variable that gets input from the user

int num;

This gets input from the user

cin>>num;

This initializes a count variable to 0. It represents the index of the current array element

int i = 0;

while(num!=0){

This inserts the inputted number to the array

array[i] = num;

This gets another input  

cin>>num;

The counter is incremented by 1

i++;

}

The above loop is repeated until the users enters 0

printArray method

This declares the array

void printArray(int array[]){

This initializes a counter variable to 0

int i =0;

This is repeated until array element is 0

while(array[i]!=0){

Print array element

   cout<<array[i]<<" ";

Increase counter by 1

   i++;

}}

See attachment for complete program

function _one(array)
Create a JavaScript function that meets the following requirements:




Please give your function a descriptive name
o ( _one is not acceptable, and is only displayed here for illustration purposes)
Receives an array of integers as an argument
The function removes all duplicates (if they exist) from the array and returns it to the caller.
Assume the input array parameter will have at least one element in it.
Examples :
_one([33])
➔ [33]
_one([33, 33, 1, 4])
➔ [1, 4]
_one([33, 33, 1, 4, 1]) ➔ [4]​

Answers

Answer:

function removeRepeaters(list){

   var goodList = [], badList = {}, used = {}, n;

   // ensure that the argument is indeed an array

   if(!Array.isArray(list)){

        throw "removeRepeaters: Expecting one argument of type Array";

   }

   // loop through the array and take note of any duplicates

   for(n in list) used[list[n]] == true ? badList[list[n]] = true : used[list[n]] = true;

   // now loop through again, and assemble a list of non-duplicates

   for(n in list) if(badList[list[n]] == undefined) goodList[] = list[n];

   return goodList;

}

Explanation:

I assume you're familiar with trinary operators, but just in case, that's what's happening in this first for loop:

for(n in list) used[list[n]] == true ? badList[list[n]] = true : used[list[n]] = true;

this is the same as saying:

for(n in list){

   if(used[list[n]] == true){

       badList[list[n]] = true;

   } else {

       used[list[n]] = true;

   }

}

This loop flags all of the values in the list that are duplicated.  Note that both "badList" and "used" are declared as objects instead of arrays.  This allows us to compare keys in them with an == operator, even if they're not defined, making it a convenient way to flag things.

Note that I haven't tested it, so I may have overlooked something.  I suggest testing it before handing it in.

Write a Python program that asks the user for their name and then prints the name out in all uppercase and then in all lowercase letters. The output should look like this:

What is your name? Maria

Your name in all uppercase letters is: MARIA

Your name in all lowercase letters is: maria

Answers

Answer:

name = input("What is your name? ")

print("Your name in all uppercase letters is " + name.upper()

print("Your name in all lowercase letters is " + name.lower()

Explanation:

The first line takes in the user input and stores it in the variable name.

The second line concatinates the string with the variable name. Then to turn the string name to upper case i used the .upper() in built python method. and did the same thing with the .lower()

Answer:

print("What is your name?")

string = "Your name in Uppercase letters:MARIA"

print(string.upper())

string = "Your name in lowercase letters"

print(string.llower())

Which wizard is a tool provided by Access that is used to scan the table's structure for duplicate?

O Query Design Wizard
O Table Design Wizard
O Table Analyzer Wizard
O Performance Analyzer Wizard

Answers

Answer:

The tool provided by access that’s used to scan the table’s structure for duplicate is “Table Analyzer Wizard”.

Why is it important that you cite your sources?

Answers

Answer:

1. It gives credit to the authors/creators who's work you used.

2. Allows people who read your work a way find your sources if they want to learn more.

Consider we have n pointers that need to be swizzled, and swizzling one point will take time t on average. Suppose that if we swizzle all pointers automatically, we can perform the swizzling in half the time it would take to swizzle each separately. If the probability that a pointer in main memory will be followed at least once is p, for what values of p is it more efficient to swizzle automatically than on demand?

Answers

Answer:Considerwehavenpointers that need to be swizzled, and swizzling one point will take time t on average. Suppose that if we swizzle all pointers automatically, we can perform the swizzling in half the time it would take to swizzle each separately. If the probability that a pointer in main memory will be followed at least once is p, for what values of p is it more efficient to swizzle automatically than on demand?

Explanation:

PLZ HELP !!!!!
plzzzz

Answers

Answer:

Producers

Explanation:

Producers manufacture and provide goods and services to consumers.

Which of the following statements is true for DMA: (only one correct answer) A. In DMA, Processor checks status until the operation is complete B. In DMA, Processor is interrupted when I/O module ready to execute data C. In DMA, no interrupt is produced D. In DMA, interrupt is sent when the task is completed E. None of the above

Answers

Answer:

D. In DMA, interrupt is sent when the task is completed

Explanation:

Note, the term Direct Memory Access simply refers to a computer feature that allows hardware subsystems to directly access the main system memory of a computer, without any the aid of the central processing unit (CPU).

It is a fact that while the transfer process is ongoing, an interrupt (interrupt signal) is not sent until when the task is completed.

Can someone help me calculate this Multimedia math:

A monochrome sequence (black and white) uses a frame size of 176 x 144 pixels and has 8 bits/pixels. Registered with Frame Rate 10 frames/sec. Video is transmitted through a 64 Kbit/sec bandwidth line.
(a) Calculate Compression Ratio (Crude Bit Speed / Compressed Bit Speed) which will be needed.
(b) What will happen if the Ratio compression is higher than it in (a)?
(c) What will happen if the Ratio compression is lower than it in (a)?

Answers

Answer:

I will try to help you answer this. it seems really confusing but I'll do my best to solve it and get it back to you. Hope I'm able to help!

Deidre is studying for a history exam. She reads the chapter in her textbook that covers the material, then realizes she needs to learn the names, dates, and places mentioned in the reading.

Which note-taking tool will help Deidre quickly find the names, dates, and places later when it is time to review?

a sticky note
a highlighter
electronic notes
flash cards

Answers

Answer:

B: Highlighter

Explanation:

Just answered on edge, hope this helps

Answer: B) A Highlighter

Explanation:

please help
Consider the following code segment.

int a = 0;
int b = 3;

while ((b != 0) && ((a / b) >= 0)
{
a = a + 2;
b = b - 1;
}
What are the values of a and b after the while loop completes its execution?

a = 4, b = 1
a = 0, b = 3
a = 6, b = 0
a = 8, b = -1

Answers

Answer:

a = 6, b = 0

Explanation:

The loop ran 3 times before b == 0. The statement "while ((b != 0)" is essentially saying: 'While b is not equal to 0, do what's in my loop'. Same general thing with "&& ((a / b) >= 0)". The "&&" is specifying that there should be another loop condition. The final part of the while loop states: 'as long as a ÷ b is greater than 0, do what's in my loop'. If all of these conditions are met, the loop will run. It will continue to run until at least one of the conditions are not met.

Side note: I can't help but notice you posted the same question a while ago, so I just copied and pasted my previous response with some tweaking here and there. Hope this helps you! :)

KAILANGAN ANG MASIDHI AT MALAWAKANG PAGBABASA NA SIYANG MAKAPAGBUBUKAS NG DAAN SA LAHAT NG KARUNUNGAN AT DISIPLINA TULAD NG AGHAM PANLIPUNAN, SYENSYA, MATEMATIKA, PILOSOPIYA, SINING ATN IBA PA.”

Answers

Answer:

Oo, tama ka!

Brainiliest?

8.10 Code Practice: Question 2
Edhesive

Answers

Answer:vocab = ["Libraries", "Bandwidth", "Hierarchy", "Software", "Firewall", "Cybersecurity","Phishing", "Logic", "Productivity"]

print (vocab)

for i in range (1, len (vocab)):

   count = i - 1

   key = vocab[i]

   while (vocab[count] > key) and (count >= 0):

       vocab[count+1] = vocab[count]

       count -= 1

       vocab [count+1] = key

       print(vocab)

Explanation: bam baby

In this exercise we have to use the knowledge of the python language to write the code, so we have to:

The code is in the attached photo.

So to make it easier the code can be found at:

vocab = ["Libraries", "Bandwidth", "Hierarchy", "Software", "Firewall", "Cybersecurity","Phishing", "Logic", "Productivity"]

print (vocab)

for i in range (1, len (vocab)):

  count = i - 1

  key = vocab[i]

  while (vocab[count] > key) and (count >= 0):

      vocab[count+1] = vocab[count]

      count -= 1

      vocab [count+1] = key

      print(vocab)

See more about python at brainly.com/question/26104476

a farmer cultivates 1/4 of his farm with ground nuts and 2/5 of it with maize what is the total landnarea that is cultivated​

Answers

Answer:

13/20

egeringioerngierngineriogneirognoernogenroiernonoirenogneogneiong

Define a function named sum_values with two parameters. The first parameter will be a list of dictionaries (the data). The second parameter will be a string (a key). Return the sum of the dictionaries' values associated with the second parameter. You SHOULD NOT assume that all of the dictionaries in the first parameter will have the second parameter as a key. If none of the dictionaries have the second parameter as a key, your function should return 0. Sample function call: sum_values(data, 'estimated_annual_kwh_savings') sum_values_by_year

Answers

Answer:

Answered below

Explanation:

//Program is written in Python

sum = 0

def sum_of_values(dict_data, number_of_boys):

for dict in dict_data:

for key in dict.keys():

if key == number_of_boys:

sum += dict[key]

//After looping check the sum variable and //return the appropriate value.

if sum != 0:

return sum

elif sum == 0:

//There was no key of such so no addition.

return 0

Critiquing design: for each of these teapots , finish the statement last on the right that critique the object design

Answers

Answer:

Hey you have to add your own opinion. Like What you like about the teapot. what you wish was different. And What if meaning if it was changed how would it differ.

Explanation:

I like the design or this teapot. I wish it was made a little different. What if it was made different, it would be of more use and better to me.

what are the main technologies that have contributed to the growth and commercialization of the internet .​

Answers

Answer:

Explanation: The main forces that led to the commercialization of the internet are its demand and the importance of the Internet.

TCP and IP technologies allowed for the connection of many networks to form on large network. This tech used packets and provided error-recovery mechanisms. Hence many small networks were combined to form the internet.

There are several technology of the Internet and the World Wide Web. The hand of projects in computer networking, mostly funded by the federal government.

The projects made communications protocols that shows the format of network messages, prototype networks, and application programs such as browsers.

The advent of computer devices and telephone network was the underlying physical infrastructure upon which the Internet was built. The commercialization and exponential growth of the internet started in the early 1990s.

It was due to high meetup of technologies, including the development of personal computers with graphical operating systems, widespread availability of internet connection services, the removal of the restriction of commercial use on NSFnet, etc.

Conclusively, These happenings combined to give the commercial push for an easy way to share and access information.

Learn more from

https://brainly.com/question/22600646

c Write a recursive function called PrintNumPattern() to output the following number pattern.Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached.

Answers

Answer:

def PrintNumPattern(a,b):

 print(a)

 if (a <= 0): return

 PrintNumPattern(a-b,b)

 print(a)

PrintNumPattern(12,3)

Explanation:

Recursive functions are cool.

What element of art does this photograph show? A. shape B. space C. form D. tone E. line

Answers

I would for sure say form because it doesn't look like a flat surface, instead it looks 3-D, but If it is multiple choice then I say do C,D, and E.

Here is some advice tho, this question seems like an opinion question, soo, that means that you pick one that stands out to you and escribe why you think so in a descriptive way... if that is not the case then go ahead and use whatever i gave you. Just in case you may want to add a little more to the bolded answer I gave you, just to be professional, in case you do want to add more here is the defintion of form in case you need it

In addition to form, they include line, shape, value, color, texture, and space. As an Element of Art, form connotes something that is three-dimensional and encloses volume, having length, width, and height, versus shape, which is two-dimensional, or flat.

If this helps, I would like brainliest, when possible

Other Questions
Gas exchange is a primary example of simple diffusion, the exchange of _________ & __________ fuels the cellular processes such as photosynthesis and cellular respiration. what is the answer for this a la profesora que el examen fue dificil. (decir, preterite)5. Cuando ramos pequeos, nosotrosmucho (jugar, imperfect)6. Yo har el examen maana. (estudiar, present progressive)7. Qunosotros en la clase hoy? (hacer, present progressive)8. Sandrair al cine esta noche. (querer, present)9. Notan alto. (hablar, tu negative command)10. Noen la biblioteca. (hablar, Uds. negative command)11. Este verano mi familia y yo viajaremos por Europa. (viajar, future tense)12. Yo noesta noche porque tengo que estudiar (salir, future tense) The function table below represents the linear function y = 4x 3. Which answer represents the outputs of the function table Help, please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1. The height in feet of a thrown football is modeled by the function h(t) = -16t2 + 60t +6, where t is timein seconds.What does the value of h(3) represent in this context?A. The increase in the football's height after 3 seconds.B. The decrease in the football's height after 3 seconds.C. The football's height after 3 seconds.D. The time it takes for the football's height to reach 3 feet. PLZ HELP !!!!! plzzzz PLEASE HELP ASAP!!!what topiclevents do youknow are involved in WWII? (Provide 3 examples) Farah harvests 20 pounds of tomatoes from her garden. She needs 4 4/5 pounds to make a batch of soup. Additionally, if she uses 5.6 pounds of tomatoes to make spaghetti sauce, how many batches of soup can Farah make? I NEED HELP ASAP WILL GIVE BRAINLIST PLEASEE HELP List the simple shapes into which you divided shape C, and measure their sides. Write all the measurements in inches. Sophie bikes at a speed of s miles per hour. her friend rana is slower, her biking speed is only r miles per hour. Tomorrow both girls are planning to spend 3 hours biking. how much longer will be the sophies route Help need ASAP!Anita wants to start an online business and not use her real name. What type of form will Anita need to complete when opening a business? A. Franchise B. DBA (doing business as)C. Trademark D. Corporation Tatl Mariei i-a oferit acesteia 2 opiuni pentru banii de buzunar: 1/4 din 5 sau 1/2 din 5. Care opiune ar nsemna mai muli bani? Describe 3 physical properties of this object (color, state of matter, shape, size, hardness, etc) Factor as the product of two binomials.22 + 11x + 18 What is the equation for Hookes law ? the tasty Deli uses 6.5 lb of ham each day how many ounces of ham will be used in 3 weeks Which of the following is an example of a subtle use of alliteration, asopposed to a strong one?A. Betty feels tentative about the trip.O B. Fiona fixed fresh farmed fish for Fred.C. Martin makes most merchants mad.D. Dina danced dreamily during dinner. High owns 60% of Low. In 2019, Low sold inventory (cost $70,000) to High for $100,000. 40% of this inventory was not sold to third parties by High until 2020. In 2020, Low sold inventory (cost $72,000) to High for $120,000. Of this inventory, $50,000 was not sold to third parties by High until 2021. In 2020, Low reports $70,000 of net income. What is the noncontrolling interest in 2020 income of Low. $24,800 $31,200 $37,200 $46,800 3. Write an equation of a line with a slope of-2 and that passes through the point (-7,13).