Write a function named twoWordsV2 that has the same specification as Problem 1, but implement it using while and not using break. (Hint: provide a different boolean condition for while.) Since only the implementation has changed, and not the specification, for a given input the output should be identical to the output in Problem 1.

Answers

Answer 1

Answer:

I am writing a Python program. Here is the function twoWordsV2:

def twoWordsV2 (length,firstLetter):#definition of function which takes length of the first word and first letter of the second word as parameter and returns these two words in a list

   word1 = "" # stores the first word

   word2= "" #holds the second word  

   while(len(word1)!=length): # checks if the input word1 length is not equal to the specified length

       word1 = input('A ' + str(length) + '-letter word please: ') #asks user to enter the input word1 of specified length

   while(word2!=firstLetter): #checks if the first character of input word2 is not equal to the specified firstLetter character

       word2 = input('A word beginning with ' + firstLetter+ ' please: ')#asks user to enter the input word2 begining with specified first letter

       if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower():#second word may begin with either an upper or lower case instance of firstLetter      

           return [word1,word2] #return the two words in a list                

   

#to check the working of the function use the following statement        

print(twoWordsV2(4,'B')) #calls twoWordsV2  method by passing 4 (length) and B (first letter)

Explanation:  

twoWordsV2 method has two parameters i.e length which is the length of the first word and firstLetter which is the first character of the the second word. This means the first word should be of specified length, and the second word should begin with a specified first letter. The function returns the two resultant words with the above specifications. These two words are displayed in a list. I will explain the working of the function with the help of an example:

Suppose length = 4 and firstLetter = 'B' and user enters "ok" as word1. input() method takes first word input from user.

The first while loop checks if the length of word1 i.e. ok is not equal to specified length i.e. 4. Length of word1 is checked using len function which returns 2 so length of word1 is 2. The loop condition is true because length of word1 i.e. 2 is not equal to specified length i.e. 4. So the body of the loop executes which displays this message:

A 4-letter word please:

Here notice that str(length) is changed to 4. This is because length=4 and str() converts this value into string.

So the above message keeps displaying until user enters a four letter word. Lets suppose user now enters "four". Now the while loop condition evaluates to false and the loop breaks. The program control  moves to the next line which is a while loop.

The second while loop checks if the first character of input word2 is not equal to the specified firstLetter character. Suppose word2 = "apple" and firstLetter= 'B'

Now the loop condition evaluates to true because word2 is not equal to first letter B. Now the main part of this while loop is the if condition: if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower() This statement checks if the first index of the word2 is equal to firstLetter. The word2 can contain a capital B or a small B so if condition checks both the cases by using upper and lower methods that converts the firstLetter to upper or lower and then match with the first letter of word2 i.e. the letter at index 0 of the word2. If this condition evaluates to true then next return statement returns the word1 and word2 in a list otherwise the second while loop keep asking user to enter the word2 with starting letter to be firstLetter i.e. 'B'.

The screenshot of the program and its output is attached.

Write A Function Named TwoWordsV2 That Has The Same Specification As Problem 1, But Implement It Using
Answer 2

The function for the given problem is:

def twoWordsV2 (length,firstLetter):word1 = "" # stores the first wordword2= "" #holds the second word   while(len(word1)!=length): word1 = input('A ' + str(length) + '-letter word please: ') while(word2!=firstLetter): word2 = input('A word beginning with ' + firstLetter+ ' please: ')if word2[0] == firstLetter.upper() or word2[0] == firstLetter.lower():    return [word1,word2]     print(twoWordsV2(4,'B')) Brief Explanation:

These 10 lines of code were written using the Python programming language and this was used to define, store and hold the function and then request input from the user, check if the given input was according to the required parameters, and then print the output.

Read more about python programming language here:
https://brainly.com/question/7015522


Related Questions

A program is considered portable if it . . . can be rewritten in a different programming language without losing its meaning. can be quickly copied from conventional RAM into high-speed RAM. can be executed on multiple platforms. none of the above

Answers

Answer:

Can be executed on multiple platforms.

Explanation:

A program is portable if it is not platform dependent. In other words, if the program is not tightly coupled to a particular platform, then it is said to be portable. Portable programs can run on multiple platforms without having to do much work. By platform, we essentially mean the operating system and hardware configuration of the machine's CPU.

Examples of portable programs are those written in;

i. Java

ii. C++

iii. C

An algorithm that could execute for an unknown amount of time because it depends on random numbers to exit a function may:_______

a. have a redundancy.
b. get caught in an infinite loop.
c. suffer from indefinite postponement.
d. issue a compiler error.

Answers

Answer:

c. suffer from indefinite postponement.

Explanation:

Algorithm is a set of rules that are followed in calculations or other problem solving operation by a computer. An algorithm may execute for unknown amount of time and it may suffer indefinite postponement. Algorithm depends on random numbers and it can execute continuously.

What is the absolute pathname of the YUM configuration file? REMEMBER: An absolute pathname begins with a forward slash

Answers

Answer:

/etc/yum.conf

Explanation:

The absolute pathname for YUM is /etc/yum.conf. The configuration file For yum and related utilities can be found there. The file has one compulsory section, and this section can be used to place Yum options with global effect, it could also have one or more sections, that can enable you to set repository-specific options.

A security administrator is investigating a report that a user is receiving suspicious emails. The user's machine has an old functioning modem installed. Which of the following security concerns need to be identified and mitigated? (Select TWO).
a) Vishing
b) Whaling
c) Spear phishing
d) Pharming
e) War dialing
f) Hoaxing

Answers

Answer:

Spear Phishing and War Dialing

Explanation:

So let's tackle these one at a time.

Vishing is simply any type of message (i.e., email, text, phone call, etc.) that appears to be from a trusted source but is not.

Whaling is simply a spear phishing attack of a high-value target such as a CEO or someone with high-level access at a company.

Spear phishing is simply a targeted phishing attack, usually towards a specific person or group of people.  (Phishing attack is simply a social attack to try and gain unauthorized access to a resource).

Pharming is an attack that attempts to redirect website traffic to a fake site.

War dialing is a technique to automatically scan a list of numbers in an area in attempt to search for exposed modems, computers, board systems, or fax machines, in order to breach the network.

Hoaxing is simply a social attack that describes a serious threat in attempts to retrieve unauthorized access or money from a victim.  (Think microsoft tech support scams)

Now that we have defined these things, let's identify the possible threats that need to be reported.

(a) Vishing?  The sec admin report doesn't mention the source of the message so we cannot associate this one

(b) Whaling? The sec admin report says a user, implying someone not high up in the company, but doesn't say it's not someone high up.  This is possible.

(c) Spear phishing?  The sec admin report says a user, implying that only this user is being targeted so this is definitely valid.

(d) Pharming?  The sec admin report says nothing about site redirection.

(e) War dialing? The sec admin report doesn't say anything about unauthorized scanning; however, it mentions the user has an old functioning modem, so this is possible.

(f) Hoaxing?  The sec admin report doesn't mention a pop up in the email or the content of the email so we are uncertain.

Thus with these considerations, the two threats that are identified and need mitigation are Spear phishing and War Dialing/Whaling.  Note that we aren't positive of the war dialing or whaling, but a case could be made for either; however, given the modem information, the question seems to indicate war dialing.

3.16 (Gas Mileage) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls. Here is a sample input/output dialog:

Answers

Answer:

I am writing a C program.

#include <stdio.h> // for using input output functions

#include <stdbool.h> // for using a bool value as data type

int main() { // start of the main() function body

 int count=0; //count the number of entries

 double gallons, miles, MilesperGallon, combined_avg, sum; //declare variables

 while(true) {// takes input gallons and miles value from user and computes avg miles per gallon

      printf( "Enter the gallons used (-1 to stop): \n" ); //prompts user to enter value of gallons or enter -1 to stop

      scanf( "%lf", &gallons );//reads the value of gallons from user

   if ( gallons == -1 ) {// if user enters -1

     combined_avg = sum / count; //displays the combined average by dividing total of miles per drives to no of entries

     printf( "Combined miles per gallon for all tankfuls:  %lf\n", combined_avg ); //displays overall average value  

     break;} //ends the loop

     printf( "Enter the miles driven: \n" ); //if user does not enter -1 then prompts the user to enter value of miles

     scanf( "%lf", &miles ); //read the value of miles from user

MilesperGallon = miles / gallons; //compute the miles per gallon

printf( "The miles per gallon for tankful:  %lf\n", MilesperGallon ); //display the computed value of miles per gallon

  sum += MilesperGallon; //adds all the computed miles per gallons values

   count += 1;  } } //counts number of tankfuls (input entries)

Explanation:

The program takes as input the miles driven and gallons used for each tankful. These values are stored in miles and gallons variables. The program calculates and displays the miles per gallon MilesperGallon obtained for each tankful by dividing the miles driven with the gallons used. The while loop continues to execute until the user enters -1. After user enters -1, the program calculates and prints the combined miles per gallon obtained for all tankful. At the computation of MilesperGallon for each tankful, the value of MilesperGallon are added and stored in sum variable. The count variable works as a counter which is incremented to 1 after each entry. For example if user enters values for miles and gallons and the program displays MilesperGallon then at the end of this iteration the value of count is incremented to 1. This value of incremented for each tankful and then these values are added. The program's output is attached.

Programming Challenge: Test Average CalculatorUsing a variable length array, write a C program that asks the user to enter test scores.Then, the program should calculate the average, determine the lowest test score, determine the letter grade, and display all three.

Answers

Answer:

well you could use variables in C and display them

Explanation:

Write a method named removeDuplicates that accepts a string parameter and returns a new string with all consecutive occurrences of the same character in the string replaced by a single occurrence of that character. For example, the call of removeDuplicates("bookkeeeeeper") should return "bokeper" .

Answers

Answer:

//Method definition

//Method receives a String argument and returns a String value

public static String removeDuplicates(String str){

       //Create a new string to hold the unique characters

       String newString = "";

       

       //Create a loop to cycle through each of the characters in the

       //original string.

       for(int i=0; i<str.length(); i++){

           // For each of the cycles, using the indexOf() method,

           // check if the character at that position

           // already exists in the new string.

           if(newString.indexOf(str.charAt(i)) == -1){

               //if it does not exist, add it to the new string

               newString += str.charAt(i);

           }  //End of if statement

       }   //End of for statement

       

       return newString;   // return the new string

   }  //End of method definition

Sample Output:

removeDuplicates("bookkeeeeeper") => "bokeper"

Explanation:

The above code has been written in Java. It contains comments explaining every line of the code. Please go through the comments.

The actual lines of codes are written in bold-face to distinguish them from comments. The program has been re-written without comments as follows:

public static String removeDuplicates(String str){

       String newString = "";

       

       for(int i=0; i<str.length(); i++){

           if(newString.indexOf(str.charAt(i)) == -1){

               newString += str.charAt(i);

           }

       }

       

       return newString;

   }

From the sample output, when tested in a main application, a call to removeDuplicates("bookkeeeeeper") would return "bokeper"

Which of these statements are true about managing through Active Directory? Check all that apply.

Answers

Answer:

ADAC uses powershell

Domain Local, Global, and Universal are examples of group scenes

Explanation:

Active directory software is suitable for directory which is installed exclusively on Windows network. These directories have data which is shared volumes, servers, and computer accounts. The main function of active directory is that it centralizes the management of users.

It should be noted thst statements are true about managing through Active Directory are;

ADAC uses powershellDomain Local, Global, and Universal are examples of group scenes.

Active Directory can be regarded as directory service that is been put in place by  Microsoft and it serves a crucial purpose for Windows domain networks.

It should be noted that in managing through Active, ADAC uses powershell.

Therefore, in active directory Domain Local, Global, and Universal are examples of group scenes .

Learn more about Active Directory  at:

https://brainly.com/question/14364696

You are a project manager for Laredo Pioneer's Traveling Rodeo Show. You're heading up a project to promote a new line of souvenirs to be sold at the shows. You are getting ready to write the project management plan and know you need to consider elements such as policies, rules, systems, relationships, and norms in the organization. Which of the following is not true? A These describe the authority level of workers, fair payment practices, communication channels, and the like. B This describes organizational governance framework. C This describes management elements. D This is part of the EEF input to this process.

Answers

Answer:

A. These describe the authority level of workers, fair payment practices, communication channels, and the like.  

Explanation:

As seen in the question above, you have been asked to write the project management plan and know that you need to consider elements such as policies, rules, systems, relationships and standards in the organization. These elements are part of EEF's entry into this process, in addition they are fundamental and indispensable for the description not only of the organizational governance structure, but also describe the management elements that will be adopted and used.

However, there is no way to use them to describe the level of authority of workers, fair payment practices, communication channels and the like, as this is not the function of this.

Identify five key technologies/innovations and discuss their advantages and disadvantages to developing countries like Ghana.​

Answers

Answer:

The key technology/ innovation advantage and disadvantage can be defined as follows:

Explanation:

Following are the 5 innovations and technology, which promote the other development goals, like renewable energy, quality of jobs, and growth of economic with the good health and very well-being:

1) The use of crop monitoring drone technology promotes sustainable farming.  

2) The production of plastic brick including highways, floors, and houses.  

3) The new banking market or digital banking.  

4) E-commerce site.    

5) Renewable energy deployment such as solar panels.  

Advantage:

It simple insect control, disease, fertilizer, etc.   It helps in aid in environmental purification and job formation.It is also fast and easy,  Funds are transferred extremely easily through one account to another.  Minimal prices, quick customer developments, and competition in the industry.  It saves them money in the medium-haul, less servicing.

Disadvantage:

The drones are too expensive to use, so poor farmers can be cut off.  Specialist technicians and gaining popularity are required.  The financial services data can be distributed through many devices and therefore become more fragile.  The personal contact loss, theft, security problems, etc. The higher operating costs, geographical limitations, and so on.

Suppose we have the following page accesses: 1 2 3 4 2 3 4 1 2 1 1 3 1 4 and that there are three frames within our system. Using the FIFO replacement algorithm, what is the number of page faults for the given reference string?

Answers

Answer:

223 8s an order of algorithm faults refrénce fifio 14 suppose in 14 and 123 no need to take other numbers

Assume a PHP document named hello.php has been saved in a folder named carla inside the htdocs folder on your computer. Which is the correct path to enter to view this page in a browser?

Answers

The available options are:

A. localhost/Carla/hello.php

B. localhost/htdocs/hello.php

C. localhost/htdocs/Carla/hello.php

D. carla/hello.php5

Answer:

C.  localhost/htdocs/Carla/hello.php  

Explanation:

A path in computer programming can be defined as the name of a file or directory, which specifies a unique location in a file system.

Therefore, to get the correct path to enter to view this page in a browser, one needs to follow the directory tree hierarchy, which is expressed in a string of characters in which path components, separated by a delimiting character, represent each directory.

Hence, correct path to enter to view this page in a browser is "localhost/htdocs/Carla/hello.php"

What is the main advantage of using DHCP? A. Allows you to manually set IP addresses B. Allows usage of static IP addresses C. Leases IP addresses, removing the need to manually assign addresses D. Maps IP addresses to human readable URLs

Answers

Answer: DHCP (dynamic host configuration protocol)  is a protocol which automatically processes the configuring devices on IP networks.It allows them to to use network services like: NTP and any communication proto cal based on UDP or TCP. DHCP assigns an IP adress and other network configuration parameters to each device on a network so they can communicate with  other IP networks. it is a part of DDI solution.

 

Explanation:

Discuss the differences between dimensionality reduction based on aggregation and dimensionality reduction based on techniques such as PCA and SVD.

Answers

Answer:

Following are the difference to this question can be defined as follows:

Explanation:

In terms of projections of information into a reduced dimension group, we can consider the dimension structure of PCA and SVD technologies.  In cases of a change in the length, based on consolidation, there's also a unit with dimensions. When we consider that the days have been aggregated by days or the trade of a commodity can be aggregated to both the area of the dimension, accumulation can be seen with a variance of dimension.

Dimensionality reduction based on aggregation involves selection of important character and variable from a large variable and dimensionality reduction based on techniques with the use of PCA and SVD.

What is dimensionality?

Dimensionality involves reducing features that have been written or identified or constructing less features from a pool of important features.

Principal components analysis(PCA) and Single value decomposition(SVD) is a form or analysis that can be used to reduce some character that are not important to an information and can also help to select important variables from among many variables.

Therefore, dimensionality reduction based on aggregation involves selection of important character and variable from a large variable and dimensionality reduction based on techniques with PCA and SVD.

Learn more on dimensional analysis here,

https://brainly.com/question/24514347

A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the client, the service sold (such as Dinner, Conference, Lodging, and so on), the amount of the sale, and the date of that event. Write a program that reads such a file and displays the total amount for each service category. Display an error if the file does not exist or the format is incorrect.

Answers

Answer:

Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?

Explanation:

Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?Life can get busy and hectic, but relationships matter. What is an effective way of mending relationships that may have had been neglected?

Steve wants to take charge of his finances. To do so, he must track his income and expenditures. To accurately calculate his take-home pay, Steve must use his __________.

Answers

Answer:brain

Explanation:

to think

7. When using find command in word we can search?
a. Characters
b. Formats
c. Symbols
d. All of the above

Answers

Answer:

When using find command in word we can search all of the above

What is a what if analysis in Excel example?

Answers

Answer:

What-If Analysis in Excel allows you to try out different values (scenarios) for formulas. The following example helps you master what-if analysis quickly and easily.

Assume you own a book store and have 100 books in storage. You sell a certain % for the highest price of $50 and a certain % for the lower price of $20.

(i really hope this is what u needed)

You turn on your Windows computer and see the system display POST messages. Then the screen goes blank with no text. Which of the following items could be the source of the problem?
1. The video card
2. The monitor
3. Windows
4. Microsoft word software installed on the system.

Answers

Answer:1)The video card
***HOPE THIS HELP YOU***
Other Questions
If a bottle of olive oil contains 1.2 kg of olive oil, what is the volume, in milliliters (mL), of the olive oil? Why does deleting just one nucleotide cause a dramatic change in the amino acid sequence produced by translation Solve the proportion below.X =A. 24B. 49c. 27D. 6 Points A,B,C and D are midpoints of the sides of the larger square. If the smaller square has area 60, what is the area of the bigger square? How did the Soviet people lose their freedom to communist A cube has a side length of 5 cm. Determine the surface area of the largest pyramid that will fit inside the cube. Round if necessary. The area of a circle is found using the formula A=\pi r^(2) , where r is the radius. If the area of a circle is 36 square feet, what is the radius, in feet? A. 6 B. 6 C. 18 D. 9 Which statement best describes how Watson and Crick's model used other scientists work to create a model of DNA?They used Chargaff's rule to determine that it contains ribose sugarO They used Franklin's photo to determine that DNA was a double helix.They used Levene's work to determine the number of base pairs in each strand.O They used Nirenberg and Matthei's studies to determine that DNA is made of nucleotides. Simplify the expression.Write your answer without negative exponents. NEED AN ANSWER ASAP Fill in the blank with a constant, so that the resulting expression can be factored as the product of two linear expressions: 2ab-6a+5b+___ Please include an explanation too! An account at a commercial bank designed for people who want to earn a higher savings rate is a(n) __________ account. Question options: regular savings account, ,regular checking ,share draft , or money market account Suppose that a 117.5 kg football player running at 6.5 m/s catches a 0.43 kg ball moving at a speed of 26.5 m/s with his feet off the ground, while both of them are moving horizontally.(a) Calculate the final speed of the player, in meters per second, if the ball and player are initially moving in the same direction. (b) Calculate the change in kinetic energy of the system, in joules, after the player catches the ball. (c) Calculate the final speed of the player, in meters per second, if the ball and player are initially moving in opposite directions. (d) Calculate the change in kinetic energy of the system, in joules, in this case. When deriving the quadratic formula by completing the square, what expression can be added to both sides of the equation to create a perfect square trinomial? A researcher predicts that the proportion of people over 65 years of age in a certain city is 11%. To test this, a sample of 1000 people is taken. Of this sample population, 126 people are over 65 years of age. The following is the setup for this hypothesis test: H0:p=0.11 Ha:p0.11 The p-value was determined to be 0.106. Come to a conclusion and interpret the results for this hypothesis test for a proportion (use a significance level of 5%) Select all that apply: a. Reject the H0. b. Fail to reject the H0. c. There is NOT sufficient evidence to conclude the proportion of people over 65 years of age in a certain city is 11%. d. There is sufficient evidence to conclude the proportion of people over 65 years of age in a certain city is 11%. Please helpsimplify the expression ab-ba/ab(a+b) Which of the following is NOT part of the urinary system? Question 9 options: A-Kidneys B-Bladder C-Urethra D-Spinal cord Who do you think the main character of the play The Glass Menagerie? Tom, Laura or Amanda? Why?? Is he or she the protagonist?? Is there an antagonist?? Write 3-5 Paragraphs. (This is due at 4:30 P.M.) How do you solve these adding negative numbers equations? Please explain thoroughly step by step.5+ (-3) = 8 + (-2)=3+(-4) = 6+ (-6)=1 + (-5)=(-2) + 5=(-7) + 4 =(-1) + 8 =(-6) + 3 =(-9) + 5 = Which is a software configuration management concept that helps us to control change without seriously impeding justifiable change? With an increase in product advertising of $50 million you expect to increase sales by 10,000 units. If unit grow margin is $4,800, will the additional advertising increase product contribution?